:root {
  --pink: #ff4d8d;
  --red: #ff5252;
  --orange: #ff9f1c;
  --yellow: #ffd23f;
  --green: #2ecc71;
  --blue: #3fa7ff;
  --purple: #a66cff;
  --ink: #3a2e5c;
  --white: #ffffff;
  font-family: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

body {
  color: var(--ink);
  background: linear-gradient(135deg, #ffd1e8, #ffe7a8, #b9f3ff, #d9c2ff, #ffd1e8);
  background-size: 400% 400%;
  animation: bg-move 16s ease infinite;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

body.fever {
  background: linear-gradient(90deg, #ff3b3b, #ff9f1c, #ffe53b, #3bff6f, #3bd8ff, #7a5cff, #ff3bd5, #ff3b3b);
  background-size: 400% 100%;
  animation: bg-move 1.6s linear infinite;
}

@keyframes bg-move {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}

/* ---------- 背景の ふわふわ ---------- */
#bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.bubble {
  position: absolute;
  bottom: -80px;
  opacity: 0.55;
  animation: float-up linear infinite;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.12));
}

@keyframes float-up {
  0% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-55vh) translateX(30px) rotate(180deg); }
  100% { transform: translateY(-115vh) rotate(360deg); }
}

body.fever .bubble {
  animation-duration: 3s !important;
  opacity: 0.9;
}

#fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

#flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  opacity: 0;
}

#flash.good {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.9), rgba(255, 240, 120, 0.4));
  animation: flash 0.35s ease-out;
}

#flash.bad {
  background: radial-gradient(circle, rgba(255, 80, 80, 0.15), rgba(255, 0, 0, 0.45));
  animation: flash 0.5s ease-out;
}

@keyframes flash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

#mute-btn {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: 12px;
  z-index: 70;
}

.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: rgba(255, 255, 255, 0.7);
  font-size: 22px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
}

main {
  position: relative;
  z-index: 10;
  height: 100%;
}

main.shake {
  animation: screen-shake 0.4s;
}

@keyframes screen-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-12px, 6px) rotate(-1deg); }
  40% { transform: translate(10px, -6px) rotate(1deg); }
  60% { transform: translate(-8px, 4px); }
  80% { transform: translate(6px, -2px); }
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.screen.active {
  display: flex;
  animation: screen-in 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes screen-in {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

/* ---------- タイトル ---------- */
#screen-title {
  justify-content: flex-start;
  overflow-y: auto;
}

.logo {
  margin: 8px 0 0;
  font-size: clamp(40px, 11vw, 84px);
  font-weight: 900;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.logo span {
  display: inline-block;
  color: var(--c);
  -webkit-text-stroke: 3px #fff;
  paint-order: stroke fill;
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.15);
  animation: letter-bounce 1.4s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.1s);
}

@keyframes letter-bounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-14px) rotate(-6deg); }
  50% { transform: translateY(0) rotate(0deg) scale(1.05, 0.95); }
}

.subtitle {
  margin: 4px 0 14px;
  font-weight: 800;
  font-size: clamp(16px, 4vw, 22px);
  color: #fff;
  text-shadow: 0 2px 0 var(--pink), 0 0 12px rgba(255, 77, 141, 0.6);
}

.panel {
  width: min(100%, 640px);
  background: rgba(255, 255, 255, 0.85);
  border: 5px solid #fff;
  border-radius: 32px;
  padding: 16px 20px 20px;
  box-shadow: 0 12px 0 rgba(58, 46, 92, 0.15), 0 20px 50px rgba(58, 46, 92, 0.2);
  backdrop-filter: blur(6px);
}

.panel h2 {
  margin: 10px 0 8px;
  font-size: 20px;
  font-weight: 900;
}

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

