:root {
  --bg: #101820;
  --ink: #17212b;
  --paper: #fff7e8;
  --paper-2: #ffe9bf;
  --mint: #58c6a4;
  --blue: #3478f6;
  --red: #f05f57;
  --yellow: #ffc857;
  --line: rgba(23, 33, 43, 0.14);
  --shadow: 0 16px 40px rgba(16, 24, 32, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(52, 120, 246, 0.12), transparent 38%),
    linear-gradient(135deg, #fff9eb 0%, #e9f7f0 54%, #eef3ff 100%);
  color: var(--ink);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  overflow: hidden;
}

button {
  border: 0;
  border-radius: 8px;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.game-shell {
  width: 100%;
  max-width: none;
  min-height: 100vh;
}

.sound-control {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: 14px;
  display: grid;
  gap: 4px;
  min-width: 0;
  max-width: 360px;
  padding: 6px 10px;
}

.sound-row {
  align-items: center;
  display: grid;
  gap: 6px;
  grid-template-columns: 62px minmax(0, 1fr);
  min-width: 0;
}

.sound-toggle-row {
  grid-template-columns: 34px minmax(0, 1fr);
}

.sound-row label {
  color: var(--ink);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.2;
}

.sound-row input[type="range"],
.sound-row select {
  accent-color: var(--blue);
  width: 100%;
}

.sound-row input[type="checkbox"] {
  appearance: none;
  background: #d8e0eb;
  border-radius: 999px;
  cursor: pointer;
  height: 18px;
  margin: 0;
  position: relative;
  width: 34px;
}

.sound-row input[type="checkbox"]::after {
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(23, 33, 43, 0.24);
  content: "";
  height: 14px;
  left: 2px;
  position: absolute;
  top: 2px;
  transition: transform 0.18s ease;
  width: 14px;
}

.sound-row input[type="checkbox"]:checked {
  background: var(--blue);
}

.sound-row input[type="checkbox"]:checked::after {
  transform: translateX(16px);
}

.sound-row input[type="range"] {
  cursor: pointer;
}

.sound-row select {
  appearance: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(243, 246, 252, 0.98)),
    linear-gradient(135deg, rgba(52, 120, 246, 0.08), rgba(88, 198, 164, 0.08));
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  font-size: 10px;
  font-weight: 800;
  min-height: 24px;
  padding: 0 6px;
}

.top-strip {
  align-items: center;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: 18px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(260px, auto) minmax(0, 1fr) minmax(360px, auto);
  min-width: 0;
  padding: 8px 12px;
}

.stats-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.stat-chip {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: clamp(12px, 1vw, 15px);
  font-weight: 900;
  white-space: nowrap;
}

.stat-chip strong {
  color: var(--blue);
  font-size: clamp(20px, 1.8vw, 28px);
  line-height: 1;
}

#questionText {
  font-size: clamp(18px, 2.2vw, 34px);
  font-weight: 900;
  line-height: 1;
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: clip;
  justify-self: center;
  max-width: 100%;
  text-align: center;
  white-space: nowrap;
  width: 100%;
}

.top-controls {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.pad-control {
  display: grid;
  align-content: start;
  gap: 4px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: 14px;
  min-width: 108px;
  padding: 6px 10px;
}

.pad-control label {
  color: var(--ink);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.2;
}

.pad-control select {
  appearance: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(243, 246, 252, 0.98)),
    linear-gradient(135deg, rgba(52, 120, 246, 0.08), rgba(88, 198, 164, 0.08));
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  font-size: 10px;
  font-weight: 800;
  min-height: 24px;
  padding: 0 6px;
}

.playfield {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.25)),
    repeating-linear-gradient(90deg, rgba(52, 120, 246, 0.08) 0 1px, transparent 1px 64px);
  min-height: 100vh;
  overflow: hidden;
  position: relative;
  touch-action: none;
}

.overlay-top {
  left: 8px;
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 6;
  display: grid;
  gap: 8px;
}

.skyline {
  background:
    linear-gradient(90deg, rgba(88, 198, 164, 0.18), rgba(255, 200, 87, 0.2)),
    linear-gradient(180deg, transparent 0 55%, rgba(23, 33, 43, 0.05) 55% 100%);
  bottom: 0;
  height: 88px;
  left: 0;
  position: absolute;
  right: 0;
}

.message {
  align-items: center;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: none;
  flex-direction: column;
  gap: 8px;
  left: 50%;
  padding: 18px 22px;
  position: absolute;
  text-align: center;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(410px, calc(100% - 32px));
  z-index: 10;
}

.message.active {
  display: flex;
}

.message strong {
  font-size: 25px;
}

.message span {
  color: rgba(23, 33, 43, 0.72);
  font-weight: 700;
  line-height: 1.45;
}

