: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;
  overflow: hidden;
}

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

.page-title {
  margin: 0 0 8px;
  font-size: 1.4rem;
  font-weight: 800;
  text-align: center;
}

.bottom-tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 10px 0 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 233, 240, 0.9));
  z-index: 5;
}

.in-game .bottom-tabs {
  display: none;
}

.tab-button {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.85);
  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;
}

.tab-button.is-active {
  background: var(--soft-green);
}

.tab-panel {
  display: none;
  height: calc(100vh - 60px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 110px;
}

.tab-panel.is-active {
  display: block;
}

.tab-panel::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.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: 520px;
  width: min(100%, 520px);
}

.profile-card {
  background: var(--card-bg);
  padding: 32px 28px;
  border-radius: 28px;
  box-shadow: var(--shadow);
  max-width: 520px;
  width: min(100%, 520px);
  margin: 0 auto;
  text-align: center;
}

.profile-stats {
  display: grid;
  gap: 16px;
  margin-bottom: 10px;
}

.profile-stack {
  display: grid;
  gap: 10px;
}

.profile-row {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 18px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  box-shadow: 0 8px 16px rgba(34, 40, 71, 0.12);
}

.profile-row .profile-icon {
  font-size: 2rem;
}

.profile-row .profile-value {
  font-size: 1.2rem;
  font-weight: 800;
}

.profile-row .profile-meta {
  font-size: 0.85rem;
  color: #4a4a4a;
  font-weight: 700;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .profile-row .profile-meta {
    font-size: 0.75rem;
  }
}

.profile-currency {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.currency-item {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 18px;
  padding: 10px 8px;
  display: grid;
  justify-items: center;
  gap: 4px;
  box-shadow: 0 8px 16px rgba(34, 40, 71, 0.12);
}

.currency-item .profile-icon {
  font-size: 2rem;
}

.currency-item .profile-value {
  font-size: 1.1rem;
  font-weight: 800;
}

.currency-item .profile-label {
  font-size: 0.8rem;
  color: #4a4a4a;
  font-weight: 700;
}

.report-panel {
  margin-top: 16px;
}

.report-card {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 8px 16px rgba(34, 40, 71, 0.12);
  text-align: left;
}

.report-card h3 {
  margin: 0 0 10px;
}

.report-table {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.report-row {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
}

.report-section {
  background: rgba(255, 255, 255, 0.75);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 6px 12px rgba(34, 40, 71, 0.1);
}

.report-text {
  margin-top: 6px;
  font-size: 0.9rem;
  color: #4a4a4a;
  line-height: 1.3;
}

.report-skills {
  font-weight: 700;
  color: #2c4b3b;
}

.report-note {
  font-size: 0.9rem;
  color: #5a5a5a;
  margin-bottom: 10px;
}

.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: center;
  margin: 6px 0 10px;
}

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

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

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-header h2 {
  margin-top: -4;
}

#clear-history-button {
  padding: 2px 8px;
  font-size: 0.75rem;
  background: #ff6b6b;
  color: #fff;
  box-shadow: 0 6px 12px rgba(255, 107, 107, 0.3);
  align-self: center;
  margin-top: -10px;
}

#clear-history-button:hover {
  background: #ff4d4d;
}

#report-button {
  margin-top: 16px;
}

#change-name-button {
  margin-top: 14px;
}

.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-table.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  text-align: center;
}

.history-table.is-empty {
  font-weight: 700;
  color: #3a3a3a;
}

.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);
  text-align: center;
}

.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 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 120px));
  gap: 10px;
  justify-content: center;
}

.mode-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 120px));
  gap: 10px;
  margin-top: 10px;
  justify-content: center;
}

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

.language-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  justify-items: center;
}

.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-button {
  aspect-ratio: 1 / 1;
  width: 100%;
  padding: 2px;
  font-size: 1.5rem;
}

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

.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;
}

.mode-label {
  font-size: 1.8rem;
  font-weight: 700;
}

.mode-row .mode-label {
  font-size: 2.2rem;
}

@media (max-width: 480px) {
  .mode-row .mode-label {
    font-size: 2rem;
  }
}

.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;
}

.screen-color {
  width: 100%;
  justify-content: center;
}

.screen-write {
  width: 100%;
  justify-content: center;
}

.color-card {
  background: var(--card-bg);
  padding: 28px 22px;
  border-radius: 24px;
  box-shadow: var(--shadow);
  text-align: center;
  width: min(100%, 520px);
  display: grid;
  gap: 14px;
  position: relative;
  justify-items: center;
}

.write-card {
  background: var(--card-bg);
  padding: 28px 22px;
  border-radius: 24px;
  box-shadow: var(--shadow);
  text-align: center;
  width: min(100%, 560px);
  display: grid;
  gap: 14px;
  justify-items: center;
}