.choice {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 6px;
  border: 4px solid transparent;
  border-radius: 20px;
  background: var(--bgc);
  font-size: clamp(16px, 4.2vw, 22px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
  box-shadow: 0 6px 0 var(--sc);
  opacity: 0.55;
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.2, 1.6, 0.4, 1), opacity 0.2s;
}

.choice small {
  font-size: 11px;
  font-weight: 800;
  opacity: 0.95;
}

.choice-icon {
  font-size: 1.2em;
  line-height: 1.2;
}

.choice.selected {
  opacity: 1;
  transform: scale(1.04);
  border-color: #fff;
  box-shadow: 0 6px 0 var(--sc), 0 0 0 4px var(--bgc), 0 0 22px var(--bgc);
}

.choice.selected::after {
  content: "✔";
  position: absolute;
  top: -10px;
  right: -8px;
  width: 28px;
  height: 28px;
  line-height: 26px;
  border-radius: 50%;
  background: #fff;
  color: var(--bgc);
  font-size: 16px;
  text-shadow: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  animation: pop-in 0.3s cubic-bezier(0.2, 1.8, 0.4, 1);
}

.choice:active {
  transform: scale(0.92) translateY(4px);
  box-shadow: 0 2px 0 var(--sc);
}

.c-pink { --bgc: #ff5c9d; --sc: #c7346e; }
.c-blue { --bgc: #3fa7ff; --sc: #1f74c4; }
.c-purple { --bgc: #a66cff; --sc: #7442c9; }
.c-green { --bgc: #2ecc71; --sc: #1e9150; }
.c-orange { --bgc: #ff9f1c; --sc: #c67400; }
.c-red { --bgc: #ff5252; --sc: #c42f2f; }
.c-yellow { --bgc: #ffbf1f; --sc: #c48c00; }

.big-btn {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 16px;
  border: 4px solid #fff;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff4d8d, #ff9f1c, #ffd23f, #2ecc71, #3fa7ff, #a66cff, #ff4d8d);
  background-size: 300% 100%;
  animation: rainbow-slide 3s linear infinite, pulse 1.2s ease-in-out infinite;
  color: #fff;
  font-size: clamp(22px, 6vw, 30px);
  font-weight: 900;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
  box-shadow: 0 8px 0 #7442c9, 0 12px 30px rgba(166, 108, 255, 0.5);
}

.big-btn:active {
  transform: translateY(6px) !important;
  box-shadow: 0 2px 0 #7442c9;
}

.big-btn-sub {
  font-size: clamp(16px, 4.4vw, 22px);
  background: linear-gradient(90deg, #ff9f1c, #ff5252);
  animation: none;
  box-shadow: 0 8px 0 #c42f2f;
}

.big-btn-plain {
  font-size: clamp(16px, 4.4vw, 22px);
  background: #8f84b8;
  animation: none;
  box-shadow: 0 8px 0 #5d5287;
}

@keyframes rainbow-slide {
  from { background-position: 0% 50%; }
  to { background-position: 300% 50%; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.best-record {
  margin: 12px 0 0;
  text-align: center;
  font-weight: 800;
  min-height: 1.4em;
}

.learning-record,
.growth-record {
  padding: 10px 14px;
  border-radius: 16px;
  background: #f3efff;
  color: var(--ink);
  text-align: center;
  font-weight: 800;
}

.learning-record { margin-top: 18px; }
.growth-record { margin: 12px 0 0; }
.growth-record:empty { display: none; }

/* ---------- カウントダウン ---------- */
.countdown-num {
  font-size: min(45vw, 45vh);
  font-weight: 900;
  color: #fff;
  -webkit-text-stroke: 8px var(--pink);
  paint-order: stroke fill;
  text-shadow: 0 14px 0 rgba(0, 0, 0, 0.15);
  white-space: nowrap;
}

.countdown-num.go {
  font-size: min(24vw, 30vh);
  -webkit-text-stroke-color: var(--orange);
}

.countdown-num.zoom {
  animation: count-zoom 0.8s cubic-bezier(0.2, 1.6, 0.4, 1) forwards;
}

@keyframes count-zoom {
  0% { transform: scale(3) rotate(-30deg); opacity: 0; }
  40% { transform: scale(1) rotate(0deg); opacity: 1; }
  80% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(0.6); opacity: 0; }
}

/* ---------- ゲーム ---------- */
#screen-game {
  padding-left: 12px;
  padding-right: 12px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.game-wrap {
  width: 100%;
  max-width: 560px;
  height: 100%;
  display: grid;
  grid-template-areas: "hud" "card" "ans" "pad";
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 10px;
}

.hud { grid-area: hud; padding-right: 56px; }
.card-area { grid-area: card; }
.answer-area { grid-area: ans; }
.keypad { grid-area: pad; }

.hud-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 3px solid #fff;
  background: rgba(255, 255, 255, 0.8);
  font-weight: 900;
  font-size: 16px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.1);
  font-variant-numeric: tabular-nums;
}

.pill-score {
  background: linear-gradient(90deg, #ffe066, #ffbf1f);
}

.pill-score.bump {
  animation: bump 0.35s cubic-bezier(0.2, 1.8, 0.4, 1);
}

.pill-btn {
  margin-left: auto;
  background: #8f84b8;
  color: #fff;
}

.progress {
  position: relative;
  margin-top: 10px;
  height: 16px;
  border-radius: 999px;
  border: 3px solid #fff;
  background: rgba(255, 255, 255, 0.5);
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff4d8d, #ff9f1c, #ffd23f, #2ecc71, #3fa7ff, #a66cff);
  background-size: 200% 100%;
  animation: rainbow-slide 2s linear infinite;
  transition: width 0.4s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.progress-rocket {
  position: absolute;
  top: 50%;
  left: 0%;
  font-size: 26px;
  transform: translate(-50%, -55%) rotate(45deg);
  transition: left 0.4s cubic-bezier(0.2, 1.4, 0.4, 1);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25));
}

.combo {
  height: 30px;
  margin-top: 6px;
  text-align: center;
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  -webkit-text-stroke: 2px var(--orange);
  paint-order: stroke fill;
  opacity: 0;
  transition: opacity 0.2s;
}

.combo.show { opacity: 1; }

body.fever .combo::after {
  content: " フィーバー！";
}

.combo.bump {
  animation: bump 0.4s cubic-bezier(0.2, 1.8, 0.4, 1);
}

@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.5) rotate(-4deg); }
  100% { transform: scale(1); }
}

@keyframes pop-in {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

/* ---------- カード ---------- */
.card-area {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.card-stage {
  position: relative;
  width: min(100%, 460px, 52vh);
  aspect-ratio: 16 / 10;
  max-height: 100%;
  perspective: 1200px;
}

/* うしろに かさなる カードの たば */
.card-stage::before,
.card-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 24px;
  background: #fff;
  border: 3px solid #e8e1ff;
}

.card-stage::before { transform: translate(10px, 10px) rotate(3deg); opacity: 0.6; }
.card-stage::after { transform: translate(5px, 5px) rotate(1.5deg); opacity: 0.85; }

.card {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.card.flip .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 24px;
  background: #fff;
  border: 4px solid #fff;
  box-shadow: 0 10px 0 rgba(58, 46, 92, 0.15), 0 16px 30px rgba(58, 46, 92, 0.2);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

.card-front {
  background:
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(135deg, #ff4d8d, #ffd23f, #3fa7ff) border-box;
  border: 6px solid transparent;
}

.card-back {
  transform: rotateY(180deg);
  background: #fff8d6;
}

.hole {
  position: absolute;
  left: 18px;
  top: 50%;
  width: 22px;
  height: 22px;
  margin-top: -11px;
  border-radius: 50%;
  background: #e9e4f7;
  box-shadow: inset 0 3px 4px rgba(0, 0, 0, 0.2);
}

.card-back .hole {
  left: auto;
  right: 18px;
}

.q,
.a {
  font-size: min(15vw, 13vh, 110px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.q .sign {
  margin: 0 0.15em;
  color: var(--pink);
}

.q .sign.minus {
  color: var(--blue);
}

.card.correct .card-back {
  background: linear-gradient(135deg, #eaffea, #a8f0c6);
  color: #128a45;
  box-shadow: 0 0 0 6px #2ecc71, 0 0 50px #2ecc71;
}

.card.wrong .card-back {
  background: linear-gradient(135deg, #fff0f0, #ffc9c9);
  color: #e53935;
  box-shadow: 0 0 0 6px #ff5252, 0 0 40px #ff5252;
}

.card.correct .a {
  position: relative;
}

.card.correct .a::after {
  content: "";
  position: absolute;
  width: max(1.5em, calc(100% + 0.5em));
  aspect-ratio: 1;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 0.09em solid #e53935;
  border-radius: 50%;
  pointer-events: none;
}

.card.wrong .a::before {
  content: "こたえは ";
  font-size: 0.32em;
  vertical-align: middle;
}

.card.enter {
  animation: card-in 0.5s cubic-bezier(0.2, 1.5, 0.4, 1);
}

@keyframes card-in {
  from { transform: translateX(110%) rotate(25deg) scale(0.7); opacity: 0; }
  to { transform: translateX(0) rotate(0) scale(1); opacity: 1; }
}

.card.shake {
  animation: card-shake 0.45s;
}

@keyframes card-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-18px) rotate(-3deg); }
  30% { transform: translateX(16px) rotate(3deg); }
  45% { transform: translateX(-12px) rotate(-2deg); }
  60% { transform: translateX(8px) rotate(1deg); }
  75% { transform: translateX(-4px); }
}

.card.leave-good {
  animation: fly-up 0.55s cubic-bezier(0.5, -0.4, 0.8, 0.6) forwards;
}

@keyframes fly-up {
  to { transform: translateY(-120vh) rotate(-35deg) scale(0.5); opacity: 0.6; }
}

.card.leave-bad {
  animation: drop-down 0.55s cubic-bezier(0.5, -0.3, 0.8, 0.6) forwards;
}

@keyframes drop-down {
  to { transform: translate(-30vw, 120vh) rotate(-60deg); }
}

/* ---------- こたえ ---------- */
.answer-box {
  margin: 0 auto;
  width: min(100%, 260px);
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  border: 5px dashed var(--purple);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.1);
}

.answer-text {
  font-size: 52px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.answer-text.empty {
  color: #c9bfe8;
  animation: blink 1s steps(2) infinite;
}

.answer-text.pop {
  animation: bump 0.25s cubic-bezier(0.2, 1.8, 0.4, 1);
}

@keyframes blink {
  50% { opacity: 0.3; }
}

.answer-box.ok { border-style: solid; border-color: var(--green); background: #eaffea; }
.answer-box.ng { border-style: solid; border-color: var(--red); background: #fff0f0; }

/* ---------- キーパッド ---------- */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.key {
  height: min(64px, 8.5vh);
  min-height: 44px;
  border: 3px solid #fff;
  border-radius: 18px;
  background: var(--kc);
  color: #fff;
  font-size: min(34px, 5vh);
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
  box-shadow: 0 6px 0 var(--ks);
  transition: transform 0.06s, box-shadow 0.06s;
}

.key.pressed,
.key:active {
  transform: translateY(5px) scale(0.96);
  box-shadow: 0 1px 0 var(--ks);
  filter: brightness(1.15);
}

.key-wide { grid-column: span 2; }

.k1 { --kc: #ff5c9d; --ks: #c7346e; }
.k2 { --kc: #ff7a45; --ks: #c4501f; }
.k3 { --kc: #ffb81f; --ks: #c48600; }
.k4 { --kc: #8fd14f; --ks: #5c9b20; }
.k5 { --kc: #2ecc71; --ks: #1e9150; }
.k6 { --kc: #1fc8c8; --ks: #128f8f; }
.k7 { --kc: #3fa7ff; --ks: #1f74c4; }
.k8 { --kc: #6c7bff; --ks: #4250c4; }
.k9 { --kc: #a66cff; --ks: #7442c9; }
.k0 { --kc: #ff6fd8; --ks: #c43ea3; }
.key-clear { --kc: #9e9ab8; --ks: #6c6888; font-size: min(24px, 3.6vh); }

/* ---------- ポップアップ ---------- */
#popups {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
}

.popup {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: clamp(40px, 11vw, 88px);
  font-weight: 900;
  white-space: nowrap;
  color: #fff;
  -webkit-text-stroke: 6px var(--pc, var(--pink));
  paint-order: stroke fill;
  text-shadow: 0 8px 0 rgba(0, 0, 0, 0.15);
  animation: popup 1s cubic-bezier(0.2, 1.6, 0.4, 1) forwards;
}

.popup.bad { --pc: #6c7bff; font-size: clamp(32px, 8vw, 64px); }

@keyframes popup {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-20deg); opacity: 0; }
  25% { transform: translate(-50%, -50%) scale(1.15) rotate(5deg); opacity: 1; }
  60% { transform: translate(-50%, -60%) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translate(-50%, -110%) scale(0.9); opacity: 0; }
}

.banner {
  position: absolute;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%);
  padding: 10px 36px;
  font-size: clamp(36px, 10vw, 80px);
  font-weight: 900;
  white-space: nowrap;
  color: #fff;
  background: linear-gradient(90deg, #ff4d8d, #ff9f1c, #ffd23f, #2ecc71, #3fa7ff, #a66cff);
  background-size: 200% 100%;
  border: 6px solid #fff;
  border-radius: 24px;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
  box-shadow: 0 0 40px rgba(255, 255, 255, 0.9);
  animation: banner 1.6s cubic-bezier(0.2, 1.6, 0.4, 1) forwards, rainbow-slide 1s linear infinite;
}

@keyframes banner {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-200deg); opacity: 0; }
  25% { transform: translate(-50%, -50%) scale(1.2) rotate(-6deg); opacity: 1; }
  40% { transform: translate(-50%, -50%) scale(1) rotate(-6deg); }
  80% { transform: translate(-50%, -50%) scale(1) rotate(-6deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2) rotate(-6deg); opacity: 0; }
}

#fever-ribbon {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  padding: 6px 0;
  text-align: center;
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  background: rgba(255, 0, 90, 0.75);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
  transform: translateY(110%);
  transition: transform 0.3s;
  pointer-events: none;
}

body.fever #fever-ribbon {
  display: none;
}

@keyframes ribbon-glow {
  from { background: rgba(255, 0, 90, 0.8); }
  to { background: rgba(255, 140, 0, 0.8); }
}

/* ---------- けっか ---------- */
#screen-result {
  justify-content: flex-start;
  overflow-y: auto;
}

.result-panel {
  margin: auto 0;
  text-align: center;
}

.result-title {
  font-size: clamp(26px, 7vw, 40px) !important;
  margin: 4px 0 !important;
}

.result-stars {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.rstar {
  font-size: clamp(56px, 16vw, 96px);
  line-height: 1.1;
  color: #e3dcf5;
  -webkit-text-stroke: 3px #fff;
  paint-order: stroke fill;
  transition: color 0.2s;
}

.rstar:nth-child(2) {
  transform: translateY(-14px);
}

.rstar.on {
  color: #ffd23f;
  -webkit-text-stroke-color: #ff9f1c;
  filter: drop-shadow(0 0 14px #ffd23f);
  animation: star-on 0.6s cubic-bezier(0.2, 1.8, 0.4, 1);
}

.rstar.on:nth-child(2) {
  animation-name: star-on-mid;
}

@keyframes star-on {
  0% { transform: scale(3) rotate(-180deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes star-on-mid {
  0% { transform: translateY(-14px) scale(3) rotate(-180deg); opacity: 0; }
  100% { transform: translateY(-14px) scale(1) rotate(0deg); opacity: 1; }
}

.new-record {
  display: none;
  margin: 4px auto;
  width: fit-content;
  padding: 4px 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffd23f, #ff9f1c);
  color: #fff;
  font-size: 22px;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
  animation: pulse 0.8s ease-in-out infinite;
}

.new-record.show { display: block; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.stat {
  display: flex;
  flex-direction: column;
  padding: 8px 4px;
  border-radius: 16px;
  background: #f3efff;
}

.stat-big {
  grid-column: 1 / -1;
  background: linear-gradient(90deg, #fff3c4, #ffe08a);
}

.stat-label {
  font-size: 13px;
  font-weight: 800;
  opacity: 0.8;
}

.stat-value {
  font-size: 26px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.stat-value small {
  font-size: 0.5em;
}

.stat-big .stat-value {
  font-size: 44px;
  color: #e5731a;
}

.mistakes {
  margin-top: 10px;
}

.mistakes h3 {
  margin: 4px 0 6px;
  font-size: 16px;
}

.mistake-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.mistake {
  padding: 4px 12px;
  border-radius: 12px;
  background: #fff0f0;
  border: 2px solid #ffc9c9;
  font-weight: 800;
}

.mistake s {
  color: #e53935;
  font-size: 0.85em;
}

.result-buttons .big-btn {
  margin-top: 14px;
}

/* ---------- ひろい がめん ---------- */
@media (min-width: 900px) and (min-aspect-ratio: 4/3) {
  .game-wrap {
    max-width: 1100px;
    grid-template-columns: 1.3fr 1fr;
    grid-template-rows: auto minmax(0, 1fr) minmax(0, 0.7fr);
    grid-template-areas:
      "hud hud"
      "card pad"
      "ans pad";
    column-gap: 32px;
  }

  .card-area {
    align-items: flex-end;
  }

  .answer-area {
    align-self: start;
    padding-bottom: 8vh;
  }

  .keypad {
    grid-row: 2 / 4;
    align-self: center;
  }

  .key {
    height: min(90px, 13vh);
    font-size: 40px;
  }

  .card-stage {
    width: min(100%, 560px, 60vh);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bubble,
  .logo span,
  body,
  body.fever,
  .big-btn,
  .progress-fill {
    animation: none;
  }
}

/* せまい がめんでも カードと キーを かさねない */
@media (max-height: 600px) {
  .game-wrap { gap: 6px; }
  .hud { padding-right: 50px; }
  .hud-row { gap: 4px; }
  .pill { padding: 3px 7px; font-size: 13px; }
  .progress { margin-top: 6px; }
  .combo { height: 22px; margin-top: 2px; font-size: 17px; }
  .answer-box { height: 52px; }
  .answer-text { font-size: 38px; }
  .keypad { gap: 5px; }
  .key { height: 44px; font-size: 25px; }
}

@media (max-height: 600px) and (orientation: landscape) {
  .game-wrap {
    max-width: 1000px;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "hud hud" "card pad" "ans pad";
    column-gap: 16px;
  }
  .keypad { align-self: stretch; grid-template-rows: repeat(4, minmax(0, 1fr)); }
  .key { height: auto; min-height: 0; }
  .card-stage { height: 100%; width: auto; max-width: 100%; }
  .answer-area { padding-bottom: 2px; }
}

@media (max-width: 480px) {
  .pill {
    padding: 4px 9px;
    font-size: 14px;
  }

  .stat-value {
    font-size: 22px;
  }
}