.rice-cake {
  align-items: center;
  background:
    radial-gradient(circle at 26% 24%, rgba(255, 255, 255, 0.95) 0 12%, transparent 13%),
    radial-gradient(circle at 72% 68%, rgba(226, 205, 177, 0.18) 0 14%, transparent 15%),
    linear-gradient(180deg, #fffdf7 0%, #f7ead6 100%);
  border: 2px solid rgba(96, 62, 29, 0.2);
  border-radius: 999px;
  box-shadow:
    0 12px 22px rgba(23, 33, 43, 0.12),
    inset 0 -5px 10px rgba(150, 111, 73, 0.12),
    inset 0 4px 8px rgba(255, 255, 255, 0.72);
  display: flex;
  font-size: 18px;
  font-weight: 900;
  justify-content: center;
  line-height: 1.15;
  min-height: 52px;
  min-width: 88px;
  padding: 11px 20px 12px;
  position: absolute;
  text-align: center;
  transform: translate(-50%, -50%);
  user-select: none;
  white-space: nowrap;
}

.rice-cake::after {
  background: rgba(90, 58, 28, 0.12);
  border-radius: 50%;
  bottom: -8px;
  content: "";
  height: 8px;
  left: 14%;
  position: absolute;
  right: 14%;
  z-index: -1;
}

.rice-cake.correct {
  border-color: rgba(88, 198, 164, 0.58);
}

.rice-cake.wrong {
  background:
    radial-gradient(circle at 26% 24%, rgba(255, 255, 255, 0.95) 0 12%, transparent 13%),
    linear-gradient(180deg, #ffffff 0%, #f3f4f6 100%);
}

.rice-cake.hit {
  opacity: 0;
  transform: translate(-50%, -50%) scale(1.18);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.rice-cake.miss {
  background: #ffe0d7;
  border-color: rgba(240, 95, 87, 0.55);
}

.basket {
  height: 128px;
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  transform-origin: center;
  width: 128px;
  z-index: 4;
}

.basket.flapping-up img {
  animation: flap-up 0.16s ease-in-out infinite alternate;
}

.image-character img {
  display: block;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  transform-origin: center 58%;
  user-select: none;
  width: 100%;
}

.controls {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.66);
  align-items: center;
  border-radius: 16px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 160px)) minmax(220px, 1fr);
  left: 12px;
  padding: 10px 12px;
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 6;
}

.primary-btn,
.ghost-btn,
.icon-btn {
  min-height: 48px;
}

.primary-btn {
  background: var(--blue);
  color: #fff;
}

.ghost-btn {
  background: #fff;
  border: 1px solid var(--line);
}

.control-hint {
  color: rgba(23, 33, 43, 0.72);
  font-size: 14px;
  font-weight: 800;
  margin: 0;
  text-align: right;
}

.flash-good {
  animation: good 0.22s ease;
}

.flash-bad {
  animation: bad 0.22s ease;
}

@keyframes good {
  50% {
    box-shadow: 0 0 0 5px rgba(88, 198, 164, 0.3), var(--shadow);
  }
}

@keyframes bad {
  50% {
    box-shadow: 0 0 0 5px rgba(240, 95, 87, 0.3), var(--shadow);
  }
}

@keyframes flap-up {
  0% {
    transform: translateY(1px) rotate(-8deg) scaleX(0.98) scaleY(1.02);
  }

  100% {
    transform: translateY(-4px) rotate(8deg) scaleX(1.03) scaleY(0.97);
  }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .game-shell {
    min-height: calc(100vh - 20px);
  }

  .playfield {
    min-height: 100vh;
  }

  .top-strip {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px 10px;
  }

  .stats-inline {
    justify-content: space-between;
  }

  .stat-chip {
    font-size: 12px;
    justify-content: space-between;
  }

  #questionText {
    justify-self: stretch;
  }

  .top-controls {
    flex-direction: column;
  }

  .overlay-top {
    left: 8px;
    right: 8px;
    top: 8px;
  }

  .sound-control {
    max-width: none;
    padding: 8px 10px;
  }

  .pad-control {
    min-width: 0;
  }

  .sound-row {
    gap: 7px;
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .sound-toggle-row {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .sound-row label {
    font-size: 12px;
  }

  .rice-cake {
    font-size: 15px;
    max-width: min(230px, 70vw);
    min-height: 48px;
    padding: 10px 16px;
    white-space: normal;
  }

  .controls {
    grid-template-columns: 1fr 1fr;
    left: 8px;
    right: 8px;
    bottom: 8px;
  }

  #pauseButton {
    display: none;
  }

  .control-hint {
    grid-column: 1 / -1;
    text-align: center;
  }

  #questionText {
    font-size: clamp(28px, 7vw, 52px);
  }
}
