:root {
  --primary: #4a90e2;
  --navy: #1e3a8a;
  --pink: #ff4d8d;
  --yellow: #ffe878;
  --white: #ffffff;
  --muted: #667085;
  --splat-outline: #2d3748;
  --apple-red: #ef4f5f;
  --apple-green: #62b958;
  --apple-stem: #7a4b2a;
  --hotspot: #ff4d8d;
  --font-kids: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-width: 0; min-height: 100%; }
html { background: #cfe9ff; }
body {
  min-height: 100vh;
  color: var(--navy);
  background: linear-gradient(135deg, #bedbf5 0%, #dcecf9 55%, #f0f7fd 100%);
  font-family: var(--font-kids);
  line-height: 1.25;
  overflow-x: hidden;
}
button { color: inherit; font: inherit; }
button:focus-visible { outline: 4px solid #163f91; outline-offset: 3px; }
.screen { width: min(1440px, 100%); margin: 0 auto; padding: 24px; }

.home-head { margin: 4px 0 22px; text-align: center; }
.home-title { margin: 0; font-size: clamp(38px, 5vw, 68px); line-height: 1.05; }
.home-ja { margin-top: 8px; font-size: clamp(17px, 2vw, 25px); font-weight: 700; }
.home-hint { margin: 15px 0 0; font-size: clamp(16px, 1.7vw, 21px); }
.home-hint span { margin-left: .55em; color: var(--muted); }
.theme-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.list-actions { width: min(620px, 100%); margin: 28px auto 8px; text-align: center; }
.theme-tile {
  min-width: 0; min-height: 150px; padding: 14px; position: relative;
  border: 4px solid var(--yellow); border-radius: 24px;
  background: #fff; box-shadow: 0 9px 22px rgba(34, 76, 122, .15);
  cursor: pointer; display: grid; grid-template-columns: minmax(100px, 45%) 1fr;
  grid-template-rows: 1fr auto; align-items: center; gap: 8px 12px; text-align: left;
}
.theme-tile:hover { transform: translateY(-2px); }
.tile-visual { height: 125px; min-width: 0; }
.tile-copy { min-width: 0; }
.tile-zh { display: block; font-size: clamp(25px, 2.4vw, 35px); font-weight: 900; }
.tile-ja { display: block; margin-top: 3px; color: #384b78; font-size: clamp(14px, 1.3vw, 18px); font-weight: 700; overflow-wrap: anywhere; }
.tile-count { display: block; margin-top: 9px; color: var(--muted); font-size: 13px; }
.tile-actions { display: flex; min-width: 0; grid-column: 1 / -1; justify-content: center; gap: 10px; }
.tile-actions button { min-width: 96px; min-height: 44px; flex: 0 1 160px; padding: 4px 14px; border-radius: 999px; cursor: pointer; font-size: 15px; font-weight: 900; line-height: 1.05; white-space: nowrap; transition: transform 120ms ease-out; }
.tile-actions button:hover { transform: translateY(-2px); }
.tile-actions button small { display: block; margin-top: 1px; font-size: 10px; font-weight: 700; }
.tile-order { border: 2px solid var(--navy); background: #fff; color: var(--navy); }
.tile-shuffle { border: 2px solid var(--pink); background: #fff; color: var(--pink); }
.tile-shuffle:hover, .tile-shuffle:active { background: #fff0f5; }
.free-tag { position: absolute; z-index: 2; top: 9px; right: 9px; padding: 4px 10px; border-radius: 999px; background: #3a9b50; color: #fff; font-size: 13px; font-weight: 900; line-height: 1.05; text-align: center; }
.free-tag small, .tile-locked-label small { display: block; font-size: 9px; }
.theme-tile.is-locked .tile-visual, .theme-tile.is-locked .tile-copy { opacity: .55; }
.tile-locked-row { width: min(300px, 100%); min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 9px; padding: 6px 15px; border: 2px solid #9aa4b8; border-radius: 999px; background: #eef1f5; color: #6f7890; font-weight: 900; text-align: center; }
.tile-locked-row svg { width: 23px; height: 23px; flex: 0 0 auto; }
.lock-overlay { position: fixed; z-index: 1000; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(30, 58, 138, .5); }
.lock-card { width: min(520px, 100%); padding: clamp(24px, 5vw, 42px); border: 6px solid var(--yellow); border-radius: 26px; background: #fff; box-shadow: 0 16px 38px rgba(20, 40, 90, .28); text-align: center; }
.lock-message-ja { font-size: clamp(23px, 4vw, 34px); font-weight: 900; }
.lock-message-zh { margin: 8px 0 25px; color: #384b78; font-size: clamp(16px, 2.5vw, 21px); font-weight: 700; }
.lock-join, .lock-close { width: 100%; min-width: 0; }
.lock-close { min-height: 52px; margin-top: 16px; font-size: 17px; }

.cards-screen { height: 100vh; padding: 12px 24px 10px; display: flex; flex-direction: column; }
.topbar { min-height: 58px; display: grid; grid-template-columns: minmax(90px, 1fr) minmax(0, 2fr) minmax(70px, 1fr); align-items: center; gap: 10px; }
.home-button { justify-self: start; border: 0; background: rgba(255,255,255,.78); border-radius: 14px; padding: 6px 13px; cursor: pointer; font-size: 15px; font-weight: 900; }
.home-button small { display: block; font-size: 11px; }
.theme-heading { min-width: 0; text-align: center; }
.theme-title { min-width: 0; text-align: center; font-size: clamp(20px, 2.5vw, 32px); font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theme-title small { margin-left: .55em; font-size: .55em; }
.shuffled-tag { width: max-content; max-width: 100%; margin: 2px auto 0; padding: 2px 9px; border-radius: 999px; background: var(--pink); color: #fff; font-size: 12px; font-weight: 900; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shuffled-tag small { margin-left: .45em; font-size: .75em; }
.progress { justify-self: end; font-weight: 900; font-size: clamp(18px, 2vw, 26px); }
.question { margin: 1px 0 5px; text-align: center; font-size: clamp(22px, 3vw, 38px); font-weight: 900; }
.question small { margin-left: .55em; color: #384b78; font-size: .52em; }
.card-stage {
  flex: 1 1 auto; min-height: 0; width: min(920px, 100%); margin: 0 auto;
  padding: 10px; border: 6px solid var(--yellow); border-radius: 24px;
  background: linear-gradient(145deg, #fff0f5, #fff 30%, #fffae0);
  box-shadow: 0 12px 28px rgba(34,76,122,.18); cursor: pointer;
  display: flex; flex-direction: column;
}
.visual { flex: 1 1 auto; min-height: 100px; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 17px; background: #eef4fb; }
.answer { flex: 0 0 118px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; opacity: 0; transform: scale(.94); visibility: hidden; }
.answer.is-visible { animation: answer-in 220ms ease-out forwards; visibility: visible; }
@keyframes answer-in { to { opacity: 1; transform: scale(1); } }
.answer-main { display: flex; min-width: 0; align-items: center; justify-content: center; gap: 14px; }
.answer-zh { font-size: clamp(45px, 6.2vw, 82px); font-weight: 900; line-height: .96; }
.answer-play {
  min-width: 76px; min-height: 48px; padding: 5px 11px; border: 3px solid var(--pink); border-radius: 999px;
  background: #fff; color: var(--pink); cursor: pointer; font-weight: 900; line-height: 1.05;
  display: grid; grid-template-columns: 22px auto; grid-template-rows: auto auto; align-items: center; column-gap: 5px;
}
.answer-play svg { width: 22px; height: 22px; grid-row: 1 / 3; }
.answer-play-ja { font-size: 12px; white-space: nowrap; }
.answer-play-zh { font-size: 9px; white-space: nowrap; }
.answer-play.is-playing { background: var(--pink); color: #fff; }
.answer-py { margin-top: 4px; color: var(--pink); font-size: clamp(18px, 2vw, 26px); font-weight: 800; }
.answer-ja { color: #384b78; font-size: clamp(15px, 1.7vw, 21px); font-weight: 700; }
.controls { flex: 0 0 auto; width: min(620px, 100%); margin: 7px auto 0; text-align: center; }
.primary { min-height: 64px; min-width: min(430px, 100%); padding: 8px 30px; border: 0; border-radius: 999px; background: var(--pink); color: #fff; box-shadow: 0 5px 0 #bd3163; cursor: pointer; font-size: clamp(22px, 2.5vw, 31px); font-weight: 900; }
.primary small, .secondary small { display: block; font-size: .52em; }
.tap-hint { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.prev { margin-top: -17px; display: block; border: 0; background: none; color: #6f7890; cursor: pointer; font-size: 12px; }

.finish-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.finish-card { width: min(720px, 100%); padding: clamp(28px, 6vw, 70px); border: 6px solid var(--yellow); border-radius: 30px; background: #fff; box-shadow: 0 16px 38px rgba(34,76,122,.18); text-align: center; }
.finish-title { margin: 0; color: var(--pink); font-size: clamp(50px, 8vw, 92px); }
.finish-ja { margin-top: 5px; font-size: clamp(22px, 3vw, 34px); font-weight: 900; }
.praise { margin: 35px 0; }
.praise-zh { font-size: clamp(35px, 5vw, 58px); font-weight: 900; }
.praise-py { color: var(--pink); font-size: 24px; font-weight: 800; }
.praise-ja { font-size: 20px; }
.finish-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 16px; }
.secondary { min-height: 64px; padding: 8px 28px; border: 3px solid var(--primary); border-radius: 999px; background: #fff; cursor: pointer; font-size: 20px; font-weight: 900; }

.card-image, .hotspot-image { display: block; width: 100%; height: 100%; object-fit: contain; opacity: 0; }
.card-image.loaded, .hotspot-image.loaded { opacity: 1; }
.image-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #94a3b8; font-weight: 800; }
.placeholder-id { font-size: 14px; }
.color-art, .shape-art, .clock-art { width: 100%; height: 100%; max-width: 560px; }
.program-art { display: block; width: 100%; height: 100%; overflow: visible; }
.count-art { width: 100%; height: 100%; padding: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.count-row { display: flex; gap: 6px; justify-content: center; }
.count-item { position: relative; width: var(--count-item-size, 55px); height: var(--count-item-size, 55px); flex: 0 0 auto; }
.count-sprite, .count-fallback { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.count-sprite { opacity: 0; }
.count-sprite.loaded { opacity: 1; }
.ten-frame-art { display: grid; grid-template-columns: repeat(var(--ten-frame-columns, 1), max-content); grid-auto-rows: max-content; align-content: center; gap: var(--ten-frame-gap, 6px); }
.ten-frame { display: grid; grid-template-columns: repeat(5, var(--ten-cell-size, 25px)); grid-template-rows: repeat(2, var(--ten-cell-size, 25px)); gap: var(--ten-cell-gap, 2px); padding: var(--ten-frame-padding, 3px); border: var(--ten-frame-border, 2px) solid var(--navy); border-radius: 8px; }
.ten-frame-cell { position: relative; width: var(--ten-cell-size, 25px); height: var(--ten-cell-size, 25px); border-radius: 5px; background: rgba(74,144,226,.1); }
.ten-frame-cell .count-item { width: 100%; height: 100%; }
.hotspot-art { position: relative; width: 100%; height: 100%; }
.hotspot-overlay { position: absolute; pointer-events: none; }

@media (min-width: 760px) { .theme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 900px) { .theme-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .theme-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 600px) {
  .screen { padding: 14px; }
  .theme-grid { grid-template-columns: minmax(0, 1fr); gap: 11px; }
  .theme-tile { min-height: 210px; padding: 10px; grid-template-columns: 1fr; grid-template-rows: 92px auto auto; text-align: center; gap: 5px; }
  .tile-visual { height: 92px; grid-row: auto; }
  .tile-count { margin-top: 4px; }
  .tile-actions { width: 100%; gap: 8px; }
  .tile-actions button { min-width: 96px; flex: 1 1 45%; padding: 4px 10px; font-size: 14px; }
  .cards-screen { height: auto; min-height: 100vh; padding: 8px 10px 12px; }
  .topbar { min-height: 52px; grid-template-columns: max-content minmax(0, 1fr) max-content; }
  .home-button { white-space: nowrap; font-size: 13px; }
  .progress { white-space: nowrap; font-size: 16px; }
  .theme-title small { display: block; margin: 0; }
  .shuffled-tag { margin-top: 1px; padding: 1px 6px; font-size: 10px; }
  .question small { display: block; margin: 1px 0 0; }
  .card-stage { flex: none; height: min(570px, 67vh); padding: 7px; border-width: 4px; }
  .answer { flex-basis: 170px; }
  .answer-main { flex-direction: column; gap: 5px; }
  .answer-play { min-width: 88px; }
  .answer-py { margin-top: 2px; }
  .primary { width: 100%; min-width: 0; }
  .prev { margin-top: 3px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
