:root {
  color-scheme: only light;
  --bg-top: #ffe9f0;
  --bg-bottom: #d8f7ff;
  --accent: #ff7a59;
  --accent-dark: #ff5a2f;
  --soft-blue: #77d2ff;
  --soft-yellow: #ffe18a;
  --soft-green: #8ee8b9;
  --shadow: 0 18px 40px rgba(34, 40, 71, 0.18);
  --card-bg: #fffdf8;
  --text: #2b2b2b;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Comic Sans MS", "Trebuchet MS", "Verdana", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, var(--bg-top), transparent 50%),
    linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
  background-attachment: fixed;
  display: flex;
  justify-content: center;
  align-items: center;
}

.app {
  width: min(100%, 1100px);
  min-height: 100vh;
  padding: 24px;
  position: relative;
}

.screen {
  display: none;
  min-height: 100%;
  align-items: center;
  justify-content: center;
}

.screen.is-active {
  display: flex;
}

.screen-start,
.screen-end {
  text-align: center;
}

.start-card,
.end-card {
  background: var(--card-bg);
  padding: 32px 28px;
  border-radius: 28px;
  box-shadow: var(--shadow);
  max-width: 420px;
}

.start-card h1,
.end-card h2 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4vw, 3rem);
}

.start-card p {
  margin: 0 0 24px;
  font-size: 1.2rem;
}

.start-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 22px;
}

.start-stats .total-row {
  font-size: 1.1rem;
  padding: 8px 10px;
}

.mode-panel,
.difficulty-panel {
  text-align: left;
  margin-bottom: 18px;
}

.language-panel {
  text-align: left;
  margin-bottom: 18px;
}

.history-panel {
  text-align: left;
  margin-top: 18px;
}

.history-panel h2 {
  margin: 0 0 10px;
  font-size: 1.2rem;
}

.history-table {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 8px 16px rgba(34, 40, 71, 0.15);
  font-size: 0.95rem;
  max-height: 180px;
  overflow-y: auto;
}

.history-row {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr 0.8fr 0.8fr 0.8fr 0.7fr;
  gap: 6px;
  padding: 6px 4px;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.08);
}

.history-row:last-child {
  border-bottom: none;
}

.history-head {
  font-weight: 700;
}

.toggle-panel {
  text-align: left;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mode-panel h2,
.difficulty-panel h2,
.toggle-panel h2,
.language-panel h2 {
  margin: 0 0 10px;
  font-size: 1.2rem;
}

.mode-grid,
.difficulty-grid,
.language-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mode-button,
.difficulty-button,
.ghost-button {
  border: none;
  border-radius: 16px;
  padding: 12px 10px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 16px rgba(34, 40, 71, 0.15);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.mode-icon {
  font-size: 1.5rem;
}

.difficulty-text {
  font-size: 1rem;
  font-weight: 700;
}

.mode-button,
.difficulty-button,
.language-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
}

.language-button {
  border: none;
  border-radius: 16px;
  padding: 12px 10px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 16px rgba(34, 40, 71, 0.15);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.language-button.is-selected {
  background: var(--soft-green);
}

.language-button:active {
  transform: scale(0.98);
}

.toggle-button {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--soft-green);
  color: #1e3b2c;
  box-shadow: 0 8px 16px rgba(34, 40, 71, 0.15);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.toggle-button.is-on {
  background: var(--soft-green);
}

.toggle-button.is-off {
  background: #d6e8dc;
  color: #2c4b3b;
}

.start-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 6px 0 10px;
}

.info-button {
  border: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #fff1cf;
  color: #7a4a00;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(156, 112, 47, 0.2);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.info-button:active {
  transform: scale(0.95);
  box-shadow: 0 5px 12px rgba(156, 112, 47, 0.18);
}

.mode-button.is-selected,
.difficulty-button.is-selected {
  background: var(--soft-green);
}

.mode-button:active,
.difficulty-button:active,
.ghost-button:active {
  transform: scale(0.98);
}

.mode-button.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.ghost-button {
  margin-top: 12px;
  background: transparent;
  border: 2px dashed rgba(34, 40, 71, 0.2);
}

.cta-button {
  border: none;
  background: var(--accent);
  color: white;
  font-size: 1.4rem;
  padding: 14px 32px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(255, 122, 89, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cta-button:active {
  transform: scale(0.97);
  box-shadow: 0 6px 16px rgba(255, 122, 89, 0.28);
}

.screen-game {
  width: 100%;
  flex-direction: column;
  gap: 20px;
}

.top-bar {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
}

.top-side {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-side-right {
  justify-content: flex-end;
}

.reward-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.8rem;
  background: rgba(255, 255, 255, 0.75);
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: 0 8px 16px rgba(75, 125, 160, 0.2);
}

.lives-slot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1.4rem;
  background: rgba(255, 255, 255, 0.75);
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: 0 8px 16px rgba(75, 125, 160, 0.2);
}

.level-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.35rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.75);
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: 0 8px 16px rgba(75, 125, 160, 0.2);
}

