@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@700;900&family=Orbitron:wght@700&display=swap");
:root {
  --primary: #6a89a4;
  --primary-dark: #3d5a70;
  --secondary: #a7c7e7;
  --accent: #63bba4;
  --error: #e57373;
  --success: #59a894;
  --bg: linear-gradient(135deg, #fdfeff 0%, #f1f6fb 100%);
  --card-bg: #ffffff;
  --card-border: #e9eff4;
  --shadow-sm: 0 2px 4px rgba(106, 137, 164, 0.05);
  --shadow-md: 0 4px 12px rgba(106, 137, 164, 0.08);
  --shadow-lg: 0 10px 30px rgba(106, 137, 164, 0.1);
  --radius: 20px;
  --font-main: "Poppins", "Apple SD Gothic Neo", "sans-serif";
  --font-digit: "Orbitron", monospace;
  --text-main: #333;
  --text-sub: #555;
  --text-muted: #888;
  --button-bg: linear-gradient(90deg, #7ba9d4 0%, #59a894 100%);
  --button-bg-hover: linear-gradient(90deg, #8fb8de 0%, #63bba4 100%);
  --button-text: #fff;
  --footer-bg: rgba(248, 250, 253, 0.8);
}
body {
  background: var(--bg);
  font-family: var(--font-main);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  color: var(--text-main);
  position: relative;
  overflow-x: hidden;
  animation: fadeIn 0.6s ease-out;
}
body.game-inactive header,
body.game-inactive main,
body.game-inactive #footer-bar {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
header {
  position: relative;
  z-index: 2;
  max-width: 440px;
  margin: 0 auto;
  padding: 24px 16px 20px 16px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 15px;
  align-items: center;
}
.logo {
  grid-row: 1 / 4;
  width: 60px;
  height: 60px;
  margin: 0;
}
h1 {
  grid-column: 2;
  grid-row: 1;
  font-size: 2rem;
  font-weight: 900;
  color: var(--primary-dark);
  margin: 0;
  letter-spacing: -1px;
  align-self: end;
}
#stage {
  grid-column: 2;
  grid-row: 2;
  font-size: 1.1rem;
  color: var(--accent);
  font-weight: 700;
  margin: 0;
}
#chances {
  grid-column: 2;
  grid-row: 3;
  font-size: 1.2rem;
  font-family: var(--font-digit);
  margin: 0;
}
main {
  max-width: 440px;
  margin: 0 auto;
  padding: 0 16px 80px 16px;
  position: relative;
  z-index: 2;
}
#products {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 24px;
}
.product-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1.5px solid var(--card-border);
  padding: 20px 18px 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  position: relative;
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
}
.product-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.product-quantity {
  color: var(--accent);
}
.product-price {
  font-weight: 900;
  color: var(--primary-dark);
}
.product-card .icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  filter: none;
}
.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.options {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 22px;
}
.options button {
  background: var(--button-bg);
  color: var(--button-text);
  font-size: 1.18rem;
  font-family: var(--font-main);
  font-weight: 700;
  border: none;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 20px 0;
  cursor: pointer;
  transition: all 0.2s ease-out;
  outline: none;
  letter-spacing: 0.5px;
  width: 100%;
  position: relative;
  overflow: hidden;
}
.options button:active {
  transform: scale(0.97);
}
.options button:hover,
.options button:focus {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.options button.selected {
  animation: popBtn 0.4s cubic-bezier(0.5, 1.6, 0.5, 1);
  background: var(--success);
  color: #fff;
}
@keyframes popBtn {
  0% {
    transform: scale(0.93);
  }
  70% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}
#timer-bar-wrap {
  width: 100%;
  height: 16px;
  background: #e0e6ed;
  border-radius: 10px;
  margin: 0 0 20px 0;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
}
#timer-bar {
  height: 100%;
  width: 100%;
  background: var(--button-bg-hover);
  border-radius: 10px;
  transition: width 0.2s linear;
}
#timer-bar-label {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-digit);
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
  pointer-events: none;
  letter-spacing: 0.2px;
  user-select: none;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
}
#result {
  font-size: 1.13rem;
  font-weight: 900;
  min-height: 34px;
  margin-bottom: 14px;
  color: var(--primary);
  transition: color 0.2s;
}
/* Toast Notification */
.toast {
  position: fixed;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--error);
  color: #fff;
  padding: 16px 24px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  font-weight: 700;
  font-size: 1rem;
  opacity: 0;
  transition: top 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55),
    opacity 0.5s ease;
  pointer-events: none;
}
.toast.show {
  top: 20px;
  opacity: 1;
}
.toast.success {
  background: var(--success);
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes popIn {
  0% {
    transform: scale(0.7);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(248, 250, 253, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99;
  display: none;
}
.modal-overlay.active {
  display: flex;
}
.modal-overlay .modal-content {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 28px;
  padding: 32px 24px 22px 24px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  min-width: 220px;
  max-width: 92vw;
  animation: popIn 0.4s cubic-bezier(0.6, 1.5, 0.5, 1);
  border: 1px solid rgba(255, 255, 255, 0.8);
}
.modal-overlay h2 {
  font-size: 1.4rem;
  font-weight: 900;
  margin: 0 0 12px 0;
  color: var(--primary-dark);
}
.modal-overlay p {
  font-size: 1.07rem;
  color: var(--text-main);
  margin-bottom: 18px;
}
.modal-overlay button {
  background: var(--button-bg);
  color: var(--button-text);
  font-size: 1.13rem;
  font-family: var(--font-main);
  font-weight: 700;
  border: none;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 15px 0;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s ease-out;
}
.modal-overlay button:hover {
  background: var(--button-bg-hover);
  color: var(--primary);
}
#footer-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--footer-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--card-border);
  border-radius: 24px 24px 0 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  min-height: 44px;
  font-size: 1.01rem;
  color: var(--primary-dark);
  z-index: 10;
  font-family: var(--font-digit);
  font-weight: 700;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
#footer-bar .icon {
  font-size: 1.17em;
}
@media (max-width: 600px) {
  main {
    padding: 0 2vw 70px 2vw;
  }
  .product-card {
    font-size: 1.03rem;
    padding: 12px 10px 10px 10px;
  }
  h1 {
    font-size: 1.9rem;
  }
  .modal-overlay .modal-content {
    padding: 14px 4px 10px 4px;
  }
}
