/* FunWonder shared game page shell (Wave 1, pairs with fw-theme.css) */
.game-head{padding:16px 0 12px}
.game-head .crumbs{display:flex;gap:8px;align-items:center;font-size:13px;color:var(--fw-text-muted);margin-bottom:10px}
.game-head .crumbs a{color:var(--fw-text-secondary);text-decoration:none}
.game-head .crumbs a:hover{color:var(--fw-text)}
.game-title-row{display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap}
.game-title-row h1{font-size:26px;font-weight:800;letter-spacing:-.02em;margin:0;color:var(--fw-text)}
.game-actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.game-stage {
  position: relative;
  min-height: clamp(500px, calc(100dvh - 168px), 780px);
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--fw-surface);
  border: 1px solid var(--fw-border);
  border-radius: 18px;
  box-shadow: var(--fw-shadow);
  overflow: hidden;
  margin-bottom: 28px;
}
#game-root{display:flex;flex-direction:column;flex:1;min-height:0}
.board-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 24px 20px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background-color: #F4F2EC;
  background-image: none;
}
.stage-simon-says .board-wrap{gap:20px}
[data-theme="dark"] .board-wrap {
  background-color: #12151C;
  border: 0;
  box-shadow: none;
}
.board-wrap>*{box-shadow:0 10px 28px rgba(0,0,0,.14),0 2px 6px rgba(0,0,0,.08)}
.board-wrap>.ss-status,.board-wrap>.su-controls,.board-wrap>.su-pad,.board-wrap>.su-msg,
.board-wrap>.wg-kb,.board-wrap>.wg-msg,.board-wrap>.at-msg,.board-wrap>.tt-input,
.board-wrap>.tt-msg,.board-wrap>.tt-inner,.board-wrap>.sh-tray,.board-wrap>.sh-stash-row{box-shadow:none}
@media (max-width: 900px) {
  .board-wrap {
    align-items: safe center;
    overflow-x: auto;
    overflow-y: hidden;
  }
}
.board-wrap>*{margin:0;flex-shrink:0}
.game-hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  margin: 0;
  background: var(--fw-surface);
  border-bottom: 1px solid var(--fw-border);
  font-family: "JetBrains Mono","JetBrains Mono Fallback",ui-monospace, monospace;
}
.hud-play{display:flex;align-items:center;gap:8px;justify-content:flex-start;flex-wrap:wrap;justify-self:start}
.hud-stats{display:flex;align-items:center;gap:8px;justify-content:center;flex-wrap:wrap;justify-self:center}
.hud-tools{display:flex;align-items:center;gap:8px;justify-content:flex-end;justify-self:end}
.hud-tool{width:36px;height:36px;flex:0 0 auto;box-sizing:border-box;border-radius:50%;border:1px solid var(--fw-border);background:var(--fw-surface);box-shadow:none;
  color:var(--fw-text-secondary);font-size:16px;font-weight:700;cursor:pointer;line-height:1;display:inline-flex;align-items:center;justify-content:center;padding:0}