.level-label {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.level-count {
  font-size: 1.4rem;
}

.level-title {
  font-size: 0.95rem;
  font-weight: 700;
}

.level-emoji {
  font-size: 1.3rem;
}

.life {
  filter: drop-shadow(0 4px 6px rgba(255, 90, 47, 0.35));
}

.life.is-lost {
  opacity: 0.3;
  filter: none;
}

.reward-emoji {
  font-size: 1.9rem;
}

.reward-count {
  font-weight: 700;
}

.timer {
  position: relative;
  font-size: 2.2rem;
  font-weight: 700;
  padding: 10px 26px;
  border-radius: 999px;
  background: var(--soft-yellow);
  box-shadow: 0 8px 18px rgba(255, 206, 72, 0.3);
  justify-self: center;
}

.pause-button {
  border: none;
  background: #ffd4aa;
  color: #4a2d00;
  font-size: 1.4rem;
  width: 52px;
  height: 52px;
  border-radius: 18px;
  box-shadow: 0 10px 18px rgba(255, 157, 79, 0.35);
  cursor: pointer;
}

.timer-ring {
  position: absolute;
  inset: -6px;
  border-radius: 999px;
  border: 3px dashed rgba(255, 140, 0, 0.3);
  animation: spin 10s linear infinite;
  pointer-events: none;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.audio-row {
  width: min(100%, 900px);
  display: block;
}

.replay-button {
  border: none;
  background: var(--soft-blue);
  color: #123;
  width: 64px;
  height: 64px;
  border-radius: 24px;
  font-size: 1.8rem;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(45, 138, 200, 0.3);
}


.replay-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.bonus-bars {
  flex: 1;
  display: grid;
  gap: 8px;
}

.bonus-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}

.bar-label,
.bar-time {
  font-size: 0.95rem;
  font-weight: 700;
  min-width: 36px;
  text-align: center;
  color: #3a3a3a;
}

.bonus-track,
.double-track {
  height: 18px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.08);
}

.bonus-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--soft-green), var(--soft-yellow));
  transition: width 0.1s linear;
}

.double-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff9ed8, #ffd36a);
  transition: width 0.1s linear;
}

.prompt-display {
  width: min(100%, 560px);
  min-height: 48px;
  text-align: center;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 18px;
  padding: 10px 14px;
  box-shadow: inset 0 6px 12px rgba(0, 0, 0, 0.08);
}

.prompt-display.is-hidden {
  display: none;
}

.prompt-display.is-rtl {
  direction: rtl;
}

.answer-card.word-card {
  font-size: clamp(2.8rem, 6vw, 4.2rem);
  padding: 12px;
}

.card-grid {
  width: min(100%, 900px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.answer-card {
  background: var(--card-bg);
  border: none;
  border-radius: 26px;
  padding: 10px;
  min-height: 160px;
  font-size: clamp(2.4rem, 5vw, 3.8rem);
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.answer-card:active {
  transform: scale(0.98);
  box-shadow: 0 10px 24px rgba(34, 40, 71, 0.2);
}

.answer-card.is-correct {
  background: #e7fff2;
  animation: pop 0.4s ease;
}

.answer-card.is-wrong {
  background: #ffeaea;
  animation: shake 0.35s ease;
}

@keyframes pop {
  0% {
    transform: scale(1);
  }
  60% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(32px, 1fr));
  gap: 4px;
  justify-items: center;
  align-items: center;
  font-size: clamp(2rem, 5vw, 2.8rem);
}

.reward-float {
  position: fixed;
  inset: auto auto 20% 50%;
  transform: translateX(-50%);
  font-size: 3rem;
  opacity: 0;
  pointer-events: none;
}

.reward-float.is-showing {
  animation: float-up 1s ease forwards;
}

@keyframes float-up {
  0% {
    transform: translate(-50%, 0);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -60px);
    opacity: 0;
  }
}

.screen-end .totals {
  display: grid;
  gap: 16px;
  font-size: 1.6rem;
  margin: 18px 0 24px;
}

.rules-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 244, 230, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 20;
}

.rules-overlay.is-active {
  display: flex;
}

.rules-card {
  background: var(--card-bg);
  padding: 24px;
  border-radius: 22px;
  box-shadow: var(--shadow);
  max-width: 420px;
  text-align: left;
}

.rules-card h2 {
  margin: 0 0 12px;
  font-size: 1.6rem;
}

.rules-card ul {
  margin: 0 0 18px;
  padding-left: 18px;
  display: grid;
  gap: 10px;
  font-size: 1rem;
}

.pause-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.pause-overlay.is-active {
  display: flex;
}

.pause-card {
  background: var(--card-bg);
  padding: 28px;
  border-radius: 24px;
  box-shadow: var(--shadow);
  text-align: center;
}

.total-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.8);
  padding: 10px 18px;
  border-radius: 18px;
}

.total-emoji {
  font-size: 2rem;
}

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 12px;
  height: 18px;
  opacity: 0.9;
  animation: confetti-fall 3s linear infinite;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(-120px) rotate(0deg);
  }
  100% {
    transform: translateY(120vh) rotate(360deg);
  }
}

@media (max-width: 720px) {
  .card-grid {
    grid-template-columns: 1fr;
  }

  .start-stats {
    grid-template-columns: 1fr 1fr;
  }

  .reward-slot {
    font-size: 1.3rem;
  }

  .lives-slot {
    font-size: 1.1rem;
  }

  .level-slot {
    font-size: 1rem;
    padding: 6px 10px;
  }

  .answer-card {
    min-height: 140px;
  }
}
