:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #173954;
  background: #f5f7fb;
  --card-face-gray: #f0f1f3;
  font-size: 18px;
  line-height: 1.5;
  font-synthesis: none;
}
*, *::before, *::after { box-sizing: border-box; }
html { min-height:100%; }
body { min-height:100vh; margin:0; }
button, input, select, textarea { font:inherit; }
button { cursor:pointer; }
button:focus-visible, a:focus-visible { outline:3px solid #dfad18; outline-offset:4px; }
a { color:inherit; text-underline-offset:3px; }
.page { display:flex; flex-direction:column; min-height:100vh; }
.header { background:#173954; color:#fff; }
.header-inner, .footer-inner { width:min(1200px,100%); margin:0 auto; padding:18px clamp(18px,4vw,40px); display:flex; gap:20px; align-items:center; flex-wrap:wrap; }
.brand, .tool-name { text-decoration:none; font-size:clamp(23px,2.8vw,30px); font-weight:750; letter-spacing:.01em; line-height:1.2; }
.brand img { display:block; width:auto; height:38px; max-width:100%; }
.divider { height:34px; width:2px; background:#ffffff70; }
.tool-name:hover, .footer a:hover { text-decoration:underline; }
.main { width:min(980px,100%); margin:0 auto; padding:clamp(24px,4vw,50px) clamp(16px,4vw,40px) 46px; flex:1; }
.game { max-width:730px; margin:0 auto; }
.eyebrow-row, .game-head, .progress-row, .toolbar { display:flex; justify-content:space-between; align-items:center; }
.eyebrow-row { margin-bottom:14px; min-height:35px; }
.stage-tag { display:inline-flex; align-items:center; gap:9px; padding:6px 13px; font-size:15px; font-weight:850; letter-spacing:.12em; color:#204967; background:#e4edf5; border-radius:999px; line-height:1.3; }
.stage-tag span { color:#89a0b3; }
.best-time { color:#687d91; font-size:13px; font-weight:760; letter-spacing:.1em; white-space:nowrap; }
.best-time strong { color:#173954; margin-left:5px; font-size:18px; letter-spacing:.02em; font-variant-numeric:tabular-nums; }
.game-head { gap:16px; align-items:flex-end; margin-bottom:20px; }
h1 { font-size:clamp(30px,4vw,46px); line-height:1.12; font-weight:850; letter-spacing:-.035em; margin:0 0 7px; }
.game-hint { font-size:clamp(15px,2vw,19px); margin:0; color:#60788d; line-height:1.35; }
.time-panel { display:flex; flex-direction:column; align-items:flex-end; flex-shrink:0; padding:2px 0 0; }
.time-label { font-size:12px; letter-spacing:.13em; font-weight:800; color:#8398aa; }
.timer { font-size:clamp(25px,4.6vw,38px); font-weight:830; line-height:1.18; letter-spacing:-.025em; font-variant-numeric:tabular-nums; white-space:nowrap; }
.progress-row { gap:17px; margin-bottom:13px; }
.progress-label { font-size:15px; font-weight:760; color:#41637f; white-space:nowrap; min-width:102px; }
.progress-track { height:8px; border-radius:99px; overflow:hidden; background:#dde8ef; flex:1; }
.progress-fill { display:block; height:100%; width:0%; background:#47b5a3; border-radius:inherit; transition:width .25s ease; }
.progress-row.sorting .progress-track { display:none; }
.progress-row.sorting { justify-content:flex-start; }
.board-shell { padding:clamp(7px,1.3vw,13px); background:#fff; border:1px solid #e0e8f0; border-radius:clamp(14px,2vw,22px); box-shadow:0 16px 40px rgba(23,57,84,.06); }
.board { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); gap:clamp(4px,1vw,9px); aspect-ratio:1; width:100%; user-select:none; -webkit-user-select:none; }
.card { border:0; position:relative; width:100%; min-width:0; min-height:0; padding:0; aspect-ratio:1; border-radius:clamp(7px,1.5vw,13px); background:transparent; perspective:800px; -webkit-tap-highlight-color:transparent; touch-action:manipulation; }
.card:disabled { cursor:default; opacity:1; }
.card-inner { display:block; position:absolute; inset:0; border-radius:inherit; transform-style:preserve-3d; transition:transform .28s cubic-bezier(.2,.68,.22,1); }
.card.revealed .card-inner, .card.matched .card-inner, .board.sorting .card-inner { transform:rotateY(180deg); }
.card-face { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; border-radius:inherit; overflow:hidden; backface-visibility:hidden; -webkit-backface-visibility:hidden; }
/* Some browsers paint the reverse-side question mark despite backface-visibility.
   Hide the reverse face explicitly whenever a card is face up. */
.card.revealed .card-back, .card.matched .card-back, .board.sorting .card-back { visibility:hidden; }
.card-back { background:linear-gradient(142deg,#24536e,#173954 78%); color:#ffde74; box-shadow:inset 0 0 0 1px #ffffff22; }
.card-back::before { content:""; position:absolute; inset:10%; border:1px solid #ffffff30; border-radius:inherit; }
.card-back::after { content:""; position:absolute; width:61%; aspect-ratio:1; border-radius:50%; border:2px dotted #84b1c1a1; }
.card-back-mark { z-index:1; font-size:clamp(20px,4vw,39px); font-weight:870; line-height:1; transform:translateY(-1px); }
.card-front { flex-direction:column; transform:rotateY(180deg); background:var(--card-face-gray); border:2px solid #dfe3e7; }
.card.matched .card-front { background:var(--card-face-gray); border-color:#b5dbd0; }
.board.sorting .card-front { background:var(--card-face-gray); border-color:#dfe3e7; }
.card-art { width:90%; height:90%; display:block; object-fit:contain; pointer-events:none; }
.card-number { position:absolute; right:5px; bottom:4px; min-width:23px; height:22px; padding:0 4px; display:grid; place-items:center; font-size:clamp(10px,1.7vw,17px); line-height:1; font-weight:850; font-variant-numeric:tabular-nums; color:#173954; border-radius:5px; background:#ffffffef; box-shadow:0 1px 4px #162f4c20; }
.board.sorting .card:not(:disabled):hover .card-front { border-color:#7ba9c0; }
.board.sorting .card.selected { z-index:2; }
.board.sorting .card.selected .card-front { background:var(--card-face-gray); border:3px solid #efa916; box-shadow:0 0 0 3px rgba(245,183,59,.24); }
.card:focus-visible { outline:3px solid #efa916; outline-offset:2px; z-index:3; }
.toolbar { gap:12px; padding:20px 1px 2px; }
.primary-action { min-height:53px; min-width:184px; border:2px solid #173954; border-radius:12px; background:#173954; color:#fff; padding:11px 22px; font-weight:760; font-size:18px; display:inline-flex; justify-content:center; gap:20px; align-items:center; transition:background .14s,transform .14s; }
.primary-action:hover { background:#24546f; }
.primary-action:active { transform:translateY(1px); }
.primary-action.secondary-mode { min-width:148px; background:#fff; color:#173954; }
.primary-action.secondary-mode:hover { background:#eaf0f6; }
.sound-action { min-height:49px; border:1px solid #d7e2eb; border-radius:12px; background:#fff; color:#43617a; padding:9px 13px; display:inline-flex; align-items:center; gap:9px; font-size:15px; font-weight:730; }
.sound-action:hover { background:#eef4f7; }
.sound-action .sound-off { display:none; }
.sound-action.muted .sound-wave { display:none; }
.sound-action.muted .sound-off { display:inline; }
.feedback { min-height:1.5em; margin:13px 0 0; font-size:15px; font-weight:700; color:#57768b; text-align:center; }
.footer { border-top:1px solid #dbe2e8; background:#fff; color:#35516a; font-size:18px; }
.footer-inner { justify-content:space-between; gap:12px 24px; }
.footer-links { display:flex; gap:12px 24px; flex-wrap:wrap; align-items:center; }
.footer a { font-weight:650; }
.footer-links span { color:#64788b; }
.game-dialog { width:min(430px,calc(100% - 28px)); padding:clamp(24px,4vw,36px); border:1px solid #dfe8ef; border-radius:22px; box-shadow:0 22px 80px #102a4380; text-align:center; color:#173954; }
.game-dialog::backdrop { background:#112e4580; backdrop-filter:blur(3px); }
.game-dialog h2 { font-size:30px; line-height:1.2; margin:0 0 9px; }
.game-dialog p { margin:0; color:#61798a; font-size:17px; }
.dialog-actions { display:flex; align-items:center; justify-content:center; gap:10px; margin-top:26px; flex-wrap:wrap; }
.dialog-actions button, .play-again { min-height:50px; border:2px solid #173954; border-radius:11px; padding:11px 18px; font-weight:750; }
.dialog-primary { background:#173954; color:#fff; }
.dialog-primary:hover { background:#23506b; }
.dialog-secondary { background:#fff; color:#173954; }
.dialog-secondary:hover { background:#f0f4f7; }
.finish-icon { display:grid; place-items:center; width:66px; height:66px; margin:0 auto 19px; background:#fff0b9; border-radius:20px; font-size:36px; color:#dc9a05; }
.completed-dialog .finish-caption { margin:0 0 24px; }
.finish-results { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:22px 0 17px; }
.finish-results div { background:#f2f6f9; border-radius:14px; padding:12px 8px; }
.finish-results span { display:block; font-size:12px; color:#647d91; font-weight:780; letter-spacing:.07em; }
.finish-results strong { font-size:clamp(23px,5vw,31px); font-variant-numeric:tabular-nums; }
.completed-dialog .new-record { color:#8a5d0d; font-weight:800; margin:0 0 14px; }
.play-again { width:100%; display:flex; align-items:center; justify-content:center; gap:16px; margin-top:8px; }
.close-finish { display:block; margin:11px auto 0; padding:8px 20px; border:0; background:transparent; font-size:15px; font-weight:700; color:#506b80; min-height:44px; }
.noscript { text-align:center; font-size:18px; margin:24px; }
.privacy-main { max-width:850px; padding-top:40px; padding-bottom:70px; }
.privacy-main h1 { margin:18px 0 24px; }
.privacy-main h2 { margin:34px 0 12px; font-size:clamp(24px,3vw,31px); }
.privacy-main p { margin:0 0 18px; font-size:18px; max-width:75ch; }
.privacy-main .back-link { font-weight:700; }
#analyticsManageWrap { margin:22px 0; }
#analyticsManageWrap[hidden] { display:none!important; }
#analyticsManage { border-radius:11px; border:2px solid #173954; background:#173954; color:#fff; padding:11px 18px; font-size:18px; font-weight:750; }
@media(max-width:620px) {
  .header-inner { gap:12px; }
  .brand,.tool-name { font-size:23px; }
  .divider { height:25px; }
  .footer-inner { align-items:flex-start; flex-direction:column; }
  .main { padding-top:23px; }
  .game-head { align-items:flex-start; }
  .game-hint { max-width:225px; }
  .card-number { right:2px; bottom:2px; min-width:17px; height:16px; border-radius:4px; padding:0 2px; }
  .card-front { border-width:1px; }
  .board.sorting .card.selected .card-front { border-width:2px; }
  .card-back::before { inset:8%; }
}
@media(max-width:400px) {
  .game-head { gap:7px; }
  h1 { font-size:28px; }
  .timer { font-size:25px; }
  .game-hint { font-size:14px; }
  .primary-action { min-width:140px; padding:10px 15px; gap:9px; }
  .sound-action { padding:9px 10px; }
  .toolbar { padding-top:16px; }
  .game-dialog { padding:23px 19px; }
}
@media(prefers-reduced-motion:reduce) { html { scroll-behavior:auto; } .card-inner,.progress-fill,.primary-action { transition:none; } .game-dialog::backdrop { backdrop-filter:none; } }
@media(max-width:360px) {
  .header-inner { gap:10px; }
  .brand img { height:31px; }
  .tool-name { font-size:21px; }
  .toolbar { gap:8px; }
  .primary-action { min-width:0; flex:1; white-space:nowrap; font-size:16px; padding:10px 10px; gap:6px; }
  .sound-action { flex-shrink:0; white-space:nowrap; padding:9px 8px; font-size:14px; gap:5px; }
  .sound-action svg { width:18px; height:18px; }
}
