:root {
  --surface: #f4f5fa;
  --white: #fff;
  --ink: #182039;
  --muted: #53607b;
  --stroke: #e0e4ee;
  --accent: #4147d5;
  --accent-text: #3d46bd;
  --soft: #e9ebff;
  --app-width: 520px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Noto Sans KR", "Malgun Gothic", sans-serif;
  color: var(--ink);
  background: var(--surface);
}

body { background:var(--surface); color:var(--ink); min-width:280px; font-size:16px; }
[hidden] { display:none!important; }
:where(button,input,select,summary):focus-visible { outline:2px solid #525be0; outline-offset:3px; }
button:disabled { opacity:.42; }
.sr-only { position:absolute!important; width:1px!important; height:1px!important; padding:0!important; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
#main:focus { outline:none; }

.shell {
  width:min(100%,var(--app-width)); min-height:100svh; margin:auto;
  padding:calc(12px + env(safe-area-inset-top)) 24px calc(104px + env(safe-area-inset-bottom)); background:var(--surface);
}
body:has(#appNav[hidden]) .shell { padding-bottom:calc(32px + env(safe-area-inset-bottom)); }
.app-topbar { display:flex; align-items:center; justify-content:space-between; margin:0 0 5px; }
.icon-button {
  display:grid; place-items:center; width:44px; height:44px; flex:none;
  padding:0; border:0; border-radius:12px; background:transparent; color:var(--muted);
}
.help-button { color:var(--muted); }
.back-button { margin-left:-6px; }
.section-header:has(>.help-button) { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:6px; }
.section-header:has(>button + .help-button) { grid-template-columns:minmax(0,1fr) auto auto; }
.board-stage { position:relative; }
.board-stage .help-button { position:absolute; top:1px; right:1px; }
.app-glyph,.app-glyph svg { display:block; width:1em; height:1em; flex:none; }
.app-glyph { font-size:22px; }

.main-nav.app-nav {
  position:fixed; z-index:20; bottom:0; left:50%; transform:translateX(-50%);
  width:min(100%,var(--app-width)); grid-template-columns:repeat(4,minmax(0,1fr)); gap:2px;
  margin:0; padding:7px 12px calc(8px + env(safe-area-inset-bottom)); border-radius:0;
  border-top:1px solid var(--stroke); background:#fffffffa;
}
.main-nav.app-nav .nav-btn {
  display:flex; flex-direction:column; justify-content:center; align-items:center;
  gap:4px; min-height:54px; padding:0; border-radius:0; background:transparent;
  color:var(--muted); box-shadow:none; font-size:12px; line-height:1.25; font-weight:650;
}
.main-nav.app-nav .nav-btn.active { color:var(--accent); font-weight:780; }
.app-nav .app-glyph { width:48px; height:29px; display:grid; place-items:center; font-size:20px; border-radius:9px; }
.app-nav .nav-btn.active .app-glyph { background:var(--soft); }
.app-nav .app-glyph svg { width:20px; height:20px; }

.home-screen { display:grid; gap:15px; }
.solo-card {
  min-width:0; padding:14px; border-radius:26px; color:var(--ink);
  background:#fff; border:1px solid var(--stroke);
}
.solo-overview {
  display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:16px 8px;
}
.board-stage {
  grid-column:1/-1; display:grid; place-items:center; padding:19px 0; border-radius:16px;
  background-color:#edeefe;
  background-image:radial-gradient(#cbd0ec 1px,transparent 1px); background-size:15px 15px;
}
.home-board {
  display:grid; grid-template:repeat(9,1fr)/repeat(9,1fr); width:clamp(145px,42vw,195px);
  aspect-ratio:1; background:#fff; border:1.5px solid #7b83ad; border-radius:5px;
  overflow:hidden; box-shadow:0 5px 12px #29335b14; font-size:clamp(10px,2.7vw,14px);
  font-weight:680; font-variant-numeric:tabular-nums; color:#32395b;
}
.home-board > span { display:grid; place-items:center; line-height:1; border-right:1px solid #e2e4f0; border-bottom:1px solid #e2e4f0; }
.home-board > span:nth-child(3n) { border-right-color:#a3a9c5; }
.home-board > span:nth-child(n+19):nth-child(-n+27),.home-board > span:nth-child(n+46):nth-child(-n+54) { border-bottom-color:#a3a9c5; }
.home-board > span:nth-child(9n) { border-right:0; }
.home-board > span:nth-child(n+73) { border-bottom:0; }
.board-peer { background:#edf0ff; }
.board-cursor { background:#cbd2ff; box-shadow:inset 0 0 0 1.5px var(--accent); }
.solo-intro { min-width:0; padding-left:2px; }
.solo-intro h1 { margin:0; font-size:clamp(24px,6vw,30px); letter-spacing:-.055em; line-height:1.2; }
.solo-intro p { margin:4px 0 0; color:var(--muted); font-size:13px; word-break:keep-all; }
.solo-stats { min-width:66px; display:grid; gap:6px; color:var(--muted); text-align:right; }
.solo-stats small { font-size:11px; font-variant-numeric:tabular-nums; }
.solo-track { height:3px; background:#e5e7f3; border-radius:4px; overflow:hidden; }
.solo-track span { display:block; height:100%; background:var(--accent); }
.solo-start {
  width:100%; min-height:48px; display:flex; justify-content:center; align-items:center; gap:6px;
  margin-top:15px; padding:9px 12px; border:0; border-radius:13px; background:var(--accent); color:white; font-weight:720; font-size:15px;
}
.solo-start .app-glyph { font-size:16px; }
.mode-list { display:grid; padding:0 14px; background:#fff; border:1px solid var(--stroke); border-radius:19px; }
.app-mode {
  display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; gap:12px;
  min-height:73px; padding:9px 2px; background:transparent; border:0; border-radius:0;
  color:var(--ink); text-align:left;
}
.app-mode+.app-mode { border-top:1px solid var(--stroke); }
.mode-symbol,.guide-orb,.world-orb,.resume-icon {
  display:grid; place-items:center; flex:none; width:41px; height:41px; border-radius:13px;
  background:var(--soft); color:var(--accent-text);
}
.mode-world .mode-symbol,.world-orb { background:#fff0e4; color:#9a4e22; }
.mode-copy { min-width:0; display:grid; grid-column:2; grid-row:1; gap:4px; }
.mode-copy strong { font-size:16px; font-weight:780; letter-spacing:-.037em; overflow-wrap:anywhere; }
.mode-copy small { color:var(--muted); font-size:12px; line-height:1.4; }
.mode-chevron { grid-column:3; grid-row:1; align-self:center; color:#7380a1; }
.mode-chevron .app-glyph { font-size:15px; }
.home-resume {
  display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; gap:11px;
  width:100%; padding:10px 13px; border:1px solid var(--stroke); border-radius:17px;
  background:#fff; color:var(--accent-text); text-align:left;
}
.home-resume .resume-icon { width:36px; height:36px; border-radius:11px; }
.home-resume .resume-icon .app-glyph { font-size:18px; }
.home-resume strong,.home-resume small { display:block; overflow-wrap:anywhere; }
.home-resume strong { font-size:14px; color:var(--ink); }
.home-resume small { margin-top:3px; font-size:12px; color:var(--muted); }

.panel { padding:0; background:transparent; border:0; border-radius:0; box-shadow:none; color:var(--ink); }
.panel-title,.puzzle-title,.pvp-match-heading h2 { color:var(--ink); font-size:27px; font-weight:780; letter-spacing:-.05em; }
.panel-subtitle,.puzzle-sub,.minititle,.foot-hint,.statusbar,.pvp-match-heading p { color:var(--muted); }
.panel-subtitle { font-size:13px; }
.primary,.secondary,.ghost,.danger { min-height:44px; border-radius:11px; font-size:14px; }
.primary,.filter.active { background:var(--accent); border-color:var(--accent); color:#fff; }
.primary:hover { background:var(--accent-text); }
.secondary { background:var(--soft); border-color:transparent; color:var(--accent); }
.ghost { background:var(--white); border-color:var(--stroke); color:var(--accent); }
.text-input,select.text-input { min-height:46px; background:var(--white); color:var(--ink); border-color:#d8deed; border-radius:10px; font-size:16px; }
.searchbar { background:var(--white); border-color:var(--stroke); }
.searchbar input { font-size:16px; color:var(--ink); }
.filter { border-color:var(--stroke); background:var(--white); color:var(--muted); font-weight:700; min-height:36px; }
.filter.active { font-weight:750; }
.card-grid { gap:7px; }
.number-card { background:var(--white); border-color:var(--stroke); border-radius:11px; min-height:62px; }
.number-card b { color:var(--ink); }
.number-card small { color:var(--muted); font-size:11px; }
.number-card.in-progress { background:#fff0dc; border-color:#eca34a; }
.number-card.in-progress b,.number-card.in-progress small { color:#884000; }
.number-card.in-progress.selected { box-shadow:inset 0 0 0 2px #cd7315; }
.number-card.selected { box-shadow:inset 0 0 0 1px #656fe0; }
.custom-card,.history-item,.empty { background:var(--white); border-color:var(--stroke); }
.custom-title,.history-item b { color:var(--ink); }

.play-panel .puzzle-top { margin-bottom:13px; }
.puzzle-title { min-width:0; overflow-wrap:anywhere; }
.play-panel .mode-tabs { margin:0 0 12px; }
.mode-tabs { border:1px solid var(--stroke); background:#e9edf6; box-shadow:none; border-radius:11px; }
.mode-btn { min-height:36px; box-shadow:none; color:var(--muted); }
.mode-btn.active,.mode-btn.time.active { box-shadow:none; background:var(--white); color:var(--accent); }
.chip { background:var(--soft); color:var(--accent); }
.statusbar { font-size:12px; }
.statusbar strong { color:var(--accent-text); }
.track { background:#e1e6f2; height:4px; margin-bottom:11px; }
.track>div { background:#6069e6; }
.board { border:2px solid #535e84; border-radius:7px; }
.cell { color:#393fc0; border-color:#dce1f0; }
.cell:nth-child(3n):not(:nth-child(9n)) { border-right-color:#8d96b5; }
.cell:nth-child(n+19):nth-child(-n+27),.cell:nth-child(n+46):nth-child(-n+54) { border-bottom-color:#8d96b5; }
.cell.given { color:#212a48; background:#eaedf5; }
.cell.peer:not(.given),.cell.pvp-peer:not(.given) { background:#eef0ff; }
.cell.same,.cell.given.same { background:#dce2ff; }
.cell.selected,.cell.given.selected,.cell.pvp-selected { background:#dde2fe; box-shadow:inset 0 0 0 2px #5d67d8; }
.cell.mistake.selected,.cell.pvp-wrong-entry.pvp-selected { background:#ffe4e8; }
.cell .notes-grid i { color:var(--accent-text); }
.cell.pvp-correct { color:#393fc0; }

.play-panel .keyboard,.pvp-numberpad { grid-template-columns:repeat(9,minmax(0,1fr)); gap:4px; }
.key,.pvp-numberpad .key { background:var(--white); border-color:var(--stroke); color:var(--accent); box-shadow:none; }
.play-panel .key,.pvp-numberpad .key { min-width:0; height:44px; padding:0; border-radius:8px; font-size:20px; }
.key:active,.key.note-selected { background:var(--soft); border-color:#b6c0f5; color:var(--accent); }
.tool { min-height:44px; border-radius:9px; border-color:var(--stroke); font-size:13px; color:var(--accent); }
.tool.active { background:var(--soft); color:var(--accent); border-color:#c7cff6; }
.play-tools,.play-options { display:grid; gap:6px; width:min(100%,495px); margin:11px auto 0; }
.play-tools { grid-template-columns:repeat(3,minmax(0,1fr)); }
.play-tools .tool { gap:7px; padding:4px; }
.play-tools .app-glyph,.play-options .app-glyph { font-size:17px; }
.play-tools .app-glyph svg,.play-options .app-glyph svg { width:1em; height:1em; }
.play-tools small { font-size:12px; color:var(--muted); }
.play-options { display:flex; justify-content:space-between; margin-top:6px; }
.play-options .tool { padding:5px 3px; border:0; background:transparent; color:var(--muted); }
.play-options .tool.active { background:transparent; color:var(--accent-text); }
.play-panel .hint-panel { margin-top:9px; }
.play-panel .hint-panel strong { font-size:14px; }
.attack-hud {
  padding:9px 11px; border:1px solid var(--stroke); border-radius:10px; background:var(--white);
}
.attack-timer { color:var(--ink); }
.attack-meta { color:var(--muted); font-size:11px; }
.attack-hearts svg { width:20px; height:20px; fill:#bc3e57; stroke:#bc3e57; }
.attack-hearts svg.empty { padding:0; border:0; border-radius:0; background:none; fill:none; stroke:#909ab2; }
.attack-start { background:var(--white); border-color:var(--stroke); color:var(--muted); }
.attack-finished { background:#fff7f8; border-color:#edd4da; }
.attack-start strong { color:var(--ink); }
.pvp-timer-card,.pvp-score,.multi-card { box-shadow:none; }
.duel-panel .pvp-timer-card,.duel-panel .pvp-score,.duel-panel .multi-card { background:var(--white); border-color:var(--stroke); }
.duel-panel .multi-card.mine,.duel-panel .pvp-score.me { background:var(--soft); border-color:#c3cdf9; box-shadow:none; }

dialog { color:var(--ink); border-color:var(--stroke); }
dialog::backdrop { background:#1820396b; }
#toast { bottom:calc(76px + env(safe-area-inset-bottom)); background:var(--accent); font-size:13px; }
body:has(#appNav[hidden]) #toast { bottom:calc(18px + env(safe-area-inset-bottom)); }
.app-splash {
  z-index:500; position:fixed; inset:0; display:grid; align-content:center; justify-items:center; gap:14px;
  background:var(--surface); color:var(--accent);
}
.app-splash img { border-radius:18px; }
.app-splash strong { font-size:22px; font-weight:780; letter-spacing:-.045em; }
.splash-loader { width:20px; height:20px; margin-top:6px; border-radius:50%; border:2px solid var(--stroke); border-top-color:var(--accent-text); animation:mate-spin .8s linear infinite; }
@keyframes mate-spin { to { transform:rotate(1turn); } }

.app-guide {
  position:fixed; inset:auto 0 max(12px,env(safe-area-inset-bottom)) 0; margin:0 auto;
  width:min(calc(100% - 24px),492px); max-height:min(85dvh,680px); padding:12px 22px 22px;
  border:0; border-radius:25px; box-shadow:0 8px 35px #1920422e;
  animation:guide-up .23s ease-out;
}
.app-guide::backdrop { background:#141a3c70; }
@keyframes guide-up { from { transform:translateY(18px); opacity:.5; } to { transform:translateY(0); opacity:1; } }
.guide-handle { width:34px; height:4px; margin:0 auto 16px; border-radius:99px; background:#d6daea; }
.guide-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.guide-skip { background:transparent; color:var(--muted); border:0; min-height:44px; font-weight:650; font-size:14px; }
.app-guide h2 { margin:12px 0 8px; font-size:24px; letter-spacing:-.045em; }
.app-guide p { margin:0; color:var(--muted); line-height:1.55; font-size:15px; }
.guide-progress { display:flex; gap:5px; margin:20px auto 14px; justify-content:center; }
.guide-progress i { height:5px; width:5px; background:#dbe0f0; border-radius:5px; }
.guide-progress .current { width:15px; background:var(--accent-text); }
.app-primary { min-height:46px; padding-inline:14px; font-weight:750; }
.guide-next { width:100%; }
.sudoku-guide .sudoku-guide-title,.sudoku-guide .sudoku-guide-caption,.sudoku-guide .sudoku-guide-key { color:var(--accent); }
.sudoku-guide .sudoku-guide-panel { background:var(--surface); border-color:var(--stroke); }
.sudoku-guide .sudoku-guide-key { border-color:#c6cff1; }
.sudoku-guide .sudoku-guide-play { background:var(--accent); box-shadow:none; }

.lobby-heading { margin:8px 0 17px; color:var(--ink); font-size:31px; line-height:1.15; font-weight:790; letter-spacing:-.05em; }
.friend-layout { display:grid; gap:12px; }
.lobby-card { min-width:0; padding:16px; border:1px solid var(--stroke); background:var(--white); border-radius:15px; }
.lobby-card h2 { font-size:17px; font-weight:750; letter-spacing:-.035em; margin:0 0 11px; }
.join-title { display:flex; flex-wrap:wrap; align-items:baseline; gap:0 8px; justify-content:space-between; }
.room-join-row { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; }
.room-code-input.text-input { background:var(--surface); font-size:21px; letter-spacing:.23em; font-weight:740; padding:8px 12px; font-variant-numeric:tabular-nums; }
.room-code-input::placeholder { color:#646d88; font-weight:550; }
.nearby-room { border-color:#929bec; }
.lobby-profile { margin-top:10px; }
.field-label,.room-code-label { color:var(--muted); font-size:14px; font-weight:700; }
.room-row { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:5px 0; border-top:1px solid #edf0f7; min-height:54px; font-size:15px; font-weight:680; }
.difficulty-field { position:relative; width:min(52%,130px); }
.difficulty-field::after { content:""; position:absolute; right:16px; top:17px; width:7px; height:7px; border:solid var(--muted); border-width:0 1.6px 1.6px 0; transform:rotate(45deg); pointer-events:none; }
.difficulty-field select { appearance:none; width:100%; min-height:44px; padding:0 32px 0 14px; border:1px solid var(--stroke); border-radius:12px; background:var(--surface); color:var(--ink); font:inherit; }
.difficulty-field select:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.invite-actions [data-action="pvp-share"] { display:inline-flex; gap:8px; align-items:center; justify-content:center; }
.invite-actions .app-glyph { width:18px; height:18px; }
.room-stepper { display:flex; gap:4px; align-items:center; }
.room-stepper output { min-width:32px; text-align:center; font-weight:770; font-variant-numeric:tabular-nums; }
.step-button { display:grid; place-items:center; height:44px; width:44px; border:1px solid var(--stroke); border-radius:10px; background:var(--surface); color:var(--accent); font-size:22px; line-height:1; }
.team-toggle { display:flex; padding:2px; gap:2px; border-radius:10px; background:#ebedf8; }
.team-toggle button { min-height:38px; border:0; border-radius:8px; padding:4px 8px; color:var(--muted); background:transparent; font-size:13px; font-weight:700; }
.team-toggle button[aria-pressed="true"] { color:var(--accent); background:var(--white); }
.room-note,.lobby-status { margin:6px 0 11px; color:var(--muted); font-size:14px; line-height:1.5; }
.room-advanced { margin:1px 0 11px; border-block:1px solid var(--stroke); }
.room-advanced summary { cursor:pointer; min-height:44px; padding:12px 2px; color:var(--accent-text); font-size:14px; font-weight:700; }
.room-times { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; padding-bottom:11px; }
.create-room>.app-primary,.waiting-room>.app-primary { width:100%; }
.waiting-room { text-align:center; }
.room-code { display:block; font-size:47px; font-weight:780; letter-spacing:.15em; padding-left:.15em; font-variant-numeric:tabular-nums; color:var(--accent); margin:2px 0 9px; }
.invite-actions { display:flex; justify-content:center; gap:8px; }
.room-roster { border-top:1px solid var(--stroke); margin-top:16px; padding-top:14px; text-align:left; }
.room-roster h2 { display:flex; justify-content:space-between; gap:12px; }
.room-roster h2 span { color:var(--muted); font-variant-numeric:tabular-nums; font-size:14px; }
.room-roster ul { padding:0; margin:0; list-style:none; display:grid; grid-template-columns:1fr 1fr; gap:7px; }
.room-roster li { padding:9px; display:flex; align-items:center; gap:6px; border-radius:8px; background:#eff1f8; color:var(--muted); font-size:13px; overflow-wrap:anywhere; }
.room-roster li.joined { color:var(--accent-text); background:var(--soft); }
.room-roster .app-glyph { font-size:17px; }
.queue-tag { color:var(--accent-text); font-size:13px; font-weight:700; }
.queue-tag.is-live::before,#nearbyBadge::before,.mode-copy .is-live::before { content:""; display:inline-block; width:6px; height:6px; margin:0 6px 2px 0; background:#2e836d; border-radius:50%; }
.world-room { display:grid; gap:10px; justify-items:center; text-align:center; padding:24px 16px; }
.world-orb { width:62px; height:62px; border-radius:17px; }
.world-orb .app-glyph { font-size:30px; }
.world-orb.is-searching { animation:search-pulse 1.6s ease-in-out infinite alternate; }
@keyframes search-pulse { from { box-shadow:0 0 0 0 #a9b6f4aa; } to { box-shadow:0 0 0 9px #a9b6f400; } }
.world-room h2,.world-room .room-note,.world-room .lobby-status { margin:0; }
.world-room .app-primary { width:min(100%,290px); margin-top:5px; }

.app-mode:active,.home-resume:active,.solo-start:active { opacity:.87; }
@media (hover:hover) {
  .app-mode:hover,.home-resume:hover,.icon-button:hover { background:#edf0fb; }
  .solo-start:hover { background:var(--accent-text); }
}
@media (min-width:610px) {
  body { background:#e8ebf5; }
  .shell,.main-nav.app-nav { border-inline:1px solid var(--stroke); }
  .shell { padding-inline:26px; }
}
@media (max-width:390px) {
  .shell { padding-inline:16px; }
  .solo-card { padding:15px; }


  .play-tools .tool,.play-options .tool { font-size:12px; }
  .play-tools .tool { gap:4px; }
  .play-panel .key,.pvp-numberpad .key { font-size:17px; }
}
@media (max-width:500px) {
  .app-guide { inset:auto 0 0; width:100%; border-radius:24px 24px 0 0; padding-bottom:calc(18px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion:reduce) {
  .app-guide,.splash-loader,.world-orb.is-searching { animation:none; }
}

.custom-header { display:grid; grid-template-columns:minmax(0,1fr) max-content; align-items:center; }
.custom-header .create-puzzle { display:inline-flex; align-items:center; justify-content:center; gap:5px; white-space:nowrap; padding-inline:12px; }
.create-puzzle .app-glyph { font-size:16px; }
.custom-list .empty { border:0; background:transparent; padding:45px 12px; color:var(--muted); }
.custom-list .empty>.app-glyph { display:grid; place-items:center; width:54px; height:54px; margin:0 auto 12px; border-radius:16px; background:var(--soft); color:var(--accent); }
.custom-list .empty svg { width:25px; height:25px; }
.custom-list .empty strong { color:var(--ink); margin-bottom:3px; }
.attack-metric-label { display:block; color:var(--muted); font-size:12px; }
.attack-hud .attack-timer { font-variant-numeric:tabular-nums; line-height:1.25; }
.rank-list,.pvp-outcome-detail { white-space:pre-line; line-height:1.65; }
.pvp-hearts svg.empty { padding:0; border:0; border-radius:0; background:none; }

@media(prefers-reduced-motion:no-preference) {
  :is(.app-primary,.solo-start,.app-mode,.key,.nav-btn,.tool,.number-card,.primary,.secondary,.ghost) {
    transition:transform 130ms ease-out, background-color 140ms ease-out,color 140ms ease-out;
  }
  :is(.app-primary,.solo-start,.app-mode,.key,.nav-btn,.tool,.number-card,.primary,.secondary,.ghost):enabled:active {
    transform:scale(.975);
  }
  .nav-btn .app-glyph { transition:background-color 180ms ease-out,color 180ms ease-out; }
  #appDialog[open] { animation:result-copy-in 190ms ease-out; }
}
@media(prefers-reduced-motion:reduce) {
  #gameOver, #pvpOutcome, #celebration, #gameOver *, #pvpOutcome *, #celebration *, #appDialog {
    animation:none!important; transition:none!important;
  }
}

/* Full-width illustrated scene, followed by the result and its actions. */
#gameOver, #pvpOutcome, #celebration {
  display:grid; grid-template:minmax(0,1fr)/minmax(0,1fr); place-items:center; padding:16px; background:rgba(22,27,53,.52);
}
#gameOver .gameover-card, #pvpOutcome .pvp-outcome-card, #celebration .celebration-card {
  --sky:#e4e7ff; --horizon:#b6c3eb; --orbit:#717fb5; --scene-ink:#364976;
  position:relative; width:min(100%,360px); max-height:100%; padding:0 20px 20px;
  overflow:auto; overscroll-behavior:contain; text-align:center; border:0; border-radius:26px;
  background:white; box-shadow:0 24px 55px #12183140,0 3px 10px #12183118;
}
#gameOver .gameover-card {
  --sky:#ffecdf; --horizon:#f4c3c4; --orbit:#b97986; --scene-ink:#913b57;
}
#pvpOutcome .pvp-outcome-card.win, #celebration .celebration-card {
  --sky:#fff0c9; --horizon:#f5cd88; --orbit:#b38548; --scene-ink:#805825;
}
#pvpOutcome .pvp-outcome-card.tie {
  --sky:#e0f3ef; --horizon:#a7d7d3; --orbit:#619996; --scene-ink:#356669;
}
.result-scene {
  position:relative; isolation:isolate; overflow:hidden; display:grid; place-items:center;
  height:clamp(94px,20vh,146px); margin:0 -20px 18px; color:var(--scene-ink);
  background:radial-gradient(ellipse at 47% 19%,#ffffffb5,transparent 57%),
    linear-gradient(137deg,var(--sky) 12%,var(--horizon));
}
.result-scene::before {
  content:""; position:absolute; inset:0; z-index:-1; opacity:.21;
  background-image:radial-gradient(var(--orbit) 1px,transparent 1px); background-size:11px 11px;
  mask-image:linear-gradient(120deg,black,transparent 55%,black);
}
.result-orbit {
  position:absolute; width:166px; height:92px; border:1px dashed var(--orbit);
  border-radius:50%; opacity:.4; transform:rotate(-18deg);
}
.result-art { position:relative; width:91px; height:91px; overflow:visible; filter:drop-shadow(0 5px 3px #3b385521); }
.result-art g { transform-box:fill-box; transform-origin:center; }
.heart-left { transform:translate(-3px,-1px) rotate(-7deg); }
.heart-right { transform:translate(4px,3px) rotate(9deg); }
.result-spark { position:absolute; width:10px; height:10px; background:var(--scene-ink); clip-path:polygon(50% 0,62% 37%,100% 50%,62% 63%,50% 100%,38% 63%,0 50%,38% 37%); }
.spark-one { left:26%; top:26%; }
.spark-two { right:24%; bottom:27%; width:8px; height:8px; }
.spark-three { right:32%; top:19%; width:5px; height:5px; }
#pvpOutcome :is(.finish-art,.win-art,.tie-art) { display:none; }
#pvpOutcome .lose .finish-art, #pvpOutcome .win .win-art, #pvpOutcome .tie .tie-art { display:inline; }
#gameOver h2, #pvpOutcome h2, #celebration h2 {
  margin:0 0 8px; color:var(--ink); font-size:clamp(22px,6vw,28px); letter-spacing:-.055em; line-height:1.25;
}
#gameOver p, #pvpOutcomeDetail, #victoryDesc { color:var(--muted); font-size:14px; margin:0 0 16px; line-height:1.6; overflow-wrap:anywhere; }
.result-time { display:inline-flex; align-items:center; gap:8px; margin:0 auto 9px; padding:3px 10px; background:#f5f4f8; border-radius:8px; font-size:12px; color:var(--muted); }
.result-time strong { font-size:14px; color:var(--ink); font-variant-numeric:tabular-nums; }
.gameover-actions, .pvp-outcome-actions { gap:7px; }
.gameover-actions button, .pvp-outcome-actions button, .celebration-card button { min-height:43px; border-radius:13px; }
#reviveAdBtn { background:var(--accent); color:#fff; border:0; box-shadow:none; }
.gameover-actions [data-action="time-retry"] { background:var(--soft); color:var(--accent-text); border:0; }
.gameover-actions .ghost { border:0; background:transparent; color:var(--muted); }

@keyframes result-arrive {
  from { opacity:0; transform:translateY(26px) scale(.925); }
  70% { transform:translateY(-3px) scale(1.008); }
  to { opacity:1; transform:none; }
}
@keyframes result-copy-in { from { opacity:0; transform:translateY(8px); } }
@keyframes result-orbit-in { from { opacity:0; transform:rotate(-48deg) scale(.7); } }
@keyframes result-spark-in { 0% { opacity:0; transform:scale(.2) rotate(-45deg); } 65% { transform:scale(1.4); } }
@keyframes heart-crack-left {
  0%,25% { transform:none; } 58% { transform:translate(-5px,-3px) rotate(-11deg); }
  100% { transform:translate(-3px,-1px) rotate(-7deg); }
}
@keyframes heart-crack-right {
  0%,25% { transform:none; } 55% { transform:translate(5px,-1px) rotate(6deg); }
  77% { transform:translate(5px,5px) rotate(12deg); }
  100% { transform:translate(4px,3px) rotate(9deg); }
}
@keyframes finish-plant { from { opacity:0; transform:translateY(-17px) rotate(-15deg); } 65% { transform:translateY(2px) rotate(3deg); } }
@keyframes finish-unfurl { from { transform:scaleX(.12) skewY(-12deg); } 65% { transform:scaleX(1.08) skewY(3deg); } }
@keyframes medal-land { from { opacity:0; transform:translateY(-17px) rotate(-22deg) scale(.72); } 70% { transform:rotate(5deg) scale(1.05); } }
@keyframes rings-meet { from { opacity:0; transform:translateX(var(--from)) rotate(-12deg); } }
@media(prefers-reduced-motion:no-preference) {
  #gameOver .gameover-card, #pvpOutcome .pvp-outcome-card, #celebration .celebration-card { animation:result-arrive .46s cubic-bezier(.2,.72,.28,1) both; }
  .result-orbit { animation:result-orbit-in .7s ease-out both; }
  .result-spark { animation:result-spark-in .42s .3s ease-out both; }
  .spark-two { animation-delay:.41s; }
  .spark-three { animation-delay:.48s; }
  .heart-left { animation:heart-crack-left .62s .08s ease-out both; }
  .heart-right { animation:heart-crack-right .62s .08s ease-out both; }
  .finish-flag { animation:finish-plant .48s .12s ease-out both; }
  .result-art .flag-cloth { transform-origin:left center; animation:finish-unfurl .58s .22s ease-out both; }
  .medal-face { animation:medal-land .65s .1s ease-out both; }
  .tie-first,.tie-second { animation:rings-meet .52s .1s ease-out both; }
  .tie-first { --from:-14px; } .tie-second { --from:14px; }
  .result-scene ~ h2, .result-time, #pvpOutcomeDetail, #victoryDesc { animation:result-copy-in .3s .12s ease-out both; }
  .gameover-actions,.pvp-outcome-actions,.celebration-card button { animation:result-copy-in .3s .18s ease-out both; }
}

body[data-app-view="catalog"] .filters {
  padding:4px; margin:13px 0 10px; gap:2px; border-radius:15px; background:#e8eaf3;
}
body[data-app-view="catalog"] .filter {
  flex:1 0 auto; padding:5px 9px; min-height:37px; border:0; border-radius:11px; background:transparent; color:var(--muted);
}
body[data-app-view="catalog"] .filter.active { background:#fff; color:var(--accent-text); box-shadow:0 1px 4px #272b5323; }
.catalog-completed { display:inline-flex; align-items:center; gap:4px; color:var(--accent-text); font-variant-numeric:tabular-nums; }
.catalog-completed .app-glyph { font-size:15px; }
.main-nav.app-nav { box-shadow:0 -4px 20px #292d5808; }
.app-nav .app-glyph { border-radius:16px; }
.app-nav .nav-btn.active .app-glyph { background:#e5e7ff; }
@media(prefers-reduced-motion:no-preference) {
  .app-nav .active .app-glyph svg { animation:tab-select .27s ease-out; }
  @keyframes tab-select { from { transform:translateY(2px) scale(.88); } 65% { transform:translateY(-1px) scale(1.06); } }
}

#gameOver .gameover-card { width:min(100%,340px); padding:22px; border-radius:24px; }
#gameOver .result-scene { width:78px; height:78px; margin:0 auto 14px; border-radius:50%; background:radial-gradient(circle at 38% 32%,#fff7f6,#fbe3e9); }
#gameOver .result-scene::before { content:none; }
#gameOver .result-art { width:60px; height:60px; filter:drop-shadow(0 2px 1px #902e451f); }
#gameOver h2 { font-size:23px; }
#gameOver .result-time { display:flex; justify-content:space-between; padding:11px 14px; margin:17px 0; background:var(--surface); border-radius:12px; }
#gameOver .result-time strong { letter-spacing:.035em; }
#gameOver .gameover-actions { gap:6px; }
#gameOver .gameover-actions button { min-height:44px; margin:0; }
.attack-start.attack-finished { display:grid; grid-template-columns:repeat(auto-fit,minmax(122px,1fr)); align-items:center; gap:6px; padding:14px; background:var(--surface); border:1px solid var(--stroke); border-radius:16px; }
.attack-start.attack-finished strong { grid-column:1/-1; font-size:15px; margin:0 0 3px; color:var(--ink); }
.attack-start.attack-finished button { margin:0; min-height:44px; }
[data-ad-slot][aria-busy="true"] { display:inline-flex; align-items:center; justify-content:center; gap:6px; opacity:.78; }
.ad-error { grid-column:1/-1; color:var(--muted); font-size:12px; line-height:1.45; }
.ad-spinner { display:block; box-sizing:border-box; width:14px; height:14px; margin:0; flex:0 0 14px; border:2px solid currentColor; border-right-color:transparent; border-radius:50%; }
@keyframes ad-wait { to { transform:rotate(360deg); } }
@keyframes result-settle {
 from { opacity:0; transform:translateY(12px) scale(.97); }
 to { opacity:1; transform:translateY(0) scale(1); }
}
@keyframes result-shade { from { background-color:transparent; } }
@media(prefers-reduced-motion:no-preference) {
 .ad-spinner { animation:ad-wait .85s linear infinite; }
 #gameOver { animation:result-shade .22s ease-out both; }
 #gameOver .gameover-card { animation:result-settle .30s cubic-bezier(.2,.75,.25,1) both; }
 .difficulty-field select,.step-button { transition:background-color .14s,border-color .14s; }
 .step-button:active:not(:disabled) { background:var(--soft); }
}

[data-history-list] > .history-more { margin-top:8px; }