.hud-tools>button{box-shadow:none}
.hud-tools #lbToggle{width:36px;height:36px;flex:0 0 auto;box-sizing:border-box;padding:0;box-shadow:none}
.hud-tool:hover{color:var(--fw-text);border-color:var(--fw-border-strong)}
.hud-tool svg{display:block}
.hud-flag{width:auto;border-radius:999px;padding:0 14px;display:inline-flex;align-items:center;gap:6px;font-size:13.5px;font-weight:700;color:var(--fw-text-secondary);filter:none;opacity:1}
.hud-flag.active{background:var(--fw-retro);border-color:var(--fw-retro);color:#fff;box-shadow:0 0 0 2px var(--fw-retro-soft)}
[data-theme="dark"] .hud-flag.active{color:#0F1115}
.hud-pill{width:auto;border-radius:999px;padding:0 14px;display:inline-flex;align-items:center;gap:6px;font-size:13.5px;font-weight:700}
#fw-help-popover{position:absolute;top:66px;right:16px;z-index:30;width:min(340px,calc(100% - 32px));
  background:var(--fw-surface);border:1px solid var(--fw-border);border-radius:14px;box-shadow:var(--fw-shadow);
  padding:16px 18px;text-align:left}
#fw-help-popover[hidden]{display:none}
#fw-help-popover h3{font-size:15px;font-weight:800;color:var(--fw-text);margin:0 0 10px}
#fw-help-popover h4{font-size:11px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:var(--fw-text-muted);margin:12px 0 5px}
#fw-help-popover ul{margin:0;padding-left:17px}
#fw-help-popover li{font-size:13.5px;line-height:1.55;color:var(--fw-text-secondary)}
.hint-flash{outline:3px solid #F59E0B!important;outline-offset:2px}
.hud-stat{background:var(--fw-bg-subtle);border:1px solid var(--fw-border);border-radius:10px;
  padding:6px 14px;font-size:15px;font-weight:700;color:var(--fw-text);font-variant-numeric:tabular-nums;min-width:92px;text-align:center}
.hud-stat .lbl{display:block;font-size:10.5px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--fw-text-muted)}
.hud-reset{width:36px;height:36px;flex:0 0 auto;box-sizing:border-box;box-shadow:none;border-radius:50%;border:1px solid var(--fw-border);background:var(--fw-surface);
  color:var(--fw-text-secondary);font-size:18px;cursor:pointer;line-height:1;display:inline-flex;align-items:center;justify-content:center;padding:0}
.hud-reset:hover{color:var(--fw-text);border-color:var(--fw-border-strong)}
.diff-pills{display:flex;gap:4px;background:var(--fw-bg-subtle);border:1px solid var(--fw-border);border-radius:999px;padding:3px}
.diff-pills button{border:none;background:transparent;color:var(--fw-text-secondary);font:inherit;font-size:13.5px;
  font-weight:600;padding:6px 14px;border-radius:999px;cursor:pointer}
.diff-pills button.active{background:var(--fw-surface);color:var(--fw-text);box-shadow:0 1px 4px rgba(0,0,0,.12)}
.new-game-btn{border:1px solid var(--fw-border);background:var(--fw-surface);color:var(--fw-text);
  font:inherit;font-size:13.5px;font-weight:700;padding:8px 16px;border-radius:999px;cursor:pointer}
.new-game-btn:hover{border-color:var(--fw-border-strong)}
@media (max-width:640px){
  .topbar-in{gap:10px}
  .topbar .fw-brand-svg{height:26px}
  .top-actions{gap:6px}
  .game-title-row h1{font-size:22px}
  .hud-stat{min-width:60px;padding:5px 8px;font-size:13.5px}
  .game-hud{gap:6px}
  .hud-play{gap:5px}
  .hud-stats{gap:5px}
  .hud-tools{gap:5px}
  .hud-tool{width:32px;height:32px}
}
/* Card games (Wave 2): green table, HUD buttons, auto-complete */
.board-wrap:has(>.card-table){padding:0;background:#156B47}
[data-theme="dark"] .board-wrap:has(>.card-table){background:#0E3B29}
.card-table{flex:1;width:100%;align-self:stretch;margin:0;display:flex;flex-direction:column;justify-content:center;background:#156B47;border-radius:0;padding:20px;box-shadow:none}
[data-theme="dark"] .card-table{background:#0E3B29}
.hud-btn{border:1px solid var(--fw-border);background:var(--fw-surface);color:var(--fw-text);
  font:inherit;font-size:13.5px;font-weight:700;padding:9px 16px;border-radius:999px;cursor:pointer;display:inline-flex;align-items:center;gap:6px}
.hud-btn svg{display:block;flex:0 0 auto}
.hud-btn:hover{border-color:var(--fw-border-strong)}
.hud-btn:disabled{opacity:.45;cursor:default}
.hud-btn.primary{background:var(--fw-retro);border-color:var(--fw-retro);color:#fff}
[data-theme="dark"] .hud-btn.primary{color:#0F1115}
.auto-complete-wrap{display:flex;justify-content:center;margin-bottom:12px}
.auto-complete-btn{border:none;background:var(--fw-amber);color:#18181B;font:inherit;font-size:14.5px;
  font-weight:800;padding:10px 26px;border-radius:999px;cursor:pointer;box-shadow:0 4px 14px rgba(245,158,11,.45)}
.auto-complete-btn:hover{filter:brightness(1.06)}
.guide details{background:var(--fw-surface);border:1px solid var(--fw-border);border-radius:14px;
  padding:16px 20px;margin-bottom:10px}
.guide summary{font-weight:700;font-size:15px;cursor:pointer;color:var(--fw-text)}
.guide details p{margin-top:9px;font-size:14.5px;line-height:1.65;color:var(--fw-text-secondary)}
@media (max-width:640px){
  .card-table{padding:10px;border-radius:0}
  .hud-btn{padding:8px 12px;font-size:13px}
}
@media (max-width:640px){
  .hud-stats{flex-wrap:nowrap}
  .hud-stat{min-width:54px}
}
.hud-sep{width:1px;height:22px;background:var(--fw-border-strong);margin:0 2px;flex:0 0 auto}
/* Card fly + drop feedback (freecell/solitaire) */
.fw-fly-card{position:fixed;z-index:1000;pointer-events:none;opacity:1;box-shadow:0 14px 28px rgba(0,0,0,0.32)}
.drop-target{cursor:pointer;transition:box-shadow .15s ease,transform .15s ease}
.drop-target:hover{box-shadow:0 0 0 2.5px #FBBF24,0 0 18px rgba(251,191,36,.55)!important;filter:brightness(1.04)}
body.is-dragging,body.is-dragging *{cursor:grabbing!important}
/* Game area: no double-tap zoom / text selection / callout while playing */
.game-stage,#game-root{touch-action:manipulation;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent}
.game-stage input,.game-stage textarea{user-select:text;-webkit-user-select:text;touch-action:auto;font-variant-ligatures:none;font-feature-settings:"liga" 0,"calt" 0}

/* HUD: play left / stats center / tools right; wrap-centered on small screens */
.game-hud{grid-template-columns:1fr auto 1fr}
@media (max-width:720px){
  .game-hud{display:flex;flex-wrap:wrap;justify-content:center;row-gap:8px}
  .hud-play,.hud-stats,.hud-tools{justify-content:center}
}

/* Shared result card (fwShowResult) */
.fw-result-backdrop{position:fixed;inset:0;z-index:900;display:flex;align-items:center;justify-content:center;padding:20px;background:rgba(250,249,246,.72);backdrop-filter:blur(6px);animation:fw-backdrop-in .28s ease-out}
body.fw-modal-open{overflow:hidden}
#confetti{z-index:899!important}
@keyframes fw-backdrop-in{from{opacity:0}to{opacity:1}}
[data-theme="dark"] .fw-result-backdrop{background:rgba(15,17,21,.74)}
.fw-result-card{position:relative;width:100%;max-width:390px;background:var(--fw-surface);border:1px solid var(--fw-border);border-radius:20px;padding:28px 24px 24px;text-align:center;box-shadow:0 24px 54px rgba(0,0,0,.16);animation:fw-pop-in .28s cubic-bezier(.22,1,.36,1)}
.fw-result-card:focus{outline:none}
@keyframes fw-pop-in{from{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:none}}
.fw-result-badge{width:56px;height:56px;border-radius:50%;margin:0 auto 14px;display:flex;align-items:center;justify-content:center;background:var(--fw-retro-soft);color:var(--fw-retro)}
.fw-result-badge.lose{background:rgba(220,38,38,.1);color:#DC2626}
.fw-result-title{font-size:24px;font-weight:800;letter-spacing:-.02em;color:var(--fw-text)}
.fw-result-sub{margin-top:6px;font-size:14px;line-height:1.55;color:var(--fw-text-secondary)}
.fw-result-newbest{display:inline-block;margin-top:12px;padding:4px 12px;border-radius:999px;background:rgba(245,158,11,.15);color:#D97706;font-size:12px;font-weight:800;letter-spacing:.08em}
.fw-result-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:18px 0 22px}
.fw-result-stat{background:var(--fw-bg-subtle);border-radius:12px;padding:12px 6px}
.fw-result-stat .lbl{display:block;font-size:11px;color:var(--fw-text-muted);margin-bottom:4px}
.fw-result-stat .val{font-family:"JetBrains Mono","JetBrains Mono Fallback",ui-monospace,monospace;font-size:18px;font-weight:700;color:var(--fw-text)}
.fw-result-actions{display:flex;gap:10px;justify-content:center;flex-wrap:wrap}
.fw-result-actions button{font:inherit;font-size:15px;font-weight:700;padding:12px 24px;border-radius:999px;cursor:pointer}
.fw-result-primary{border:1px solid var(--fw-retro);background:var(--fw-retro);color:#fff}
[data-theme="dark"] .fw-result-primary{color:#0F1115}
.fw-result-secondary{border:1px solid var(--fw-border);background:var(--fw-surface);color:var(--fw-text)}
.fw-result-share-row{display:flex;gap:8px;justify-content:center;margin-top:14px;flex-wrap:wrap}
.fw-result-card .fw-result-share,.fw-result-card .fw-result-share-img{background:transparent;border:1px solid var(--fw-border);box-shadow:none;padding:7px 14px;border-radius:999px;color:var(--fw-text-secondary);font:inherit;font-size:13px;font-weight:600;cursor:pointer;white-space:nowrap}
.fw-result-card .fw-result-share:hover,.fw-result-card .fw-result-share-img:hover{background:var(--fw-bg-subtle);color:var(--fw-text)}
.fw-confetti{position:absolute;top:10px;left:50%;width:8px;height:8px;border-radius:2px;pointer-events:none;animation:fw-confetti-fall .7s ease-out forwards}
@keyframes fw-confetti-fall{0%{opacity:1;transform:translate(0,0) rotate(0)}100%{opacity:0;transform:translate(var(--dx),90px) rotate(var(--rot))}}
.fw-result-close{position:absolute;top:10px;right:12px;width:32px;height:32px;border:none;background:transparent;color:var(--fw-text-muted);font-size:22px;line-height:1;cursor:pointer;border-radius:50%}
.fw-result-close:hover{color:var(--fw-text);background:var(--fw-bg-subtle)}

.board-wrap>.card-table{box-shadow:none}
@media (max-width:640px){.game-hud{padding:12px}}

/* Flush stage: HUD bar + full-bleed desktop, no nested card */
.game-stage>:only-child{display:flex;flex-direction:column;flex:1;min-height:0}
.game-stage .board-wrap{height:auto!important;flex:1 1 auto;margin:0}
.game-stage .card-table{height:auto!important;flex:1 1 auto;margin:0;border-radius:0}
.game-stage .card-table{flex:1 1 auto!important}
.game-stage .board-wrap{margin:0!important}
.game-stage .game-hud{margin:0!important}

.fw-result-actions button:focus-visible,.fw-result-close:focus-visible,.fw-result-share:focus-visible,.fw-result-share-img:focus-visible{outline:2px solid var(--fw-retro);outline-offset:2px}
.fw-result-actions button:focus:not(:focus-visible),.fw-result-close:focus:not(:focus-visible){outline:none}

/* Prop buttons (icon + name + count badge), shared across games */
.prop-btn{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--fw-border);
  background:var(--fw-surface);color:var(--fw-text);font:inherit;font-size:13.5px;font-weight:700;
  padding:8px 12px;border-radius:999px;cursor:pointer;line-height:1;white-space:nowrap}
.prop-btn svg{width:15px;height:15px;flex:0 0 auto;display:block;overflow:visible}
.prop-btn:hover{border-color:var(--fw-border-strong)}
.prop-btn:disabled{opacity:.45;cursor:default}
.prop-badge{min-width:18px;height:18px;padding:0 5px;border-radius:999px;background:#FEF3C7;
  color:#92400E;font-size:11px;font-weight:800;display:inline-flex;align-items:center;
  justify-content:center;font-variant-numeric:tabular-nums;box-sizing:border-box}
[data-theme="dark"] .prop-badge{background:#3A2E14;color:#FBBF24}
.prop-btn:disabled .prop-badge,.prop-badge.empty{background:var(--fw-bg-subtle);color:var(--fw-text-muted)}
.prop-btn.active{border-color:#D97706;box-shadow:0 0 0 2px rgba(245,158,11,.25);color:#92400E}
[data-theme="dark"] .prop-btn.active{color:#FBBF24}
.prop-btn.active-bomb{border-color:#DC2626;box-shadow:0 0 0 2px rgba(220,38,38,.22);color:#DC2626}

/* Hide native search clear button (custom clear buttons instead) */
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration{-webkit-appearance:none;appearance:none;display:none}
input[type="search"]{appearance:textfield;-moz-appearance:textfield}

/* Mobile game pages (2026-12-03): two-layer compact HUD, tighter whitespace.
   Layer 1: stats left + tools right. Layer 2: play actions full row.
   Empty play group collapses to a single layer (stats + tools). */
@media (max-width:720px){
  .game-head{padding:10px 0 8px}
  .game-head .crumbs{margin-bottom:6px;font-size:12.5px}
  .game-title-row{gap:10px}
  .game-title-row h1{font-size:20px}
  .game-stage{min-height:0;margin-bottom:20px;border-radius:16px}
  .board-wrap{min-height:320px}
  .stage-snake .board-wrap{min-height:min(420px,calc(100dvh - 240px))}
  .card-table{min-height:360px}
  .board-wrap{padding:16px 12px;gap:10px}
  .game-hud{display:grid;grid-template-columns:minmax(0,1fr) auto;
    grid-template-areas:"stats tools" "play play";align-items:center;
    column-gap:8px;row-gap:0;padding:8px 12px}
  .hud-play{grid-area:play;justify-self:stretch;justify-content:flex-start;flex-wrap:wrap;gap:6px;min-width:0;width:100%;
    border-top:1px solid var(--fw-border);padding-top:8px;margin-top:8px}
  .hud-tools{grid-area:tools;justify-self:end;justify-content:flex-end;gap:5px}
  .hud-stats{grid-area:stats;justify-self:start;justify-content:flex-start;flex-wrap:nowrap;gap:5px;min-width:0}
  .hud-stat{min-width:52px;padding:3px 7px;font-size:13px;line-height:1.25;border-radius:9px;white-space:nowrap}
  .hud-play>*,.hud-stats>*,.hud-tools>*{flex:0 0 auto}
  .hud-stat .lbl{white-space:nowrap}
  .hud-stat .lbl{font-size:9.5px;letter-spacing:.04em}
  .hud-tool,.hud-reset,.hud-tools #lbToggle{width:32px;height:32px;padding:0;box-shadow:none}
  .hud-sep{display:none}
  .hud-flag{width:auto;padding:0 12px;white-space:nowrap}
  .prop-btn{padding:7px 9px;font-size:12.5px;gap:4px}
  .prop-btn svg{width:14px;height:14px}
  .prop-badge{min-width:16px;height:16px;font-size:10px;padding:0 4px}
  .hud-btn{padding:6px 11px;font-size:12.5px;white-space:nowrap}
  .diff-pills button{padding:5px 11px;font-size:12.5px}
  /* Wide prop groups go icon+badge only so layer 1 fits one row */
  .stage-mahjong-merge .prop-btn,.stage-sheep-match .prop-btn{font-size:0;padding:7px 8px}
  .stage-mahjong-merge .prop-badge,.stage-sheep-match .prop-badge{font-size:10px}
  /* No play actions: single compact layer */
  .game-hud:has(>.hud-play:empty){grid-template-areas:"stats tools"}
  .game-hud:has(>.hud-play:empty) .hud-play{display:none}
}

/* Share-card preview lightbox (over the result modal) */
.fw-share-preview{position:fixed;inset:0;z-index:960;display:flex;align-items:center;justify-content:center;padding:20px;background:rgba(28,25,23,.45);backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);animation:fw-backdrop-in .22s ease-out}
.fw-share-preview-card{position:relative;width:100%;max-width:560px;background:var(--fw-surface);border:1px solid var(--fw-border);border-radius:20px;padding:22px;box-shadow:0 24px 54px rgba(0,0,0,.22);animation:fw-pop-in .26s cubic-bezier(.22,1,.36,1)}
.fw-share-preview-frame{position:relative;width:100%;aspect-ratio:1200/680;border-radius:12px;overflow:hidden;background:var(--fw-bg-subtle)}
.fw-share-preview-img{display:block;width:100%;height:100%;object-fit:cover;opacity:0;transition:opacity .25s ease}
.fw-share-preview-frame.loaded .fw-share-preview-img{opacity:1}
.fw-share-preview-loading{position:absolute;inset:0;margin:auto;width:44px;height:44px;border-radius:50%;border:4px solid var(--fw-border);border-top-color:#108A5A;border-right-color:#F59E0B;animation:fw-share-spin .9s linear infinite}
.fw-share-preview-frame.loaded .fw-share-preview-loading{display:none}
@keyframes fw-share-spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){.fw-share-preview-loading{animation-duration:2.4s}}
.fw-share-preview-social{display:flex;justify-content:center;width:100%;margin-top:16px}
.fw-share-preview-hint{text-align:center;font-size:12px;color:var(--fw-text-muted);margin-top:10px}
.fw-share-preview-close{position:absolute;top:-14px;right:-14px;width:34px;height:34px;border:1px solid var(--fw-border);background:var(--fw-surface);color:var(--fw-text-muted);font-size:20px;line-height:1;cursor:pointer;border-radius:50%;box-shadow:0 6px 18px rgba(0,0,0,.16)}
.fw-share-preview-close:hover{color:var(--fw-text)}
.fw-share-preview-actions{display:flex;gap:8px;justify-content:center;flex-wrap:wrap;margin-top:18px}
.fw-share-preview-actions button{background:transparent;border:1px solid var(--fw-border);box-shadow:none;padding:8px 18px;border-radius:999px;color:var(--fw-text-secondary);font:inherit;font-size:13.5px;font-weight:600;cursor:pointer;white-space:nowrap}
.fw-share-preview-actions button:hover{background:var(--fw-bg-subtle);color:var(--fw-text)}
.fw-share-preview-actions .fw-share-preview-copy{background:#108A5A;border-color:#108A5A;color:#FFFFFF}
.fw-share-preview-actions .fw-share-preview-copy:hover{background:#0D734B;border-color:#0D734B;color:#FFFFFF}
.fw-share-preview-actions .fw-share-preview-save{background:var(--fw-surface);border:1px solid var(--fw-border);color:var(--fw-text-secondary)}
.fw-share-preview-actions button:focus-visible,.fw-share-preview-close:focus-visible{outline:2px solid var(--fw-retro);outline-offset:2px}