.color-palette {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 3px solid transparent;
  cursor: pointer;
  background: #eee;
  box-shadow: 0 6px 12px rgba(34, 40, 71, 0.2);
}

.color-swatch.is-selected {
  border-color: #222;
}

.color-swatch[data-color="#ff7a59"] {
  background: #ff7a59;
}

.color-swatch[data-color="#2b88ff"] {
  background: #2b88ff;
}

.color-swatch[data-color="#8ee8b9"] {
  background: #8ee8b9;
}

.color-swatch[data-color="#ffd36a"] {
  background: #ffd36a;
}

.color-swatch[data-color="#9b5de5"] {
  background: #9b5de5;
}

.color-swatch[data-color="#8d5524"] {
  background: #8d5524;
}

.color-swatch[data-color="rainbow"] {
  background: linear-gradient(90deg, #ff595e, #ffca3a, #8ac926, #1982c4, #6a4c93);
}

.color-swatch[data-color="rainbow-grad"] {
  background: linear-gradient(90deg, #ff004d, #ff7a00, #ffd500, #a3ff00, #00ffd5, #0052ff, #6a00ff, #ff00b3);
}

#color-canvas {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 24px rgba(34, 40, 71, 0.18);
  touch-action: none;
  border: 6px solid rgba(255, 255, 255, 0.7);
  margin: 0 auto;
}

#color-home,
#write-home {
  position: relative;
  z-index: 2;
}

#write-canvas {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 24px rgba(34, 40, 71, 0.18);
  touch-action: none;
  border: 6px solid rgba(255, 255, 255, 0.7);
  margin: 0 auto;
}

.color-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.write-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.color-result {
  font-size: 1.2rem;
  font-weight: 700;
  min-height: 1.4rem;
}

.celebrate-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

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

.celebrate-card {
  background: rgba(255, 255, 255, 0.9);
  padding: 20px 26px;
  border-radius: 22px;
  box-shadow: var(--shadow);
  text-align: center;
  z-index: 2;
}

.celebrate-score {
  font-size: clamp(2.6rem, 8vw, 4rem);
  font-weight: 800;
  color: #ff7a59;
}

.celebrate-balloon {
  font-size: clamp(2.4rem, 7vw, 3.6rem);
  animation: balloon-float 1.6s ease-in-out infinite;
}

.celebrate-text {
  font-size: 1.4rem;
  font-weight: 700;
}

.fireworks {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 1;
}

.spark {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  opacity: 0;
  animation: spark-pop 1.4s ease-out infinite;
}

@keyframes spark-pop {
  0% {
    transform: scale(0.2);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    transform: scale(2.6);
    opacity: 0;
  }
}

@keyframes balloon-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

.write-word {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800;
  background: rgba(255, 255, 255, 0.7);
  padding: 6px 12px;
  border-radius: 14px;
  display: inline-block;
}

.write-word.is-rtl {
  direction: rtl;
}

.write-result {
  font-size: 1.2rem;
  font-weight: 700;
  min-height: 1.4rem;
}

.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;
}

.kid-greeting {
  font-size: clamp(1rem, 3.2vw, 1.4rem);
  font-weight: 700;
  text-align: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 8px 16px rgba(75, 125, 160, 0.2);
}

.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;
}

.rules-card p {
  margin: 0 0 18px;
  font-size: 1rem;
}

.confirm-card {
  text-align: center;
  background: #fff7f0;
}

.confirm-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}

.name-input {
  width: 100%;
  border: 2px solid rgba(0, 0, 0, 0.12);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 1rem;
  margin: 0 0 14px;
  background: #fff;
}

.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: repeat(2, minmax(0, 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;
  }
}

@media (max-width: 480px) {
  body {
    align-items: flex-start;
    overflow: auto;
  }

  .app {
    padding: 16px;
    height: auto;
    min-height: 100vh;
  }

  .tab-panel {
    height: auto;
    min-height: calc(100vh - 60px);
    overflow-y: visible;
  }

  .start-card,
  .end-card,
  .profile-card {
    padding: 20px 16px;
    border-radius: 20px;
  }

  .mode-grid {
    grid-template-columns: repeat(2, minmax(0, 100px));
    justify-content: center;
  }

  .mode-row {
    grid-template-columns: repeat(2, minmax(0, 100px));
    justify-content: center;
  }

  .mode-button {
    font-size: 0.8rem;
  }

  .language-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .difficulty-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-grid {
    width: 100%;
    gap: 12px;
  }

  .answer-card {
    min-height: 120px;
    font-size: clamp(2rem, 7vw, 3rem);
  }

  .bottom-tabs {
    padding: 8px 0 12px;
  }
}
