/* Colors: dark is the default; light applies via data-mode="light" (set by applyTheme) or the OS setting before JS runs. */
:root {
  color-scheme: dark;
  --bg: #0f0e17; --surface: #1a1828; --surface2: #252336;
  --accent1: #ff6b6b; --accent2: #ffd93d; --accent3: #6bcb77;
  --accent4: #4d96ff; --accent5: #c77dff;
  --text: #fffffe; --text2: #bec0d0;
  --radius: 16px; --radius-lg: 24px;
  --border: rgba(255,255,255,0.09); --shadow: 0 14px 34px rgba(0,0,0,0.28);
  --bar-bg: color-mix(in srgb, var(--surface) 95%, transparent); --bar-shadow: 0 14px 40px rgba(0,0,0,.48);
  --overlay: rgba(4,4,12,.82); --watermark: rgba(255,255,255,.035);
  --good-bg: #1a3a2a; --bad-bg: #3a1a1a;
  --nav-active: color-mix(in srgb, var(--accent4) 55%, var(--text));
}
:root[data-mode="light"] {
  color-scheme: light;
  --bg: #f4f3fa; --surface: #ffffff; --surface2: #ecebf5;
  --accent1: #e5484d; --accent2: #b07800; --accent3: #2b9348;
  --accent4: #2f6fe0; --accent5: #9440d6;
  --text: #1c1a2e; --text2: #5b5970;
  --border: rgba(28,26,60,.12); --shadow: 0 10px 28px rgba(40,34,90,.10);
  --bar-shadow: 0 8px 28px rgba(40,34,90,.14);
  --overlay: rgba(28,26,46,.55); --watermark: rgba(28,26,60,.05);
  --good-bg: #dcf3e2; --bad-bg: #fde3e3;
  --nav-active: var(--accent4);
}
@media (prefers-color-scheme: light) {
  :root:not([data-mode]) {
    color-scheme: light;
    --bg: #f4f3fa; --surface: #ffffff; --surface2: #ecebf5;
    --accent1: #e5484d; --accent2: #b07800; --accent3: #2b9348;
    --accent4: #2f6fe0; --accent5: #9440d6;
    --text: #1c1a2e; --text2: #5b5970;
    --border: rgba(28,26,60,.12); --shadow: 0 10px 28px rgba(40,34,90,.10);
    --bar-shadow: 0 8px 28px rgba(40,34,90,.14);
    --overlay: rgba(28,26,46,.55); --watermark: rgba(28,26,60,.05);
    --good-bg: #dcf3e2; --bad-bg: #fde3e3;
    --nav-active: var(--accent4);
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
button, .game-card, .chip, .sol-card { -webkit-tap-highlight-color:transparent; touch-action:manipulation; }
body { font-family: system-ui, -apple-system, 'Segoe UI', 'Noto Sans JP', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; padding-bottom:92px; }
body.playing-game { padding-bottom:0; }
body.playing-game .app-taskbar { display:none; }
/*1~13,16,17のゲームはclaude が作成、14と15はgeminiが作成*/
/* TOP BAR */
#topbar { display: flex; align-items: center; gap: 12px; padding: 11px 20px; background:var(--bar-bg); border-bottom:1px solid var(--border); position: sticky; top: 0; z-index: 100; backdrop-filter:blur(16px); }
#topbar h1 { font-size: 20px; font-weight: 900; }
#topbar h1 span { color: var(--accent2); }
.back-btn { background: var(--surface2); border: none; color: var(--text); padding: 7px 14px; border-radius: 999px; font-family: inherit; font-size: 13px; cursor: pointer; display: none; }
.back-btn:hover { background: var(--border); }
#topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tb-pill { background: var(--surface2); border-radius: 999px; padding: 5px 14px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.tb-pill.lv { color: var(--accent5); }
.tb-pill.pt { color: var(--accent2); }
.tb-save-btn { background: var(--accent3); color: #111; border: none; border-radius: 999px; padding: 6px 14px; font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.tb-save-btn:hover { opacity: 0.85; }
.tb-load-btn { background: var(--accent4); color: #fff; border: none; border-radius: 999px; padding: 6px 14px; font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.tb-profile-btn { width:38px; height:38px; flex:0 0 38px; display:grid; place-items:center; overflow:hidden; white-space:nowrap; background:linear-gradient(135deg,var(--accent4),var(--accent5)); color:#fff; border:none; border-radius:50%; padding:0; font-family:inherit; font-size:20px; line-height:1; cursor:pointer; }
.tb-rules-btn { background:var(--surface2); color:var(--text); border:1px solid var(--border); border-radius:999px; padding:6px 14px; font-family:inherit; font-size:13px; font-weight:700; cursor:pointer; }
.tb-install-btn { display:none; background:linear-gradient(135deg,var(--accent4),var(--accent5)); color:#fff; border:0; border-radius:999px; padding:6px 14px; font-family:inherit; font-size:13px; font-weight:800; cursor:pointer; white-space:nowrap; }
.tb-install-btn.visible { display:inline-block; }

/* HOME */
#home { padding: 20px; }
.home-banner { background: var(--surface); border-radius: var(--radius-lg); padding: 20px 24px; margin-bottom: 20px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.lv-badge { width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(135deg, var(--accent5), var(--accent4)); display: flex; align-items: center; justify-content: center; flex-direction: column; flex-shrink: 0; }
.lv-badge .lv-num { font-size: 22px; font-weight: 900; }
.lv-badge .lv-label { font-size: 9px; color: rgba(255,255,255,0.8); }
.lv-info { flex: 1; min-width: 160px; }
.lv-info h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.lv-bar-wrap { background: var(--surface2); border-radius: 999px; height: 8px; overflow: hidden; margin-bottom: 4px; }
.lv-bar { height: 100%; background: linear-gradient(90deg, var(--accent4), var(--accent5)); border-radius: 999px; transition: width 0.5s; }
.lv-xp-text { font-size: 11px; color: var(--text2); }
.home-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat-card { background: var(--surface2); border-radius: var(--radius); padding: 10px 16px; text-align: center; min-width: 90px; }
.stat-card .s-val { font-size: 20px; font-weight: 900; color: var(--accent2); }
.stat-card .s-label { font-size: 10px; color: var(--text2); }
.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.game-card { background: var(--surface); border-radius: var(--radius-lg); padding: 20px 16px; cursor: pointer; border: 1px solid var(--border); transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s; position: relative; overflow: hidden; box-shadow: 0 8px 22px rgba(0,0,0,.16); }
.game-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--card-color); }
.game-card:hover { transform: translateY(-3px); border-color: var(--card-color); box-shadow: var(--shadow); }
.game-icon { font-size: 36px; margin-bottom: 10px; display: block; }
.game-title { font-size: 16px; font-weight: 700; margin-bottom: 3px; }
.game-desc { font-size: 11px; color: var(--text2); line-height: 1.5; }
.game-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.game-tag { font-size: 10px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--card-color); color: #111; }
.game-hs { font-size: 10px; color: var(--text2); }
.game-hs span { color: var(--accent2); font-weight: 700; }
.mastery-line { display:flex; align-items:center; justify-content:space-between; gap:6px; margin-top:8px; font-size:10px; color:var(--text2); }
.mastery-stars { color:var(--accent2); letter-spacing:1px; white-space:nowrap; }
.meta-dashboard { display:grid; grid-template-columns:repeat(5,minmax(145px,1fr)); gap:9px; margin-bottom:16px; align-items:start; }
.meta-panel { background:var(--surface); border:1px solid var(--border); border-radius:15px; padding:0; box-shadow:0 5px 14px rgba(0,0,0,.12); overflow:hidden; }
.meta-title { display:flex; align-items:center; justify-content:space-between; gap:7px; font-size:12px; font-weight:900; padding:11px 12px; cursor:pointer; list-style:none; user-select:none; }
.meta-title::-webkit-details-marker { display:none; }
.meta-title::after { content:'＋'; color:var(--text2); font-size:15px; margin-left:auto; }
.meta-panel[open] .meta-title::after { content:'−'; }
.meta-panel > div:not(.meta-title) { padding:0 11px 11px; }
.meta-sub { color:var(--text2); font-size:10px; font-weight:500; }
.mission-item, .achievement-item, .shop-item { background:var(--surface2); border:1px solid var(--border); border-radius:12px; padding:10px; margin-top:7px; }
.mission-head, .shop-head { display:flex; justify-content:space-between; align-items:center; gap:8px; font-size:12px; font-weight:700; }
.mission-reward { color:var(--accent2); white-space:nowrap; }
.mission-progress { height:5px; background:var(--surface); border-radius:999px; overflow:hidden; margin-top:7px; }
.mission-progress > span { display:block; height:100%; background:linear-gradient(90deg,var(--accent4),var(--accent5)); border-radius:999px; }
.mission-item.done { border-color:rgba(107,203,119,.5); }
.achievement-list { display:flex; flex-wrap:wrap; gap:6px; }
.achievement-badge { background:var(--surface2); border:1px solid var(--border); border-radius:999px; padding:5px 9px; font-size:10px; color:var(--text2); }
.achievement-badge.unlocked { color:var(--accent2); border-color:rgba(255,217,61,.45); }
.shop-item .btn { min-height:32px; padding:5px 10px; font-size:10px; box-shadow:none; }
.theme-dots { display:flex; gap:3px; margin-top:5px; }
.theme-dots i { display:block; width:12px; height:12px; border-radius:50%; }
.ranking-controls { display:flex; gap:7px; margin-bottom:8px; }
.ranking-controls select { flex:1; min-width:0; background:var(--surface2); color:var(--text); border:1px solid var(--border); border-radius:10px; padding:7px; font-family:inherit; }
.ranking-mode-tabs { display:grid; grid-template-columns:repeat(4,1fr); gap:7px; margin-bottom:12px; }
.ranking-mode-tab { min-height:42px; border:1px solid var(--border); border-radius:11px; background:var(--surface2); color:var(--text2); font-family:inherit; font-size:12px; font-weight:800; cursor:pointer; }
.ranking-mode-tab.active { background:var(--accent4); border-color:var(--accent4); color:#fff; }
.ranking-row { display:grid; grid-template-columns:28px 1fr auto; align-items:center; gap:7px; padding:7px 4px; border-bottom:1px solid var(--border); font-size:11px; }
.ranking-row:last-child { border-bottom:none; }
.ranking-rank { color:var(--accent2); font-weight:900; }
.ranking-score { font-weight:900; color:var(--accent3); }
.profile-preview { display:flex; align-items:center; gap:12px; background:var(--surface2); border-radius:var(--radius); padding:12px; margin-bottom:14px; }
.profile-avatar { width:48px; height:48px; display:grid; place-items:center; background:var(--surface); border-radius:50%; font-size:26px; }
.avatar-picker { display:flex; gap:7px; flex-wrap:wrap; margin:8px 0 14px; }
.avatar-option { width:40px; height:40px; border:2px solid transparent; background:var(--surface2); border-radius:50%; font-size:20px; cursor:pointer; }
.avatar-option.selected { border-color:var(--accent2); }
.profile-stats { display:grid; grid-template-columns:repeat(3,1fr); gap:7px; margin-bottom:14px; }
.profile-stat { background:var(--surface2); border-radius:12px; padding:9px; text-align:center; }
.profile-stat strong { display:block; color:var(--accent2); font-size:17px; }
.profile-stat span { color:var(--text2); font-size:9px; }
.player-card { position:relative; overflow:hidden; background:linear-gradient(135deg,var(--surface2),var(--surface)); border:1px solid var(--border); border-radius:20px; padding:18px; margin-bottom:14px; }
.player-card::after { content:'GAME CARD'; position:absolute; right:-8px; bottom:4px; font-size:34px; font-weight:900; color:var(--watermark); transform:rotate(-8deg); }
.player-card-main { display:flex; align-items:center; gap:13px; position:relative; z-index:1; }
.player-card .profile-avatar { width:58px; height:58px; font-size:32px; background:linear-gradient(135deg,var(--accent4),var(--accent5)); }
.challenge-box { background:linear-gradient(135deg,rgba(199,125,255,.16),rgba(77,150,255,.1)); border:1px solid rgba(199,125,255,.32); border-radius:14px; padding:12px; }
.challenge-game { font-size:16px; font-weight:900; margin-bottom:4px; }
.challenge-active { position:sticky; top:66px; z-index:90; background:var(--surface); border:1px solid var(--accent5); border-radius:14px; padding:8px 12px; margin-bottom:12px; display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:11px; box-shadow:var(--shadow); }
.game-browser { background:var(--surface); border:1px solid var(--border); border-radius:18px; padding:12px; margin-bottom:14px; }
.game-browser-top { display:flex; gap:9px; align-items:center; }
.game-search { flex:1; min-width:0; }
.game-filter-row { display:flex; gap:6px; flex-wrap:wrap; margin-top:9px; }
.filter-chip { border:1px solid var(--border); background:var(--surface2); color:var(--text2); border-radius:999px; padding:5px 10px; font-family:inherit; font-size:10px; font-weight:700; cursor:pointer; }
.filter-chip.active { background:var(--accent4); color:#fff; border-color:var(--accent4); }
.favorite-btn { position:absolute; top:10px; right:10px; width:32px; height:32px; display:grid; place-items:center; border:1px solid var(--border); border-radius:50%; background:var(--surface2); color:var(--text2); font-size:16px; cursor:pointer; z-index:2; }
.favorite-btn.active { color:var(--accent2); }
.games-empty { grid-column:1/-1; color:var(--text2); text-align:center; padding:40px 15px; background:var(--surface); border-radius:var(--radius-lg); }
.hub-link { width:100%; border:0; color:var(--text); background:linear-gradient(135deg,var(--surface2),var(--surface)); border-radius:12px; padding:12px; cursor:pointer; font:inherit; font-size:12px; font-weight:800; text-align:left; }
.hub-link:hover { outline:1px solid var(--accent4); }
.app-page { display:none; padding:20px; max-width:1100px; margin:0 auto; }
.page-hero { background:linear-gradient(135deg,rgba(199,125,255,.2),rgba(77,150,255,.14)); border:1px solid var(--border); border-radius:24px; padding:24px; margin-bottom:18px; }
.page-hero h2 { font-size:26px; margin-bottom:6px; }
.page-content { max-width:760px; margin:0 auto; background:var(--surface); border:1px solid var(--border); border-radius:20px; padding:20px; box-shadow:0 8px 22px rgba(0,0,0,.14); }
.menu-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.menu-card { display:flex; align-items:center; gap:14px; min-height:92px; padding:16px; border:1px solid var(--border); border-radius:18px; background:var(--surface); color:var(--text); text-align:left; font:inherit; cursor:pointer; box-shadow:0 8px 22px rgba(0,0,0,.12); }
.menu-card:hover { border-color:var(--accent4); transform:translateY(-1px); }
.menu-card-icon { width:48px; height:48px; flex:0 0 48px; display:grid; place-items:center; border-radius:15px; background:var(--surface2); font-size:26px; }
.menu-card strong { display:block; font-size:15px; margin-bottom:3px; }
.menu-card small { display:block; color:var(--text2); font-size:10px; line-height:1.45; }
.store-choice { max-width:850px; margin:0 auto; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.store-choice .menu-card { min-height:150px; padding:22px; }
.store-choice .menu-card-icon { width:64px; height:64px; flex-basis:64px; font-size:36px; }
.shop-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(230px,1fr)); gap:14px; }
.shop-card { background:var(--surface); border:1px solid var(--border); border-radius:18px; padding:17px; box-shadow:0 8px 22px rgba(0,0,0,.14); }
.shop-card.active { border-color:var(--accent3); }
.shop-card h3 { font-size:16px; margin-bottom:4px; }
.shop-card p { color:var(--text2); font-size:11px; line-height:1.55; min-height:35px; }
.shop-card .theme-dots i { width:22px; height:22px; }
.shop-card .btn { width:100%; margin-top:14px; }
.shop-section-title { font-size:20px; margin:24px 0 12px; }
.collection-summary { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; margin:18px 0; }
.collection-summary-card { padding:16px; border:1px solid var(--border); border-radius:16px; background:var(--surface); text-align:center; }
.collection-summary-card strong { display:block; color:var(--accent2); font-size:24px; }
.collection-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(190px,1fr)); gap:12px; }
.collection-card { min-height:190px; display:flex; flex-direction:column; align-items:center; padding:16px; border:1px solid var(--border); border-radius:18px; background:var(--surface); text-align:center; }
.collection-card.locked { opacity:.58; }
.collection-card-icon { width:68px; height:68px; display:grid; place-items:center; margin-bottom:9px; border-radius:50%; background:var(--surface2); font-size:36px; }
.collection-card.locked .collection-card-icon { filter:grayscale(1); }
.collection-card strong { font-size:13px; }.collection-card small { color:var(--text2); font-size:10px; margin:4px 0 10px; }.collection-card .btn { width:100%; margin-top:auto; padding:6px; font-size:11px; }
.avatar-shop-card { text-align:center; }
.avatar-shop-icon { width:70px; height:70px; margin:0 auto 10px; display:grid; place-items:center; border-radius:50%; background:linear-gradient(135deg,var(--surface2),var(--surface)); border:1px solid var(--border); font-size:38px; }
.privacy-note { margin-top:12px; padding:10px; border-radius:10px; background:var(--surface2); color:var(--text2); font-size:10px; line-height:1.6; }
.gacha-panel { position:relative; overflow:hidden; background:linear-gradient(135deg,rgba(199,125,255,.22),rgba(77,150,255,.13)); border:1px solid rgba(199,125,255,.4); border-radius:22px; padding:20px; }
.gacha-panel::after { content:'GACHA'; position:absolute; right:-8px; top:-18px; font-size:76px; font-weight:1000; color:var(--watermark); transform:rotate(8deg); pointer-events:none; }
.gacha-wallet { display:flex; gap:8px; flex-wrap:wrap; margin:12px 0; }
.gacha-wallet span { background:var(--surface); border:1px solid var(--border); border-radius:999px; padding:7px 12px; font-size:12px; font-weight:900; }
.gacha-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; position:relative; z-index:1; }
.gacha-actions .btn { width:100%; }
.gacha-rates { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:6px; margin-top:14px; }
.gacha-rate { background:color-mix(in srgb, var(--bg) 55%, transparent); border-radius:10px; padding:8px 4px; text-align:center; font-size:10px; }
.gacha-rate strong { display:block; font-size:13px; }
.gacha-results { display:grid; grid-template-columns:repeat(auto-fill,minmax(115px,1fr)); gap:9px; margin-top:14px; }
.gacha-result { background:var(--surface); border:2px solid var(--border); border-radius:15px; padding:12px 7px; text-align:center; animation:gachaPop .36s ease both; }
.gacha-result-icon { font-size:34px; line-height:1.2; margin-bottom:5px; }
.gacha-result strong,.gacha-item-rarity { display:block; font-size:11px; }
.gacha-result small { color:var(--text2); font-size:9px; }
.gacha-result .btn { width:100%; min-height:34px; padding:5px 7px; margin-top:8px; font-size:10px; }
.gacha-reveal { position:fixed; inset:0; z-index:1500; display:grid; place-items:center; padding:18px; background:var(--overlay); backdrop-filter:blur(12px); overflow:auto; }
.gacha-reveal-box { position:relative; width:min(760px,100%); max-height:calc(100dvh - 36px); overflow:auto; padding:clamp(22px,5vw,38px); border:2px solid var(--reveal-color,#89909d); border-radius:26px; background:radial-gradient(circle at 50% 15%,var(--reveal-glow,rgba(137,144,157,.28)),transparent 42%),var(--surface); box-shadow:0 0 50px var(--reveal-glow,rgba(137,144,157,.28)); text-align:center; animation:revealBoxIn .35s ease both; }
.gacha-reveal-orb { width:112px; height:112px; display:grid; place-items:center; margin:22px auto; border-radius:50%; background:conic-gradient(from 0deg,#4d96ff,#c77dff,#ffd93d,#4d96ff); font-size:52px; box-shadow:0 0 45px var(--reveal-glow,rgba(199,125,255,.5)); animation:gachaDrawSpin .75s linear infinite,gachaPulse .7s ease-in-out infinite alternate; }
.gacha-reveal.revealed .gacha-reveal-orb { animation:revealBurst .5s ease both; }
.gacha-reveal .gacha-results { grid-template-columns:repeat(auto-fit,minmax(120px,1fr)); max-height:55vh; overflow:auto; }
.gacha-reveal.rarity-R { --reveal-color:#4d96ff; --reveal-glow:rgba(77,150,255,.42); }.gacha-reveal.rarity-SR,.gacha-reveal.rarity-SSR { --reveal-color:#c77dff; --reveal-glow:rgba(199,125,255,.48); }.gacha-reveal.rarity-UR { --reveal-color:#ffd93d; --reveal-glow:rgba(255,217,61,.55); }.gacha-reveal.rarity-SECRET { --reveal-color:var(--text); --reveal-glow:rgba(255,112,166,.62); }
@keyframes gachaDrawSpin { to { transform:rotate(360deg); } } @keyframes gachaPulse { to { scale:1.12; filter:brightness(1.35); } } @keyframes revealBurst { 50%{scale:1.35;filter:brightness(2)} 100%{scale:0;opacity:0;height:0;margin:0 auto} } @keyframes revealBoxIn { from{opacity:0;transform:scale(.88)} }
@media (prefers-reduced-motion:reduce) { .gacha-reveal-orb,.gacha-reveal-box { animation:none!important; } }
.rarity-N { border-color:#89909d; }.rarity-R { border-color:#4d96ff; }.rarity-SR { border-color:#c77dff; }.rarity-UR { border-color:#ffd93d; box-shadow:0 0 18px rgba(255,217,61,.25); }.rarity-SECRET { border-color:var(--text); box-shadow:0 0 22px rgba(199,125,255,.5); background:linear-gradient(135deg,rgba(255,107,107,.2),rgba(77,150,255,.2),rgba(107,203,119,.2)); }
.gacha-collection { display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); gap:10px; }
.gacha-collection-card { display:flex; align-items:center; gap:10px; background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:11px; }
.gacha-collection-card.locked { opacity:.5; filter:grayscale(1); }
.gacha-collection-card .gacha-result-icon { margin:0; min-width:42px; text-align:center; }
.gacha-collection-info { flex:1; min-width:0; }.gacha-collection-info strong { display:block; font-size:12px; }.gacha-collection-info small { color:var(--text2); font-size:9px; }
.gacha-collection-card .btn { width:auto; min-height:32px; margin:0; padding:5px 9px; font-size:10px; }
.profile-avatar.frame-blue { box-shadow:0 0 0 3px #4d96ff,0 0 15px rgba(77,150,255,.6); }
.profile-avatar.frame-red { box-shadow:0 0 0 3px #ff6b6b,0 0 15px rgba(255,107,107,.6); }
.profile-avatar.frame-neon { box-shadow:0 0 0 3px #00f5d4,0 0 18px #f15bb5; }
.profile-avatar.frame-gold { box-shadow:0 0 0 4px #ffd93d,0 0 22px rgba(255,217,61,.8); }
.profile-avatar.frame-cosmic { box-shadow:0 0 0 4px #7b2cbf,0 0 25px #4cc9f0; }
.profile-avatar.frame-secret { animation:secretGlow 1.6s linear infinite; }
@keyframes gachaPop { from { opacity:0; transform:translateY(10px) scale(.9); } to { opacity:1; transform:none; } }
@keyframes secretGlow { 0%{box-shadow:0 0 0 4px #ff6b6b,0 0 25px #ff6b6b} 33%{box-shadow:0 0 0 4px #6bcb77,0 0 25px #6bcb77} 66%{box-shadow:0 0 0 4px #4d96ff,0 0 25px #4d96ff} 100%{box-shadow:0 0 0 4px #ff6b6b,0 0 25px #ff6b6b} }

/* APP TASKBAR & FEATURE PAGES */
.app-taskbar { position:fixed; left:50%; bottom:max(12px,env(safe-area-inset-bottom)); transform:translateX(-50%); z-index:400; width:min(720px,calc(100% - 24px)); display:grid; grid-template-columns:repeat(5,1fr); gap:5px; padding:8px; border:1px solid var(--border); border-radius:22px; background:var(--bar-bg); box-shadow:var(--bar-shadow); backdrop-filter:blur(16px); }
.taskbar-item { min-width:0; min-height:55px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px; border:0; border-radius:15px; background:transparent; color:var(--text2); font-family:inherit; font-size:10px; font-weight:800; cursor:pointer; }
.taskbar-item:hover { background:var(--surface2); color:var(--text); }
.taskbar-item.active { color:#fff; background:linear-gradient(135deg,var(--accent4),var(--accent5)); }
.taskbar-icon { font-size:20px; line-height:1; }
.taskbar-label { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:100%; }
#hub-achievements .achievement-list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px; }
#hub-achievements .achievement-badge { padding:12px; border-radius:13px; font-size:12px; line-height:1.45; display:flex; flex-direction:column; gap:5px; min-width:0; }
#hub-achievements .achievement-badge:not(.unlocked) .achievement-icon { filter:grayscale(1); opacity:.55; }
#hub-achievements .achievement-badge.unlocked { background:color-mix(in srgb,var(--accent2) 10%,var(--surface2)); }
.achievement-head { display:flex; align-items:center; gap:7px; min-width:0; }
.achievement-head strong { flex:1; min-width:0; color:var(--text); font-size:13px; }
.achievement-icon { font-size:20px; line-height:1; }
.achievement-desc { color:var(--text); }
.achievement-meta { display:flex; flex-wrap:wrap; justify-content:space-between; gap:2px 8px; font-size:11px; color:var(--text2); }
.achievement-filters { display:flex; gap:6px; margin-bottom:12px; }
.achievement-filters button { flex:1; min-height:40px; border:1px solid var(--border); border-radius:10px; background:var(--surface2); color:var(--text2); font-family:inherit; font-size:12px; font-weight:800; cursor:pointer; }
.achievement-filters button[aria-pressed="true"] { background:var(--accent4); border-color:var(--accent4); color:#fff; }
#hub-ranking .ranking-row { grid-template-columns:36px 1fr auto; padding:12px 6px; font-size:13px; }
#hub-ranking .ranking-controls select { min-height:44px; font-size:13px; }
#hub-daily .mission-item, #hub-challenge .challenge-box { padding:14px; }

/* GAME SCREEN */
#game-screen { display: none; padding: 20px; max-width: 680px; margin: 0 auto; }
.game-layout { width:100%; }
#game-screen[data-game] { max-width:760px; }
#game-screen[data-game] > .game-header { background:linear-gradient(135deg,var(--surface),rgba(77,150,255,.06)); border:1px solid var(--border); border-radius:18px; padding:16px; }
#game-screen[data-game] .info-row { justify-content:center; }
#game-screen[data-game] canvas { height:auto; }
.game-header { text-align: center; margin-bottom: 20px; }
.game-header h2 { font-size: 24px; font-weight: 900; margin-bottom: 4px; }
.game-header p { color: var(--text2); font-size: 13px; }

/* LEVEL UP TOAST */
#lvup-toast { position:fixed; bottom:calc(100px + env(safe-area-inset-bottom)); left:50%; transform:translateX(-50%); width:max-content; max-width:calc(100vw - 32px); background:var(--surface); color:var(--text); border:1px solid var(--border); border-left:3px solid var(--notice-color,var(--accent4)); padding:9px 14px; border-radius:12px; font-weight:600; font-size:12px; line-height:1.5; z-index:999; opacity:0; visibility:hidden; transition:opacity .15s; pointer-events:none; box-shadow:0 4px 16px rgba(0,0,0,.2); overflow-wrap:anywhere; }
#lvup-toast.show { opacity:1; visibility:visible; }
body.playing-game #lvup-toast { bottom:calc(8px + env(safe-area-inset-bottom)); font-size:11px; padding:6px 10px; }
/* Avoid accidental long-press selection on game controls while keeping text entry and copying available. */
#game-screen, #game-screen *, button, button *, .game-card, .game-card *, .app-taskbar, #lvup-toast { -webkit-user-select:none; user-select:none; -webkit-touch-callout:none; }
input, textarea, [contenteditable="true"], #game-screen input, #game-screen textarea, #game-screen [contenteditable="true"] { -webkit-user-select:text; user-select:text; -webkit-touch-callout:default; }

/* BUTTONS */
.btn { background: var(--accent4); color: #fff; border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 11px 26px; min-height: 42px; font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer; transition: opacity 0.15s, transform 0.1s, filter .15s, box-shadow .15s; box-shadow: 0 5px 12px rgba(0,0,0,.18); }
.btn:hover { opacity: 0.85; }
.btn:active { transform: scale(0.97); }
.btn:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(77,150,255,.35); outline-offset: 2px; }
.btn:disabled { cursor: not-allowed; filter: grayscale(.35); box-shadow: none; opacity:.45; }
.btn-danger { background: var(--accent1); }
.btn-success { background: var(--accent3); color: #111; }
.btn-warn { background: var(--accent2); color: #111; }
.btn-purple { background: var(--accent5); }
.btn-sm { padding: 7px 16px; font-size: 13px; }

/* RESULT BOX */
.result-box { background: var(--surface2); border-radius: var(--radius); padding: 20px; text-align: center; margin-top: 20px; }
.result-box .result-score { font-size: 48px; font-weight: 900; color: var(--accent2); }
.result-box p { color: var(--text2); margin-top: 8px; font-size: 14px; }
.result-overlay { position:fixed; inset:0; z-index:1200; display:grid; place-items:center; padding:20px; background:var(--overlay); backdrop-filter:blur(8px); overflow:auto; animation:resultFade .2s ease both; }
.result-overlay .result-box { width:min(620px,100%); margin:auto; padding:clamp(22px,5vw,34px); border:1px solid var(--border); background:var(--surface); box-shadow:0 24px 80px rgba(0,0,0,.5); }
.result-overlay .result-game { margin:0 0 8px; color:var(--text2); font-weight:800; }
.result-overlay h2 { font-size:clamp(25px,7vw,36px); margin-bottom:18px; }
.result-overlay .modal-btns { justify-content:center; margin-top:22px; }
.result-overlay .modal-btns .btn { min-width:140px; }
body.result-open #game-screen { visibility:hidden; }
#game-screen[inert] { pointer-events:none; user-select:none; }
.casino-round-actions { max-width:620px; margin:18px auto 0; padding:18px; text-align:center; background:var(--surface); border:1px solid var(--accent5); border-radius:var(--radius-lg); box-shadow:var(--shadow); }
.result-box .casino-round-buttons { justify-content:center; margin-top:18px; }
.casino-round-actions strong { display:block; margin-bottom:12px; color:var(--accent2); font-size:18px; }
.casino-round-actions .modal-btns { justify-content:center; }
@keyframes resultFade { from { opacity:0; transform:scale(.985); } }
.xp-gain { font-size: 14px; color: var(--accent5); font-weight: 700; margin-top: 6px; }

/* MEMORY */
.memory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0 auto; max-width: 340px; }
.mem-card { aspect-ratio: 1; background: var(--surface2); border-radius: 12px; font-size: 26px; display: flex; align-items: center; justify-content: center; cursor: pointer; user-select: none; transition: transform 0.2s; border: 2px solid transparent; }
.mem-card:hover { transform: scale(1.05); }
.mem-card.flipped { background: var(--surface); border-color: var(--accent4); }
.mem-card.matched { background: var(--good-bg); border-color: var(--accent3); pointer-events: none; }
.mem-back { display: none; }
.mem-card.flipped .mem-back, .mem-card.matched .mem-back { display: block; }
.mem-card.flipped .mem-front, .mem-card.matched .mem-front { display: none; }

/* REACTION */
#reaction-area { width: 100%; height: 240px; background: var(--surface2); border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 900; cursor: pointer; user-select: none; transition: background 0.2s; }
#reaction-area.go { background: var(--good-bg); color: var(--accent3); }
#reaction-area.wait { background: var(--bad-bg); color: var(--accent1); }

/* QUIZ */
.quiz-q { background: var(--surface2); border-radius: var(--radius); padding: 18px; font-size: 17px; font-weight: 700; margin-bottom: 18px; line-height: 1.5; text-align: center; }
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quiz-opt { background: var(--surface2); border: 2px solid var(--surface2); border-radius: var(--radius); padding: 13px; font-family: inherit; font-size: 14px; color: var(--text); cursor: pointer; transition: border-color 0.15s; text-align: center; font-weight: 500; }
.quiz-opt:hover { border-color: var(--accent4); }
.quiz-opt { min-height:52px; line-height:1.45; }
.quiz-opt.correct { background: var(--good-bg); border-color: var(--accent3); color: var(--accent3); }
.quiz-opt.wrong { background: var(--bad-bg); border-color: var(--accent1); color: var(--accent1); }
.quiz-progress { height: 6px; background: var(--surface2); border-radius: 999px; margin-bottom: 14px; overflow: hidden; }
.quiz-bar { height: 100%; background: var(--accent4); transition: width 0.3s; border-radius: 999px; }

/* BLACKJACK */
.card-zone { display: flex; flex-wrap: wrap; gap: 8px; min-height: 88px; margin-bottom: 10px; }
.playing-card { width: 56px; height: 80px; background: #fff; color: #222; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 18px; font-weight: 900; border: 2px solid #ddd; flex-shrink: 0; }
.playing-card.red { color: #e63946; }
.playing-card .suit { font-size: 12px; }
.playing-card.hidden { background: var(--surface2); color: var(--surface2); border-color: var(--surface); }
.zone-label { font-size: 12px; color: var(--text2); margin-bottom: 6px; font-weight: 700; }
.bj-score { font-size: 18px; font-weight: 900; color: var(--accent2); margin-bottom: 14px; }
.bj-btns { display: flex; gap: 10px; }
.chip-row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.chip { width: 50px; height: 50px; border-radius: 50%; border: 3px dashed rgba(255,255,255,0.5); display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 12px; cursor: pointer; transition: transform 0.1s; }
.chip:hover { transform: scale(1.1); }
.card-zone { background:var(--surface2); border:1px solid var(--border); border-radius:14px; padding:10px; }
.bj-btns .btn { flex:1; }

/* HANGMAN */
.word-hint { font-size: 28px; letter-spacing: 8px; font-weight: 900; text-align: center; margin: 14px 0; font-family: monospace; }
.word-wrong { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.word-wrong span { background: var(--bad-bg); color: var(--accent1); padding: 3px 9px; border-radius: 8px; font-weight: 700; font-size: 13px; }
.hangman-svg { display: block; margin: 0 auto 14px; }
.keyboard { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.key { width: 36px; height: 36px; background: var(--surface2); border: none; border-radius: 8px; color: var(--text); font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; transition: background 0.1s; }
.key:hover:not(:disabled) { background: var(--accent4); }
.key:disabled { opacity: 0.3; cursor: not-allowed; }

/* 2048 SLIDE */
.slide-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 7px; background: var(--surface2); padding: 10px; border-radius: var(--radius); user-select: none; }
.slide-cell { aspect-ratio: 1; background: var(--surface); border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 900; transition: background 0.1s; }
.slide-cell[data-v="2"] { background: #2d3a1a; color: #a9d46a; }
.slide-cell[data-v="4"] { background: #3a2d1a; color: #e6a050; }
.slide-cell[data-v="8"] { background: #3a1a1a; color: #ff7c7c; }
.slide-cell[data-v="16"] { background: #1a2d3a; color: #60c8ff; }
.slide-cell[data-v="32"] { background: #2a1a3a; color: #c77dff; }
.slide-cell[data-v="64"] { background: #3a1a2d; color: #ff9de2; }
.slide-cell[data-v="128"] { background: #1a3a2d; color: #6bcb77; font-size: 16px; }
.slide-cell[data-v="256"] { background: #ffd93d; color: #111; font-size: 16px; }
.slide-cell[data-v="512"] { background: #ff6b6b; color: #fff; font-size: 16px; }
.slide-cell[data-v="1024"] { background: #c77dff; color: #fff; font-size: 13px; }
.slide-cell[data-v="2048"] { background: #ffd93d; color: #111; font-size: 13px; }
.slide-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.slide-info .score-num { font-size: 22px; font-weight: 900; color: var(--accent2); }
#game-screen[data-game="slide"] .slide-grid { max-width:440px; margin-inline:auto; }
#game-screen[data-game="slide"] .flex-center .btn { min-width:54px; font-size:18px; }

/* ROULETTE */
.roulette-wrap { text-align: center; }
.roulette-canvas { display: block; margin: 0 auto 14px; border-radius: 50%; }
.bet-info { margin-bottom: 14px; font-size: 15px; }
.bet-info span { color: var(--accent2); font-weight: 900; font-size: 20px; }
.bet-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; }

/* SHIRITORI */
.shiri-chain { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; min-height: 36px; }
.shiri-word { background: var(--surface2); padding: 5px 12px; border-radius: 999px; font-size: 14px; font-weight: 700; }
.shiri-word.new { background: var(--accent4); color: #fff; }
.shiri-input-row { display: flex; gap: 10px; }
.shiri-input { flex: 1; background: var(--surface2); border: 2px solid var(--surface2); border-radius: var(--radius); padding: 11px 14px; color: var(--text); font-family: inherit; font-size: 15px; outline: none; transition: border-color 0.2s; }
.shiri-input:focus { border-color: var(--accent4); }
.shiri-input-row .btn { min-width:88px; }
.shiri-msg { min-height: 22px; font-size: 13px; margin-top: 8px; font-weight: 700; }
.shiri-msg.ok { color: var(--accent3); }
.shiri-msg.err { color: var(--accent1); }
.shiri-prompt { background: var(--surface2); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; text-align: center; }
.shiri-prompt .next-char { font-size: 30px; font-weight: 900; color: var(--accent2); }
.shiri-score-row { display: flex; gap: 10px; margin-bottom: 10px; }
.shiri-score-box { flex: 1; background: var(--surface2); border-radius: var(--radius); padding: 10px; text-align: center; }
.shiri-score-box .label { font-size: 10px; color: var(--text2); }
.shiri-score-box .val { font-size: 20px; font-weight: 900; color: var(--accent2); }

/* TETRIS */
/* TETRIS: a glowing well whose frame colour follows the level, with a compact side column. */
#tetris-wrap { --tet-glow:hsl(255 95% 66%); display:flex; justify-content:center; align-items:flex-start; gap:14px; }
.tetris-board-frame { padding:4px; border-radius:16px; background:linear-gradient(160deg,color-mix(in srgb,var(--tet-glow) 75%,#fff),color-mix(in srgb,var(--tet-glow) 30%,#0a0918)); box-shadow:0 0 0 1px rgba(255,255,255,.08),0 0 26px color-mix(in srgb,var(--tet-glow) 45%,transparent),0 14px 30px rgba(0,0,0,.45); transition:box-shadow .4s; }
#tetris-wrap.danger .tetris-board-frame { animation:tetDanger 1.2s ease-in-out infinite; }
@keyframes tetDanger { 50% { box-shadow:0 0 0 2px rgba(255,80,100,.75),0 0 32px rgba(255,60,90,.7),0 14px 30px rgba(0,0,0,.45); } }
#game-screen[data-game="tetris"] #tetris-canvas { display:block; width:auto; height:min(560px,calc(100dvh - 190px)); border:0; border-radius:12px; box-shadow:none; }
#tetris-canvas.thud { animation:tetThud .14s ease-out; }
@keyframes tetThud { 40% { transform:translateY(3px); } }
#tetris-side { flex:0 0 132px; display:flex; flex-direction:column; gap:8px; }
.tetris-panel { background:var(--surface2); border-radius:14px; padding:8px 10px 10px; text-align:center; }
.tetris-panel .tp-label { font-size:10px; font-weight:800; letter-spacing:.12em; color:var(--text2); margin-bottom:4px; }
.tetris-panel .tp-val { font-size:22px; font-weight:900; color:var(--accent2); font-variant-numeric:tabular-nums; }
.tetris-panel .tp-val.bump { animation:tetBump .25s ease-out; }
@keyframes tetBump { 40% { transform:scale(1.15); } }
.tp-row { display:grid; grid-template-columns:1fr 1fr; gap:4px; margin-top:8px; }
.tp-sub { font-size:17px; font-weight:900; font-variant-numeric:tabular-nums; }
.tp-bar { height:5px; margin-top:8px; border-radius:999px; background:rgba(127,127,160,.25); overflow:hidden; }
.tp-bar span { display:block; height:100%; width:0; border-radius:inherit; background:var(--tet-glow); transition:width .3s; }
.tetris-panel.tp-preview { background:linear-gradient(180deg,#1d1946,#100e28); border-color:rgba(255,255,255,.08); }
.tp-preview .tp-label { color:rgba(255,255,255,.62); }
#game-screen[data-game="tetris"] .tp-preview canvas { display:block; width:100%; height:auto; border:0; box-shadow:none; }
#game-screen[data-game="tetris"] .tet-hint { margin-top:2px; }
/* Mouse and keyboard: the on-screen pad is for touch screens only. */
@media (hover:hover) and (pointer:fine) { #game-screen[data-game="tetris"] .tet-btns { display:none; } }
@media (prefers-reduced-motion:reduce) { #tetris-canvas.thud, .tetris-panel .tp-val.bump, #tetris-wrap.danger .tetris-board-frame { animation:none; } }
#next-canvas { display: block; margin: 0 auto; }
.tet-hint { font-size: 11px; color: var(--text2); text-align: center; margin-top: 8px; line-height: 1.6; }
.tet-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.tet-btns .btn { font-size: 18px; padding: 10px; }

/* GAME-SPECIFIC PLAYABILITY */
#game-screen[data-game="memory"] .memory-grid { width:min(100%,380px); }
#game-screen[data-game="reaction"] #reaction-area { border:2px solid var(--border); box-shadow:var(--shadow); }
#game-screen[data-game="quiz"] .quiz-q { border:1px solid var(--border); font-size:18px; }
#game-screen[data-game="hangman"] .keyboard { max-width:520px; margin-inline:auto; }
#game-screen[data-game="hangman"] .key { width:42px; height:42px; font-size:14px; }
#game-screen[data-game="roulette"] .roulette-wrap { background:var(--surface); border:1px solid var(--border); border-radius:20px; padding:16px; }
#game-screen[data-game="shiritori"] .shiri-chain { background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:10px; max-height:150px; overflow:auto; }
#game-screen[data-game="breakout"] #bo-canvas { width:min(100%,400px); cursor:crosshair !important; }
#game-screen[data-game="runner"] #runner-canvas { width:min(100%,480px); }
#game-screen[data-game="shooting"] #shoot-canvas { width:min(100%,420px); }
#game-screen[data-game="pinball"] #pin-canvas { width:min(100%,400px); }
#game-screen[data-game="pinball"] .pin-controls { display:grid; grid-template-columns:1fr 1fr 1fr; gap:8px; width:min(100%,420px); margin:14px auto 0; }
#game-screen[data-game="pinball"] .pin-controls .btn { min-width:0; padding-left:8px; padding-right:8px; }
#game-screen[data-game="snake"] #snake-canvas { width:min(100%,440px); }
#game-screen[data-game="aimtrainer"] #aim-canvas { width:min(100%,560px); }
#game-screen[data-game="fighter"] { max-width:820px; }
#fighter-canvas { width:min(100%,760px); height:auto; aspect-ratio:760/470; display:block; margin:auto; background:#15152c; touch-action:none; border-radius:18px; }
.fighter-controls { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-top:12px; }
.fighter-control-group { display:flex; justify-content:center; gap:7px; padding:9px; background:var(--surface2); border:1px solid var(--border); border-radius:14px; }
.fighter-key { min-width:58px; min-height:52px; padding:8px !important; font-size:16px; touch-action:none; user-select:none; }
.sol-top,.sol-board { width:min(94%,448px); display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); gap:6px; margin-left:auto; margin-right:auto; align-items:start; }
.sol-top { align-items:start; margin-top:14px; margin-bottom:14px; }
.sol-board { min-height:260px; }
.sol-pile { min-width:0; min-height:0; aspect-ratio:.7; border:2px dashed var(--border); border-radius:10px; position:relative; }
.sol-card { width:100%; aspect-ratio:.7; min-height:0; border:2px solid #d8d8df; border-radius:9px; background:#fff; color:#20202b; padding:5px; font:900 clamp(11px,2.4vw,17px)/1 sans-serif; cursor:pointer; position:relative; text-align:left; box-shadow:0 3px 8px rgba(0,0,0,.22); user-select:none; touch-action:manipulation; }
.sol-card.red { color:#d92f43; }
.sol-card > span { position:absolute; top:4px; left:4px; white-space:nowrap; line-height:1; }
.sol-card.back { color:transparent; border-color:#8585b8; background:repeating-linear-gradient(45deg,#343477 0 7px,#4d4da0 7px 14px); }
.sol-card.selected { outline:4px solid var(--accent2); transform:translateY(-3px); z-index:20; }
.sol-tableau .sol-card + .sol-card { margin-top:calc(26px - 100% / .7); }
.sol-tableau .sol-card.back + .sol-card { margin-top:calc(12px - 100% / .7); }
.sol-slot-label { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; color:var(--text2); font-size:23px; pointer-events:none; }
.sol-tableau { min-width:0; display:flex; flex-direction:column; }
.sol-tableau .sol-card { flex-shrink:0; }
.sol-status { min-height:38px; padding:9px 12px; text-align:center; color:var(--text2); font-size:13px; }
#game-screen[data-game="simon"] .simon-board { display:grid; grid-template-columns:repeat(2,minmax(110px,180px)); gap:12px; justify-content:center; margin:18px auto; }
#game-screen[data-game="simon"] .simon-pad { aspect-ratio:1; border:0; border-radius:24px; cursor:pointer; opacity:.68; box-shadow:inset 0 -8px 0 rgba(0,0,0,.2),0 8px 20px rgba(0,0,0,.18); transition:transform .08s,opacity .08s,filter .08s; touch-action:manipulation; }
#game-screen[data-game="simon"] .simon-pad:hover { opacity:.82; }
#game-screen[data-game="simon"] .simon-pad.active { opacity:1; filter:brightness(1.55); transform:scale(.96); box-shadow:0 0 30px var(--pad-color); }
#game-screen[data-game="simon"] .simon-pad:disabled { cursor:default; }
#game-screen[data-game="typing"] .typing-word { font-size:clamp(30px,8vw,54px); font-weight:900; letter-spacing:.06em; text-align:center; padding:24px 12px; margin:16px 0 12px; background:var(--surface); border:1px solid var(--border); border-radius:18px; color:var(--accent2); }
#game-screen[data-game="typing"] .typing-input { width:min(100%,460px); display:block; margin:0 auto; text-align:center; font-size:22px; font-weight:700; letter-spacing:.04em; }
#game-screen[data-game="typing"] .typing-input.wrong { border-color:var(--accent1); color:var(--accent1); animation:shake .18s; }
#game-screen[data-game="typing"] .typing-feedback { height:26px; text-align:center; margin-top:8px; font-weight:800; }
#game-screen[data-game="sokoban"] .sokoban-board { display:grid; width:min(100%,480px); margin:14px auto; padding:8px; gap:3px; background:#172033; border:1px solid var(--border); border-radius:16px; touch-action:none; user-select:none; }
#game-screen[data-game="sokoban"] .sokoban-cell { aspect-ratio:1; display:grid; place-items:center; border-radius:7px; font-size:clamp(18px,6vw,32px); background:#26324a; }
#game-screen[data-game="sokoban"] .sokoban-cell.wall { background:#56627a; box-shadow:inset 0 0 0 2px rgba(255,255,255,.08); }
#game-screen[data-game="sokoban"] .sokoban-cell.goal { background:radial-gradient(circle,#ffd93d 0 18%,#26324a 20%); }
#game-screen[data-game="sokoban"] .sokoban-cell.box { background:#9b673c; box-shadow:inset 0 0 0 3px #d99a57; }
#game-screen[data-game="sokoban"] .sokoban-cell.box.goal { background:#6bcb77; box-shadow:inset 0 0 0 3px #b8f2c0; }
#game-screen[data-game="sokoban"] .sokoban-controls { display:grid; grid-template-columns:repeat(3,58px); gap:6px; justify-content:center; }
#game-screen[data-game="sokoban"] .sokoban-controls .btn { min-width:58px; padding:11px; font-size:20px; }
#game-screen[data-game="reversi"] .reversi-board { display:grid; grid-template-columns:repeat(8,1fr); width:min(100%,500px); margin:14px auto; padding:5px; gap:3px; background:#163e2d; border:2px solid #315b48; border-radius:12px; box-shadow:var(--shadow); }
#game-screen[data-game="reversi"] .reversi-cell { position:relative; aspect-ratio:1; border:0; border-radius:4px; background:#2d9965; cursor:pointer; padding:8%; }
#game-screen[data-game="reversi"] .reversi-cell:hover { background:#37ad75; }
#game-screen[data-game="reversi"] .reversi-cell:disabled { cursor:default; }
#game-screen[data-game="reversi"] .reversi-disc { display:block; width:100%; height:100%; border-radius:50%; box-shadow:inset -4px -5px 8px rgba(0,0,0,.25),0 2px 3px rgba(0,0,0,.35); }
#game-screen[data-game="reversi"] .reversi-disc.black { background:#15171d; }
#game-screen[data-game="reversi"] .reversi-disc.white { background:#f5f5f0; }
#game-screen[data-game="reversi"] .reversi-hint::after { content:''; position:absolute; width:22%; height:22%; border-radius:50%; background:rgba(255,255,255,.5); inset:39%; }
#game-screen[data-game="lightsout"] .lights-board { display:grid; width:min(100%,460px); margin:16px auto; padding:9px; gap:7px; background:#121a2a; border:1px solid var(--border); border-radius:18px; box-shadow:var(--shadow); }
#game-screen[data-game="lightsout"] .light-cell { aspect-ratio:1; border:1px solid #34405a; border-radius:12px; background:#202a3c; cursor:pointer; box-shadow:inset 0 -5px 8px rgba(0,0,0,.24); transition:background .12s,box-shadow .12s,transform .08s; }
#game-screen[data-game="lightsout"] .light-cell:hover { transform:scale(.96); }
#game-screen[data-game="lightsout"] .light-cell.on { background:#ffe66d; border-color:#fff0a2; box-shadow:0 0 18px rgba(255,230,109,.75),inset 0 0 12px #fff5b8; }
#game-screen[data-game="pong"] #pong-canvas { display:block; width:min(100%,640px); margin:14px auto; background:#101728; touch-action:none; cursor:none; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }
.ms-board { display:grid; grid-template-columns:repeat(9,minmax(30px,38px)); gap:4px; justify-content:center; margin-bottom:14px; user-select:none; }
.ms-cell { aspect-ratio:1; background:var(--surface2); border:1px solid var(--border); border-radius:6px; display:flex; align-items:center; justify-content:center; font-weight:900; font-size:16px; cursor:pointer; transition:background .1s,transform .1s; }
.ms-cell:hover { transform:translateY(-1px); border-color:var(--accent4); }
.aim-mode-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-bottom:16px; }
.aim-mode-card { background:var(--surface2); border-radius:var(--radius); padding:16px 14px; cursor:pointer; border:2px solid transparent; transition:all .15s; }
.aim-mode-card:hover { transform:translateY(-2px); box-shadow:var(--shadow); }
.direction-pad { display:grid; grid-template-columns:repeat(3,58px); gap:7px; justify-content:center; margin-top:14px; }
.direction-pad .btn { width:58px; height:52px; padding:0; font-size:18px; touch-action:manipulation; }

/* MISC */
.center { text-align: center; }
.mt { margin-top: 14px; }
.flex-center { display: flex; align-items: center; justify-content: center; gap: 10px; }
.info-row { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.info-box { flex: 1; min-width: 70px; background: var(--surface2); border-radius: var(--radius); padding: 10px; text-align: center; }
.info-box .ib-val { font-size: 20px; font-weight: 900; color: var(--accent2); }
.info-box .ib-label { font-size: 10px; color: var(--text2); }

/* SHARED UI */
.home-banner, .result-box, .modal-box, .info-box, .stat-card, .tetris-panel { border: 1px solid var(--border); box-shadow: 0 8px 22px rgba(0,0,0,.14); }
input:not([type]), input[type="text"], input[type="number"], input[type="search"] { min-height: 42px; }
input:not([type]), input[type="text"], input[type="number"], input[type="search"], textarea {
  background:var(--surface2); border:1px solid var(--border); border-radius:12px;
  color:var(--text); font-family:inherit; padding:10px 13px;
}
input::placeholder, textarea::placeholder { color:var(--text2); opacity:.75; }
#game-screen canvas { border:1px solid var(--border); box-shadow:var(--shadow); }
.game-header { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.game-header h2 { letter-spacing: .02em; }

/* MONSTER BATTLE */
.monster-stage { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-bottom:12px; }
.monster-unit, .battle-log { background:var(--surface2); border:1px solid var(--border); border-radius:var(--radius); padding:14px; }
.monster-unit.enemy { text-align:center; }
.unit-kicker { font-size:12px; color:var(--text2); }
.unit-hp { font-size:22px; font-weight:900; color:var(--accent3); }
.monster-unit.enemy .unit-hp { font-size:18px; color:var(--accent1); }
.unit-meta { font-size:11px; color:var(--text2); margin-top:5px; }
.meter { height:10px; background:var(--surface); border-radius:999px; overflow:hidden; }
.meter.small { height:6px; margin-top:2px; }
.meter-fill { height:100%; border-radius:999px; transition:width .3s; }
.battle-log { min-height:104px; margin-bottom:12px; border-left:3px solid var(--accent4); }
.battle-log-line { font-size:13px; line-height:1.55; }
.skill-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.skill-grid .btn { width:100%; }
.danger-label { color:var(--accent1); font-weight:900; }
.battle-heading { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:8px; }
.stage-badge, .status-chip { border-radius:999px; padding:3px 9px; font-size:10px; font-weight:900; }
.stage-badge { background:var(--accent5); color:#fff; }
.status-row { min-height:25px; display:flex; justify-content:center; gap:5px; flex-wrap:wrap; margin-top:7px; }
.status-chip { background:var(--surface); color:var(--text2); border:1px solid var(--border); }
.status-chip.bad { color:var(--accent1); }
.status-chip.good { color:var(--accent4); }
.enemy-intent { margin-top:8px; padding:6px 9px; border-radius:10px; background:var(--surface); font-size:11px; color:var(--text2); }
.enemy-intent.danger { color:var(--accent1); border:1px solid rgba(255,107,107,.35); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior:auto !important; transition-duration:.01ms !important; animation-duration:.01ms !important; }
}
@media (max-width:520px) {
  #home, #game-screen { padding:14px max(12px,env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left)); }
  #topbar { padding:calc(10px + env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) 10px max(12px,env(safe-area-inset-left)); gap:8px; }
  #topbar h1 { font-size:16px; }
  #topbar-right { gap:5px; flex-wrap:nowrap; }
  .tb-pill { padding:5px 9px; font-size:11px; }
  .tb-profile-btn { width:34px; height:34px; font-size:18px; }
  .games-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  .game-card { padding:15px 12px; border-radius:17px; }
  .game-icon { font-size:30px; margin-bottom:7px; }
  .game-title { font-size:14px; }
  .game-desc { display:none; }
  .game-meta { margin-top:8px; }
  .home-banner { padding:15px; gap:12px; margin-bottom:13px; }
  .home-stats { width:100%; }
  .stat-card { flex:1; padding:8px; }
  .menu-grid, .store-choice { grid-template-columns:1fr; gap:9px; }
  .menu-card, .store-choice .menu-card { min-height:78px; padding:13px; }
  .store-choice .menu-card-icon { width:48px; height:48px; flex-basis:48px; font-size:26px; }
  .monster-stage { grid-template-columns:1fr; }
  .skill-grid, .quiz-options { grid-template-columns:1fr; }
  body { padding-bottom:82px; }
  .app-taskbar { bottom:0; width:100%; gap:1px; padding:6px 4px calc(6px + env(safe-area-inset-bottom)); border-radius:18px 18px 0 0; border-left:0; border-right:0; border-bottom:0; }
  .taskbar-item { min-height:52px; padding:4px 2px; font-size:9px; border-radius:12px; }
  .taskbar-icon { font-size:19px; }
  .app-page { padding:14px; }
  .app-page .page-hero { padding:19px; border-radius:20px; }
  .app-page .page-hero h2 { font-size:22px; }
  .page-content { padding:15px; border-radius:17px; }
  #hub-achievements .achievement-list { grid-template-columns:1fr; }
  .game-browser-top { align-items:stretch; }
  #rules-modal { padding:8px; }
  .rules-grid { grid-template-columns:1fr; }
  .rules-header, .rules-content { padding-left:14px; padding-right:14px; }
  #game-screen[data-game] > .game-header { padding:12px; margin-bottom:14px; }
  #game-screen[data-game] .btn { min-height:46px; }
  .result-box .result-score { font-size:clamp(30px,11vw,48px); }
  .shiri-input-row { flex-direction:column; }
  .shiri-input-row .btn { width:100%; }
  .ms-board { grid-template-columns:repeat(9,minmax(28px,1fr)); gap:3px; width:100%; }
  .ms-cell { font-size:14px; }
  .aim-mode-grid { grid-template-columns:1fr; }
  .aim-mode-card { padding:14px; }
  .direction-pad { grid-template-columns:repeat(3,64px); }
  .direction-pad .btn { width:64px; height:56px; }
  .fighter-controls { grid-template-columns:1fr 1fr; gap:6px; position:sticky; bottom:6px; z-index:4; }
  .fighter-control-group { min-width:0; gap:4px; padding:6px; }
  .fighter-key { min-width:0; min-height:56px; flex:1; padding:5px !important; }
  #game-screen[data-game="fighter"] .tet-hint { display:none; }
  #game-screen[data-game="pinball"] .info-row { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; }
  #game-screen[data-game="pinball"] .info-box { min-width:0; padding:7px 3px; }
  #game-screen[data-game="pinball"] .info-box .ib-val { font-size:16px; }
  #game-screen[data-game="pinball"] #pin-canvas { width:min(100%,calc((100dvh - 275px)*.65625)); min-width:250px; }
  .sol-top,.sol-board { gap:3px; }
  .sol-board { min-height:230px; }
  .sol-pile { border-radius:7px; }
  .sol-card { padding:3px; font-size:11px; border-radius:6px; }
  .sol-card > span { top:3px; left:3px; }
  .sol-tableau .sol-card + .sol-card { margin-top:calc(22px - 100% / .7); }
  .sol-tableau .sol-card.back + .sol-card { margin-top:calc(10px - 100% / .7); }
  .sol-slot-label { font-size:16px; }
}
@media (min-width:521px) and (max-width:900px) { .app-taskbar { width:calc(100% - 28px); } }
@media (max-height:520px) and (orientation:landscape) {
  #topbar { position:relative; padding-top:max(7px,env(safe-area-inset-top)); padding-bottom:7px; }
  #game-screen[data-game] > .game-header { padding:8px 12px; margin-bottom:8px; }
  #game-screen[data-game] > .game-header p { display:none; }
  #game-screen[data-game="fighter"] { padding-top:8px; }
  #game-screen[data-game="fighter"] .fighter-controls { grid-template-columns:1fr 1fr; margin-top:6px; }
  #game-screen[data-game="fighter"] .fighter-key { min-height:46px; }
  #game-screen[data-game="pinball"] #pin-canvas { width:min(44vw,300px); }
}
@media (pointer:coarse) {
  button, .btn, .filter-chip { min-height:44px; }
}

/* STREAK BANNER */
.streak-banner { background: linear-gradient(90deg,#ff6b6b,#ffd93d); color:#111; border-radius:999px; padding:4px 16px; font-size:13px; font-weight:900; text-align:center; margin-bottom:12px; }

/* SAVE MODAL */
#save-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 500; align-items: center; justify-content: center; }
#save-modal.open { display: flex; }
#profile-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.72); z-index:510; align-items:center; justify-content:center; }
#profile-modal.open { display:flex; }
#profile-modal .modal-box { display:flex; flex-direction:column; max-height:calc(100dvh - 32px); overflow:hidden; padding:0; }
.profile-dialog-header { display:flex; align-items:center; gap:12px; padding:18px 20px; border-bottom:1px solid var(--border); flex-shrink:0; }
#profile-modal .profile-dialog-header h3 { flex:1; margin:0; font-size:18px; }
.profile-dialog-close { flex-shrink:0; width:44px; height:44px; border:0; border-radius:12px; background:var(--surface2); color:var(--text); font-size:26px; cursor:pointer; }
#profile-modal-content { overflow-y:auto; min-height:0; padding:20px; overscroll-behavior:contain; }
#profile-modal .modal-btns { margin:0; padding:14px 20px; border-top:1px solid var(--border); flex-shrink:0; background:var(--surface); }
#rules-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.78); z-index:520; align-items:center; justify-content:center; padding:18px; }
#rules-modal.open { display:flex; }
.rules-box { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); width:min(920px,100%); max-height:88vh; display:flex; flex-direction:column; box-shadow:var(--shadow); }
.rules-header { padding:20px 22px 14px; border-bottom:1px solid var(--border); }
.rules-title-row { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px; }
.rules-title-row h2 { font-size:22px; }
.rules-close { width:38px; height:38px; border:none; border-radius:50%; background:var(--surface2); color:var(--text); font-size:20px; cursor:pointer; }
.rules-search { width:100%; }
.rules-content { padding:16px 22px 24px; overflow:auto; }
.rules-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.rule-card { background:var(--surface2); border:1px solid var(--border); border-radius:16px; padding:15px; }
.rule-card-head { display:flex; align-items:center; gap:9px; margin-bottom:10px; }
.rule-card-icon { font-size:28px; }
.rule-card h3 { font-size:15px; }
.rule-tag { color:var(--text2); font-size:10px; }
.rule-section { margin-top:8px; font-size:12px; line-height:1.65; color:var(--text2); }
.rule-section strong { color:var(--text); }
.rules-empty { text-align:center; color:var(--text2); padding:35px; }
.modal-box { background: var(--surface); border-radius: var(--radius-lg); padding: 28px; max-width: 480px; width: 90%; }
.modal-box h3 { font-size: 20px; font-weight: 900; margin-bottom: 16px; }
.modal-textarea { width: 100%; height: 120px; background: var(--surface2); border: 2px solid var(--surface2); border-radius: var(--radius); color: var(--text); font-family: monospace; font-size: 12px; padding: 10px; resize: none; outline: none; }
.modal-textarea:focus { border-color: var(--accent4); }
.modal-btns { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.manual-backup-label { display:block; color:var(--text2); font-size:11px; font-weight:800; margin:4px 0 7px; }

/* BGM PANEL */
#bgm-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 500; align-items: center; justify-content: center; padding:16px; }
#bgm-modal.open { display: flex; }
#bgm-modal .modal-box { position:relative; max-height:calc(100dvh - 32px); overflow-y:auto; overscroll-behavior:contain; scrollbar-gutter:stable; }
.bgm-modal-close { position:sticky; top:0; z-index:3; float:right; width:42px; height:42px; display:grid; place-items:center; margin:-12px -12px 4px 10px; border:1px solid var(--border); border-radius:50%; background:var(--surface2); color:var(--text); font-size:25px; line-height:1; cursor:pointer; box-shadow:var(--shadow); }
.bgm-modal-close:hover { background:var(--accent1); }
.bgm-track { display: flex; align-items: center; gap: 10px; background: var(--surface2); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 8px; cursor: pointer; border: 2px solid transparent; transition: border-color 0.15s; }
.bgm-track:hover { border-color: var(--accent4); }
.bgm-track.active { border-color: var(--accent3); background: var(--good-bg); }
.bgm-track.loading .track-icon { animation:bgmSpin .8s linear infinite; }
.bgm-track.locked { cursor:not-allowed; opacity:.55; filter:grayscale(.7); }
.bgm-track.locked:hover { border-color:transparent; }
@keyframes bgmSpin { to { transform:rotate(360deg); } }
.bgm-track .track-icon { font-size: 22px; width: 32px; text-align: center; flex-shrink: 0; }
.bgm-track .track-info { flex: 1; min-width: 0; }
.bgm-track .track-name { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bgm-track .track-file { font-size: 11px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bgm-track .track-status { font-size: 12px; font-weight: 700; flex-shrink: 0; }
.bgm-vol { width: 100%; accent-color: var(--accent4); margin: 8px 0; }
.bgm-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tb-bgm-btn { background: var(--surface2); color: var(--text); border: none; border-radius: 999px; padding: 6px 14px; font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.tb-bgm-btn:hover { background: var(--border); }
.tb-bgm-btn.playing { background: var(--accent3); color: #111; }
.home-view-bar { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; padding:6px; margin-bottom:28px; background:var(--surface); border:1px solid var(--border); border-radius:16px; }
.home-view-bar button { min-height:52px; padding:10px 8px; border:0; border-radius:11px; background:transparent; color:var(--text2); font:inherit; font-size:14px; font-weight:700; cursor:pointer; }
.home-view-bar button:hover { background:var(--surface2); }
.home-view-bar button[aria-selected="true"] { background:var(--accent4); color:#fff; }
.home-view-panel[hidden], #home-simple[hidden] { display:none; }
.home-view-title { font-size:20px; margin-bottom:18px; }
#library-page > .page-content { max-width:none; padding:0; background:transparent; border:0; box-shadow:none; }
.random-home { padding:40px 20px; text-align:center; background:var(--surface); border:1px solid var(--border); border-radius:20px; }
.random-home-icon { display:block; font-size:56px; margin-bottom:20px; }
.random-home h2 { font-size:24px; }
.random-home p { color:var(--text2); line-height:1.8; margin:16px 0 28px; }
@media (max-width:520px) { .home-view-bar { gap:3px; padding:4px; } .home-view-bar button { font-size:13px; padding:10px 4px; } }
/* Readable browsing: fewer competing details, larger type and calmer surfaces. */
#home { max-width:1100px; margin:0 auto; padding:28px 24px; }
.home-banner { gap:20px; padding:20px 24px; margin-bottom:24px; border:1px solid var(--border); }
.lv-xp-text, .stat-card .s-label { font-size:13px; line-height:1.6; }
.stat-card { background:transparent; padding:8px 16px; }
.stat-card .s-val { color:var(--text); }
.games-grid { grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:20px; }
.game-card { display:flex; flex-direction:column; padding:24px 20px; border-radius:20px; box-shadow:none; }
.game-card::before { display:none; }
.game-card:hover { transform:translateY(-2px); box-shadow:0 8px 24px rgba(0,0,0,.18); }
.game-icon { margin-bottom:18px; padding-right:36px; }
.game-title { font-size:18px; line-height:1.5; margin-bottom:8px; overflow-wrap:anywhere; }
.game-desc { display:block; font-size:14px; line-height:1.7; margin-bottom:20px; }
.game-meta { margin-top:auto; gap:10px; flex-wrap:wrap; }
.game-tag { background:var(--surface2); color:var(--text2); font-size:13px; font-weight:500; padding:5px 10px; }
.game-hs { font-size:13px; }
.game-hs span { color:var(--text); }
.favorite-btn { width:44px; height:44px; background:var(--surface2); }
.game-browser { padding:18px; margin-bottom:24px; }
.game-search { font-size:16px; min-height:44px; }
.game-filter-row { gap:8px; margin-top:14px; }
.app-booting { overflow:hidden; }
#splash-screen {
  position:fixed; inset:0; z-index:3000; display:grid; place-items:center;
  min-height:100dvh; padding:24px; overflow:auto;
  background:
    radial-gradient(circle at 20% 15%,rgba(124,92,255,.35),transparent 32%),
    radial-gradient(circle at 85% 80%,rgba(0,207,255,.22),transparent 34%),
    #070713;
  transition:opacity .42s ease,visibility .42s ease;
}
#splash-screen.dismissed { opacity:0; visibility:hidden; pointer-events:none; }
.splash-card { width:min(520px,100%); text-align:center; }
.splash-logo {
  display:grid; place-items:center; width:112px; height:112px; margin:0 auto 24px;
  border:1px solid rgba(255,255,255,.18); border-radius:32px; font-size:58px;
  background:linear-gradient(145deg,rgba(124,92,255,.85),rgba(190,28,180,.8));
  box-shadow:0 24px 70px rgba(87,51,220,.4),inset 0 1px rgba(255,255,255,.28);
  transform:rotate(-3deg);
}
.splash-eyebrow { color:#83ddff; font-size:13px; font-weight:800; letter-spacing:.18em; text-transform:uppercase; }
.splash-card h1 { margin:9px 0 10px; font-size:clamp(34px,8vw,54px); line-height:1.08; letter-spacing:-.04em; }
.splash-card h1 span { color:#61d9ff; }
.splash-copy { margin:0 auto 28px; color:var(--text2); font-size:15px; line-height:1.8; }
.splash-start {
  width:min(360px,100%); min-height:62px; border:0; border-radius:20px; color:#fff;
  background:linear-gradient(100deg,#6557ef,#c019b2); font:inherit; font-size:18px; font-weight:900;
  box-shadow:0 16px 44px rgba(132,55,225,.36); cursor:pointer;
  transition:transform .16s ease,filter .16s ease;
}
.splash-start:hover { filter:brightness(1.1); transform:translateY(-2px); }
.splash-start:active { transform:translateY(1px) scale(.99); }
.splash-music { margin-top:28px; color:#c9c7dd; font-size:clamp(16px,4vw,18px); font-weight:700; letter-spacing:.02em; }
.filter-chip { min-height:44px; padding:10px 14px; font-size:13px; }
.page-hero { background:var(--surface); }
.page-hero p, .menu-card small, .shop-card p { font-size:14px; line-height:1.7; }
.menu-card { padding:20px; box-shadow:none; }
.menu-card strong { font-size:17px; margin-bottom:6px; }
.meta-sub, .profile-stat span, .privacy-note, .achievement-badge { font-size:13px; line-height:1.6; }
.taskbar-item { font-size:13px; gap:6px; }
.taskbar-item.active { background:var(--surface2); color:var(--nav-active); }
.game-card:focus-visible, button:focus-visible, select:focus-visible { outline:3px solid var(--accent4); outline-offset:3px; }
@media (max-width:520px) {
  #home { padding:20px 16px; }
  #topbar { flex-wrap:wrap; }
  #topbar-right { flex-wrap:wrap; }
  .home-banner { padding:16px; gap:12px; }
  .home-stats { gap:16px; }
  .stat-card { text-align:left; padding:4px 0; }
  .stat-card .s-val { font-size:18px; }
  .games-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
  .game-card { padding:16px 14px; }
  .game-icon { font-size:30px; margin-bottom:16px; }
  .game-title { font-size:16px; }
  .game-desc { display:block; font-size:13px; line-height:1.65; margin-bottom:16px; }
  .game-meta { align-items:flex-start; gap:8px; }
  .game-browser-top { flex-wrap:wrap; }
  .game-search { flex-basis:100%; }
  .taskbar-item { font-size:12px; }
  .app-page { padding:20px 16px; }
}
@media (max-width:359px) {
  .games-grid { grid-template-columns:1fr; }
  .taskbar-item { font-size:11px; }
}
.profile-avatar.frame-emerald { box-shadow:0 0 0 3px #10b981,0 0 18px rgba(16,185,129,.75); }
.profile-avatar.frame-rainbow { animation:secretGlow 1.1s linear infinite; border:2px solid #fff; }
.home-daily-widget { display:grid; grid-template-columns:1.25fr 1fr; gap:14px; margin-bottom:24px; }
@media (max-width:680px) { .home-daily-widget { grid-template-columns:1fr; } }
.pickup-card { display:flex; align-items:center; gap:14px; background:linear-gradient(135deg,rgba(77,150,255,.18),rgba(199,125,255,.14)); border:1px solid rgba(77,150,255,.38); border-radius:20px; padding:16px 18px; cursor:pointer; transition:transform .15s,box-shadow .15s; }
.pickup-card:hover { transform:translateY(-2px); box-shadow:0 10px 26px rgba(0,0,0,.22); }
.pickup-icon { font-size:40px; flex-shrink:0; width:62px; height:62px; display:grid; place-items:center; background:var(--surface); border-radius:16px; border:1px solid var(--border); }
.pickup-body { flex:1; min-width:0; }
.pickup-badge { display:inline-block; background:var(--accent2); color:#111; font-size:11px; font-weight:900; padding:2px 9px; border-radius:999px; margin-bottom:5px; }
.pickup-title { font-size:17px; font-weight:900; margin-bottom:2px; }
.pickup-desc { font-size:12px; color:var(--text2); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.daily-mini-box { background:var(--surface); border:1px solid var(--border); border-radius:20px; padding:15px 18px; display:flex; flex-direction:column; justify-content:center; gap:8px; }
.daily-mini-head { display:flex; justify-content:space-between; align-items:center; font-size:13px; font-weight:800; }
.daily-mini-pills { display:flex; gap:6px; flex-wrap:wrap; }
.daily-mini-pill { font-size:11px; padding:4px 10px; border-radius:999px; background:var(--surface2); color:var(--text2); border:1px solid var(--border); }
.daily-mini-pill.done { background:rgba(107,203,119,.18); color:var(--accent3); border-color:rgba(107,203,119,.45); font-weight:700; }
.game-sort-select { background:var(--surface2); color:var(--text); border:1px solid var(--border); border-radius:12px; padding:0 12px; min-height:44px; font-family:inherit; font-size:13px; font-weight:700; cursor:pointer; }
.card-submeta { display:flex; justify-content:space-between; align-items:center; gap:6px; margin-top:8px; padding-top:8px; border-top:1px solid var(--border); font-size:11px; color:var(--text2); }
.card-mastery { color:var(--accent2); letter-spacing:1px; font-weight:700; }
.game-quick-btn { background:var(--surface2); color:var(--text2); border:1px solid var(--border); border-radius:999px; padding:5px 12px; font-family:inherit; font-size:12px; font-weight:700; cursor:pointer; min-height:34px; }
.game-quick-btn:hover { color:var(--text); border-color:var(--accent4); }
.new-record-badge { display:inline-block; background:linear-gradient(90deg,#ff6b6b,#ffd93d); color:#111; font-weight:900; font-size:12px; padding:4px 12px; border-radius:999px; margin-bottom:8px;  }
.confetti-piece { position:fixed; top:-16px; width:10px; height:14px; border-radius:2px; z-index:2500; pointer-events:none; animation:confettiFall linear forwards; }
/* In-game controls (pause, quit, rules, restart) live in the top bar while a game is open. */
.topbar-game { display:none; align-items:center; gap:6px; }
body.playing-game .topbar-game { display:flex; }
.game-quit-bar { display:flex; gap:6px; }
.game-quit-bar[hidden], .topbar-game .game-quick-btn[hidden] { display:none; }
.topbar-game .game-quick-btn { display:inline-flex; align-items:center; justify-content:center; gap:5px; color:var(--text); white-space:nowrap; }
.game-pickup-line { display:flex; justify-content:center; margin-bottom:8px; }
.game-pickup-line .pickup-badge { margin:0; }
.result-home-btn { background:var(--surface2) !important; color:var(--accent4) !important; }
@keyframes confettiFall { to { transform:translateY(105vh) rotate(720deg); opacity:0; } }
/* NEW GAMES: WHACK-A-MOLE, BLOCK PUZZLE, HIGH-LOW, FRUIT MERGE */
.mole-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; max-width:390px; margin:14px auto; }
.mole-hole { aspect-ratio:1; background:radial-gradient(circle at 50% 72%,#120d1d 36%,var(--surface2) 68%); border:2px solid var(--border); border-radius:22px; display:flex; flex-direction:column; align-items:center; justify-content:center; font-size:clamp(34px,9vw,48px); cursor:pointer; position:relative; overflow:hidden; transition:transform .08s,border-color .12s; touch-action:manipulation; }
.mole-hole:active { transform:scale(.94); }
.mole-hole.up { border-color:var(--accent2); box-shadow:0 0 18px rgba(255,217,61,.22); }
.mole-hole.fever { border-color:var(--accent5); box-shadow:0 0 22px rgba(199,125,255,.35); }
.mole-key-hint { position:absolute; top:6px; left:8px; font-size:10px; color:var(--text2); font-weight:800; opacity:.6; }
.bp-board { display:grid; grid-template-columns:repeat(8,1fr); gap:4px; max-width:380px; margin:12px auto; padding:8px; background:var(--surface2); border:2px solid var(--border); border-radius:16px; }
.bp-cell { aspect-ratio:1; border-radius:6px; background:var(--surface); border:1px solid var(--border); cursor:pointer; transition:background .1s,transform .08s; }
.bp-cell.preview-ok { background:rgba(107,203,119,.45) !important; border-color:var(--accent3); }
.bp-cell.preview-bad { background:rgba(255,107,107,.35) !important; border-color:var(--accent1); }
.bp-tray { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; max-width:420px; margin:14px auto; }
.bp-piece-btn { min-height:94px; background:var(--surface2); border:2px solid var(--border); border-radius:16px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px; padding:10px; cursor:pointer; }
.bp-piece-btn.selected { border-color:var(--accent2); background:rgba(255,217,61,.1); transform:translateY(-3px); }
.bp-piece-btn:disabled { opacity:.3; cursor:default; transform:none; }
.bp-mini-grid { display:grid; gap:2px; }
.bp-mini-cell { width:14px; height:14px; border-radius:3px; }
.hl-stage { display:flex; align-items:center; justify-content:center; gap:18px; margin:18px auto; flex-wrap:wrap; }
.hl-card { width:124px; height:174px; border-radius:16px; background:#fff; color:#181824; border:3px solid #e2e8f0; display:flex; flex-direction:column; align-items:center; justify-content:center; font-size:38px; font-weight:900; box-shadow:0 12px 28px rgba(0,0,0,.32); position:relative; }
.hl-card.red { color:#e11d48; }
.hl-card.back { background:repeating-linear-gradient(45deg,#312e81 0 10px,#4338ca 10px 20px); color:#fff; border-color:#818cf8; }

/* COLOR MODE SWITCH */
.settings-row { max-width:850px; margin:0 auto 16px; display:flex; align-items:center; justify-content:space-between; gap:12px 16px; flex-wrap:wrap; padding:14px 16px; background:var(--surface); border:1px solid var(--border); border-radius:18px; }
.settings-row strong { display:block; font-size:15px; }
.settings-row small { display:block; color:var(--text2); font-size:12px; margin-top:2px; }
#items-page .settings-row { margin:0 0 14px; max-width:none; }
.mode-switch { display:inline-grid; grid-template-columns:repeat(3,auto); gap:4px; padding:4px; background:var(--surface2); border-radius:14px; }
.mode-switch button { min-height:40px; padding:6px 12px; border:0; border-radius:10px; background:transparent; color:var(--text2); font:inherit; font-size:13px; font-weight:700; cursor:pointer; white-space:nowrap; }
.mode-switch button:hover { color:var(--text); }
.mode-switch button.active { background:var(--surface); color:var(--text); box-shadow:0 1px 4px rgba(0,0,0,.18); }
@media (max-width:520px) { .settings-row > div:last-child, .mode-switch { width:100%; } .mode-switch { grid-template-columns:repeat(3,1fr); } }

/* WATER SORT */
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.ws-shelf { --glass:color-mix(in srgb, var(--text) 34%, transparent); --glass-bg:color-mix(in srgb, var(--text) 5%, transparent); max-width:560px; margin:4px auto 0; padding:28px 10px 16px; background:var(--surface); border:1px solid var(--border); border-radius:22px; box-shadow:var(--shadow); }
.ws-board { display:flex; flex-wrap:wrap; justify-content:center; align-items:flex-end; gap:28px 14px; }
.ws-tube { position:relative; width:62px; height:196px; padding:0; border:0; background:none; color:inherit; cursor:pointer; touch-action:manipulation; transition:transform .2s cubic-bezier(.3,1.5,.5,1); -webkit-tap-highlight-color:transparent; }
.ws-tube::before { content:''; position:absolute; top:3px; left:0; right:0; height:9px; border:3px solid var(--glass); border-radius:7px; background:var(--surface); z-index:2; transition:border-color .15s; }
.ws-glass { position:absolute; inset:11px 5px 0; border:3px solid var(--glass); border-top:0; border-radius:3px 3px 30px 30px; background:var(--glass-bg); overflow:hidden; transition:border-color .15s, box-shadow .15s; }
.ws-glass::after { content:''; position:absolute; top:10px; bottom:18px; left:6px; width:5px; border-radius:5px; background:rgba(255,255,255,.4); z-index:2; pointer-events:none; }
.ws-liquid { position:absolute; left:3px; right:3px; bottom:3px; top:6px; display:flex; flex-direction:column-reverse; border-radius:0 0 24px 24px; overflow:hidden; transform-origin:bottom; }
.ws-seg { position:relative; flex:0 0 auto; display:grid; place-items:center; background:linear-gradient(90deg, rgba(0,0,0,.10), transparent 32%, rgba(255,255,255,.22) 62%, rgba(0,0,0,.08)), var(--c); }
.ws-seg + .ws-seg { box-shadow:inset 0 -2px 0 rgba(0,0,0,.08); }
.ws-seg.top::before { content:''; position:absolute; top:-4px; left:-2px; right:-2px; height:8px; border-radius:50%; background:color-mix(in srgb, var(--c) 65%, white); }
.ws-seg b { position:relative; min-width:20px; height:20px; padding:0 4px; display:grid; place-items:center; border-radius:999px; background:rgba(255,255,255,.62); color:#1d1a2b; font-size:12px; font-weight:900; line-height:1; }
.ws-tube[aria-pressed="true"] { transform:translateY(-18px); }
.ws-tube[aria-pressed="true"]::before, .ws-tube[aria-pressed="true"] .ws-glass { border-color:var(--accent2); }
.ws-tube[aria-pressed="true"] .ws-glass { box-shadow:0 0 0 4px color-mix(in srgb, var(--accent2) 28%, transparent), 0 12px 24px rgba(0,0,0,.18); }
.ws-tube.done::before, .ws-tube.done .ws-glass { border-color:var(--accent3); }
.ws-check { position:absolute; top:-16px; left:50%; width:24px; height:24px; margin-left:-12px; border-radius:50%; background:var(--accent3); color:#fff; font-size:14px; font-weight:900; display:grid; place-items:center; z-index:3; animation:wsPop .35s cubic-bezier(.3,1.6,.5,1) both; }
.ws-tube.pour-in .ws-liquid { animation:wsSlosh .45s ease; }
.ws-tube.pour-out { animation:wsTilt .35s ease; }
.ws-tube.shake { animation:shake .25s; }
.ws-tube:disabled { cursor:default; }
.ws-tube:focus-visible { outline:3px solid var(--accent4); outline-offset:5px; border-radius:14px; }
@keyframes wsSlosh { 0% { transform:scaleY(.93); } 55% { transform:scaleY(1.03); } 100% { transform:none; } }
@keyframes wsTilt { 0% { transform:translateY(-18px) rotate(-12deg); } 100% { transform:none; } }
@keyframes wsPop { from { transform:scale(0); } to { transform:scale(1); } }
.ws-status { min-height:44px; max-width:440px; margin:14px auto 10px; padding:10px 14px; display:grid; place-items:center; text-align:center; line-height:1.5; border-radius:14px; background:var(--surface2); color:var(--text2); font-size:14px; font-weight:700; }
.ws-status[data-tone="good"] { background:var(--good-bg); color:var(--accent3); }
.ws-status[data-tone="bad"] { background:var(--bad-bg); color:var(--accent1); }
.ws-controls { flex-wrap:wrap; }
#ws-next[hidden] { display:none; }
@media (max-width:520px) {
  .ws-shelf { padding:26px 4px 12px; border-radius:18px; }
  .ws-board { gap:26px 8px; }
  .ws-tube { width:54px; height:176px; }
  .ws-board[data-count="8"] .ws-tube, .ws-board[data-count="9"] .ws-tube { width:50px; height:162px; }
}
@media (prefers-reduced-motion:reduce) { .ws-tube { transition:none; } }
/* PIN PULL */
.pin-progress { max-width:400px; margin:0 auto 10px; text-align:center; font-weight:800; color:var(--text2); }
.pin-board { max-width:400px; margin:0 auto; }
.pin-board svg { display:block; width:100%; height:auto; filter:drop-shadow(0 12px 24px rgba(0,0,0,.25)); }
.pin-action { cursor:pointer; touch-action:manipulation; outline:none; }
.pin-action .pin-knob { transition:filter .12s; }
.pin-action:hover .pin-knob { filter:brightness(1.12) drop-shadow(0 0 6px rgba(255,216,77,.8)); }
.pin-action:focus-visible .pin-hit { stroke:#fff; stroke-width:3; }
.pin-action[aria-disabled="true"] { cursor:default; }
.pin-particle { pointer-events:none; }
.pin-flowline { animation:pinFlow .9s linear infinite; }
@keyframes pinFlow { to { stroke-dashoffset:-13; } }
.pin-danger { animation:pinDanger .6s ease-in-out infinite alternate; }
@keyframes pinDanger { to { stroke-width:6; } }
.pin-status { min-height:48px; max-width:420px; margin:12px auto 10px; padding:10px 14px; display:grid; place-items:center; text-align:center; line-height:1.5; border-radius:14px; background:var(--surface2); color:var(--text2); font-size:14px; font-weight:700; }
.pin-status[data-tone="good"] { background:var(--good-bg); color:var(--accent3); }
.pin-status[data-tone="bad"] { background:var(--bad-bg); color:var(--accent1); }
.pin-controls { display:flex; justify-content:center; gap:8px; flex-wrap:wrap; }
#pin-next[hidden] { display:none; }
@media (prefers-reduced-motion:reduce) { .pin-flowline, .pin-danger { animation:none; } }
/* FIGHTER */
.fighter-vs { display:flex; align-items:center; justify-content:center; gap:16px; margin-bottom:12px; }
.fighter-vs .fv { display:grid; place-items:center; width:78px; height:78px; border-radius:20px; font-size:34px; color:#fff; box-shadow:var(--shadow); }
.fighter-vs .fv b { font-size:12px; letter-spacing:.08em; }
.fighter-vs .fv.blue { background:linear-gradient(135deg,#3d8bff,#1d4fae); }
.fighter-vs .fv.red { background:linear-gradient(135deg,#ff5a5a,#a3232c); transform:scaleX(-1); }
.fighter-vs .fv.red b { transform:scaleX(-1); }
.fighter-vs strong { font-size:28px; font-weight:900; color:var(--accent2); }
#game-screen[data-game="fighter"] .fighter-control-group { background:var(--surface); border-radius:18px; box-shadow:var(--shadow); }
.fighter-key { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:0; font-size:20px; border-radius:14px; box-shadow:inset 0 -4px 0 rgba(0,0,0,.18); transition:transform .06s; }
.fighter-key small { font-size:11px; font-weight:900; line-height:1; }
.fighter-key:active, .fighter-key.held { transform:translateY(2px) scale(.97); box-shadow:inset 0 -1px 0 rgba(0,0,0,.18); }
.fk-move { background:var(--surface2); color:var(--text); }
.fk-light { background:linear-gradient(180deg,#4fd18b,#2b9a5c); }
.fk-heavy { background:linear-gradient(180deg,#ff7a6b,#d8343a); }
.fk-guard { background:linear-gradient(180deg,#7cc4ff,#3b82f6); }
@media (max-width:520px) { .fighter-key { min-height:64px !important; } }
.runner-jump { min-width:180px; min-height:56px !important; font-size:18px; border-radius:16px; box-shadow:inset 0 -4px 0 rgba(0,0,0,.18); }
#game-screen[data-game="runner"] #runner-canvas { width:100%; box-shadow:var(--shadow); }
/* BOARD & CARD GAME POLISH */
.ms-cell { background:linear-gradient(160deg, color-mix(in srgb, var(--accent4) 22%, var(--surface2)), var(--surface2)); border:1px solid var(--border); box-shadow:inset 0 2px 0 rgba(255,255,255,.12), inset 0 -3px 0 rgba(0,0,0,.18); }
.ms-cell.open { background:var(--surface); box-shadow:inset 0 1px 3px rgba(0,0,0,.18); border-color:transparent; }
.ms-cell.open:hover { transform:none; }
.ms-cell.boom { background:var(--bad-bg); }
.ms-n1 { color:#3b82f6; } .ms-n2 { color:#22a05a; } .ms-n3 { color:#ef4444; } .ms-n4 { color:#8b5cf6; } .ms-n5 { color:#ea7a12; } .ms-n6 { color:#0ea5a5; } .ms-n7, .ms-n8 { color:var(--text); }
:root:not([data-mode="light"]) .ms-n1 { color:#7cb4ff; } :root:not([data-mode="light"]) .ms-n2 { color:#6fdc94; } :root:not([data-mode="light"]) .ms-n3 { color:#ff8080; } :root:not([data-mode="light"]) .ms-n4 { color:#c4a2ff; }
.mem-card { background:repeating-linear-gradient(45deg, rgba(255,255,255,.10) 0 6px, transparent 6px 12px), linear-gradient(135deg, var(--accent4), var(--accent5)); border:3px solid rgba(255,255,255,.35); box-shadow:0 6px 14px rgba(0,0,0,.18); color:#fff; }
.mem-card .mem-front { font-size:0; } .mem-card .mem-front::after { content:'?'; font-size:24px; font-weight:900; color:rgba(255,255,255,.9); }
.mem-card.flipped { background:var(--surface); border-color:var(--accent4); animation:memFlip .28s ease both; }
.mem-card.matched { background:var(--good-bg); border-color:var(--accent3); animation:memMatch .35s ease both; box-shadow:none; }
@keyframes memFlip { from { transform:rotateY(90deg); } to { transform:none; } }
@keyframes memMatch { 50% { transform:scale(1.12); } }
#game-screen[data-game="quiz"] .quiz-options { counter-reset:qopt; }
.quiz-opt { position:relative; display:flex; align-items:center; gap:10px; text-align:left; padding-left:12px; box-shadow:inset 0 -3px 0 rgba(0,0,0,.08); }
.quiz-opt::before { counter-increment:qopt; content:counter(qopt, upper-alpha); flex:0 0 28px; height:28px; display:grid; place-items:center; border-radius:9px; background:var(--surface); color:var(--accent4); font-weight:900; font-size:13px; }
.quiz-opt.correct::before { content:'✓'; background:var(--accent3); color:#fff; }
.quiz-opt.wrong::before { content:'✕'; background:var(--accent1); color:#fff; }
.key { background:var(--surface); border:1px solid var(--border); box-shadow:inset 0 -3px 0 rgba(0,0,0,.15); transition:transform .06s, background .1s; }
.key:active:not(:disabled) { transform:translateY(2px); box-shadow:none; }
.monster-unit.enemy { background:radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--accent5) 14%, var(--surface2)), var(--surface2) 70%); }
.monster-sprite { width:112px; height:112px; margin:2px auto 6px; display:grid; place-items:center; font-size:66px; line-height:1; border-radius:50%; background:radial-gradient(circle, color-mix(in srgb, var(--mc) 38%, transparent), transparent 68%); animation:monsterBob 2.2s ease-in-out infinite; filter:drop-shadow(0 8px 10px rgba(0,0,0,.25)); }
@keyframes monsterBob { 50% { transform:translateY(-6px) scale(1.03); } }
#reaction-area { flex-direction:column; gap:10px; text-align:center; padding:16px; }
#reaction-area::before { content:'👆'; font-size:54px; line-height:1; }
#reaction-area.wait::before { content:'⏳'; }
#reaction-area.go::before { content:'⚡'; animation:reactPulse .5s ease-in-out infinite alternate; }
#reaction-area.go { box-shadow:0 0 0 4px var(--accent3), 0 0 40px color-mix(in srgb, var(--accent3) 45%, transparent); }
@keyframes reactPulse { to { transform:scale(1.25); } }
.playing-card { border-radius:10px; box-shadow:0 6px 14px rgba(0,0,0,.22); border:1px solid #e3e3ea; background:linear-gradient(180deg,#ffffff,#f1f1f6); }
.playing-card.hidden { background:repeating-linear-gradient(45deg,#3d4fd1 0 6px,#5466e6 6px 12px); border:3px solid #fff; color:transparent; }
.chip { box-shadow:0 4px 0 rgba(0,0,0,.25), inset 0 0 0 4px rgba(255,255,255,.35); border-style:dashed; }
@media (prefers-reduced-motion:reduce) { .monster-sprite, #reaction-area.go::before { animation:none; } }
.hangman-svg { width:220px; height:auto; padding:10px; background:linear-gradient(180deg, color-mix(in srgb, var(--accent4) 10%, var(--surface)), var(--surface)); border:1px solid var(--border); border-radius:20px; box-shadow:var(--shadow); }
.hangman-svg line[stroke="var(--text2)"] { stroke:#a8744f; stroke-width:7; stroke-linecap:round; }
.hangman-svg line[stroke="var(--accent1)"], .hangman-svg circle[stroke="var(--accent1)"] { stroke-width:5; stroke-linecap:round; }
.word-hint { display:flex; justify-content:center; flex-wrap:wrap; gap:6px; letter-spacing:0; }
.hm-slot { width:34px; height:42px; display:grid; place-items:center; border-radius:10px; background:var(--surface2); border-bottom:4px solid var(--border); font-size:24px; font-weight:900; text-transform:uppercase; }
.hm-slot.on { background:var(--good-bg); border-bottom-color:var(--accent3); color:var(--accent3); animation:wsPop .25s ease both; }
/* Square board cells must not inherit the 44px touch minimum, or 8-wide boards overflow phones. */
#game-screen[data-game="reversi"] .reversi-cell, #game-screen[data-game="lightsout"] .light-cell, .ws-tube, .bp-cell, .mole-hole, .sdk-cell { min-height:0 !important; }
#game-screen[data-game="reversi"] .reversi-board { box-shadow:0 12px 26px rgba(0,0,0,.3), inset 0 0 0 3px rgba(0,0,0,.18); border-radius:16px; }
.golf-status { max-width:360px; margin:0 auto 10px; padding:8px 12px; border-radius:14px; background:var(--surface2); color:var(--text); text-align:center; font-size:13px; font-weight:700; line-height:1.5; }
.golf-course { border-radius:18px; border:4px solid #8a5a32; box-shadow:var(--shadow); }
.golf-controls { max-width:360px; margin:14px auto; display:grid; gap:12px; padding:14px; background:var(--surface); border:1px solid var(--border); border-radius:18px; box-shadow:var(--shadow); color:var(--text); font-size:13px; font-weight:700; }
.golf-controls output { color:var(--accent2); font-weight:900; }
.golf-controls input[type=range] { accent-color:var(--accent3); }
/* SOLITAIRE FELT */
#game-screen[data-game="solitaire"] .sol-top, #game-screen[data-game="solitaire"] .sol-board { width:min(100%,468px); background:radial-gradient(ellipse at 50% 0%, #2b8a5a, #1b5e3d 75%); }
#game-screen[data-game="solitaire"] .sol-top { padding:14px 10px 10px; margin-bottom:0; border-radius:20px 20px 0 0; box-shadow:0 -1px 0 rgba(255,255,255,.08) inset; }
#game-screen[data-game="solitaire"] .sol-board { padding:8px 10px 18px; border-radius:0 0 20px 20px; box-shadow:var(--shadow); }
#game-screen[data-game="solitaire"] .sol-pile { border-color:rgba(255,255,255,.28); background:rgba(0,0,0,.12); }
#game-screen[data-game="solitaire"] .sol-slot-label { color:rgba(255,255,255,.55); }
.sol-card { border-color:#e2e2ea; background:linear-gradient(180deg,#ffffff,#f3f3f8); }
.sol-card.back { background:repeating-linear-gradient(45deg,#c0392b 0 6px,#d9534f 6px 12px); border:2px solid #fff; }
/* SOKOBAN WAREHOUSE */
#game-screen[data-game="sokoban"] .sokoban-board { background:#1b2233; border:3px solid #39445e; }
#game-screen[data-game="sokoban"] .sokoban-cell { background:#2c3650; box-shadow:inset 0 0 0 1px rgba(255,255,255,.04); font-size:clamp(20px,7vw,34px); }
#game-screen[data-game="sokoban"] .sokoban-cell.wall { background-color:#9c5a43; background-image:linear-gradient(rgba(0,0,0,.28) 2px, transparent 2px), linear-gradient(90deg, rgba(0,0,0,.28) 2px, transparent 2px), linear-gradient(90deg, transparent 50%, rgba(0,0,0,.28) 50%, rgba(0,0,0,.28) calc(50% + 2px), transparent calc(50% + 2px)); background-size:100% 50%, 50% 50%, 100% 100%; background-position:0 0, 25% 0, 0 50%; box-shadow:inset 0 3px 0 rgba(255,255,255,.15); }
#game-screen[data-game="sokoban"] .sokoban-cell.goal { background:radial-gradient(circle, #ffd93d 0 14%, rgba(255,217,61,.35) 16% 30%, #2c3650 32%); }
#game-screen[data-game="sokoban"] .sokoban-cell.box { background:#c98b4f; box-shadow:inset 0 0 0 3px #e0a86c, inset 0 0 0 5px #8a5a32; }
#game-screen[data-game="sokoban"] .sokoban-cell.box.goal { background:#4cc070; box-shadow:inset 0 0 0 3px #a6f0bd, 0 0 14px rgba(76,192,112,.55); }
/* 2048 TILES (same bright palette in both modes) */
#game-screen .slide-grid { background:color-mix(in srgb, var(--text) 10%, var(--surface2)); }
#game-screen .slide-cell { background:color-mix(in srgb, var(--text) 5%, var(--surface)); box-shadow:inset 0 -4px 0 rgba(0,0,0,.12); color:#1b1b2b; }
#game-screen .slide-cell[data-v="2"] { background:#bfe6ff; color:#1b3a5c; }
#game-screen .slide-cell[data-v="4"] { background:#b6f0c8; color:#14532d; }
#game-screen .slide-cell[data-v="8"] { background:#ffe27a; color:#5c4300; }
#game-screen .slide-cell[data-v="16"] { background:#ffbe7a; color:#6b2e00; }
#game-screen .slide-cell[data-v="32"] { background:#ff9566; color:#fff; }
#game-screen .slide-cell[data-v="64"] { background:#ff6b6b; color:#fff; }
#game-screen .slide-cell[data-v="128"] { background:#f472b6; color:#fff; }
#game-screen .slide-cell[data-v="256"] { background:#c084fc; color:#fff; }
#game-screen .slide-cell[data-v="512"] { background:#818cf8; color:#fff; }
#game-screen .slide-cell[data-v="1024"] { background:#4f8cff; color:#fff; }
#game-screen .slide-cell[data-v="2048"] { background:linear-gradient(135deg,#ffe066,#ffb020); color:#fff; box-shadow:0 0 20px rgba(255,190,40,.6); text-shadow:0 1px 2px rgba(0,0,0,.25); }
/* PUZZLE RESUME */
.puzzle-resume { display:flex; align-items:center; justify-content:space-between; gap:10px 14px; flex-wrap:wrap; margin:0 auto 14px; max-width:560px; padding:12px 14px; background:var(--good-bg); border:1px solid var(--accent3); border-radius:16px; }
.puzzle-resume strong { display:block; font-size:15px; }
.puzzle-resume small { display:block; color:var(--text2); font-size:12px; margin-top:2px; }
.puzzle-resume-btns { display:flex; gap:8px; flex-wrap:wrap; }
@media (max-width:520px) { .puzzle-resume-btns { width:100%; } .puzzle-resume-btns .btn { flex:1; } }
/* NEW GAMES: PLAY UI */
.mole-hole { color:var(--text); font-family:inherit; padding:0; }
.mole-face { position:relative; display:block; line-height:1; opacity:0; transform:translateY(60%) scale(.7); transition:transform .1s ease-out,opacity .1s; pointer-events:none; }
.mole-hole.up .mole-face, .mole-hole.hit .mole-face { opacity:1; transform:none; }
.mole-hole.hit .mole-face { transform:scale(.8) rotate(-14deg); filter:saturate(.6); }
.mole-hole.bomb.up { border-color:var(--accent1); }
.mole-crown { position:absolute; left:50%; top:-.45em; transform:translateX(-50%); font-size:.5em; }
.mole-pop { position:absolute; top:8px; right:10px; font-size:15px; font-weight:900; color:var(--accent3); pointer-events:none; animation:molePop .5s ease-out both; }
.mole-pop.bad { color:var(--accent1); }
@keyframes molePop { from { opacity:1; transform:translateY(0); } to { opacity:0; transform:translateY(-16px); } }
.mole-legend { display:flex; gap:8px; justify-content:center; flex-wrap:wrap; margin-bottom:12px; }
.mole-legend span { background:var(--surface); border:1px solid var(--border); border-radius:999px; padding:5px 11px; font-size:13px; font-weight:700; }
.hl-card { gap:2px; }
.hl-card .hl-suit { font-size:28px; line-height:1; }
.hl-corner { position:absolute; top:8px; left:10px; font-size:14px; line-height:1.1; text-align:center; }
.hl-arrow { font-size:26px; color:var(--text2); font-weight:900; }
#hl-flip { animation:hlFlip .35s ease both; }
@keyframes hlFlip { from { transform:rotateY(90deg); } to { transform:none; } }
.hl-actions { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; max-width:460px; margin:12px auto 8px; }
.hl-actions .btn { display:flex; flex-direction:column; align-items:center; gap:2px; padding:10px 6px; }
.hl-actions small { font-size:11px; font-weight:700; opacity:.85; }
.hl-drop { display:block; width:100%; max-width:460px; margin:0 auto; }
.hl-history { display:flex; flex-wrap:wrap; gap:5px; justify-content:center; margin-top:12px; min-height:26px; }
.hl-history span { padding:3px 8px; border-radius:999px; font-size:12px; font-weight:800; background:var(--good-bg); color:var(--accent3); }
.hl-history span.ng { background:var(--bad-bg); color:var(--accent1); }
.bp-cell.filled { box-shadow:inset 0 -3px 0 rgba(0,0,0,.18); border-color:transparent; }
.bp-piece-btn { color:var(--text2); font-family:inherit; }
.bp-piece-btn small { font-size:11px; font-weight:700; }
.fm-canvas { display:block; width:min(100%,360px); height:auto; margin:0 auto; border-radius:14px; touch-action:none; cursor:pointer; }
@media (max-width:520px) {
  .mole-grid { gap:8px; }
  .hl-card { width:104px; height:146px; font-size:32px; }
  .hl-stage { gap:10px; margin:12px auto; }
  .bp-tray { gap:8px; }
  .bp-piece-btn { min-height:86px; padding:8px 4px; }
}

/* PHONE LAYOUT */
.stat-card { border:0; box-shadow:none; }
@media (max-width:520px) {
  /* One-row top bar: drop the site title while the back button is showing. */
  #topbar, #topbar-right { flex-wrap:nowrap; }
  body.has-back #topbar h1 { display:none; }
  .back-btn { padding:8px 12px; white-space:nowrap; }
  /* Compact 3-column game list so more games fit on screen. */
  .games-grid { grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
  .game-card { padding:14px 6px 10px; border-radius:16px; align-items:center; text-align:center; }
  .game-icon { font-size:32px; margin:4px 0 8px; padding:0; }
  .game-title { font-size:13px; line-height:1.35; margin-bottom:6px; }
  .game-desc, .game-tag { display:none; }
  .game-meta { justify-content:center; margin-top:auto; }
  .game-hs { font-size:11px; }
  .favorite-btn { top:4px; right:4px; width:28px; height:28px; min-height:0; font-size:13px; background:transparent; border-color:transparent; }
  .favorite-btn.active { background:transparent; }
  .home-view-bar { margin-bottom:20px; }
  /* Tetris: board shrinks to fit beside the side panel. */
}
@media (max-width:359px) { .games-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } }

/* LIGHT MODE ADJUSTMENTS */
:root[data-mode="light"] #splash-screen { background:radial-gradient(circle at 20% 15%,rgba(124,92,255,.22),transparent 34%),radial-gradient(circle at 85% 80%,rgba(0,170,230,.16),transparent 36%),#f6f5fc; }
:root[data-mode="light"] .splash-eyebrow { color:#1f7fb8; }
:root[data-mode="light"] .splash-card h1 span { color:#1a8fd0; }
:root[data-mode="light"] .splash-music { color:var(--text2); }
:root[data-mode="light"] .slide-cell[data-v="2"] { background:#e6f4d4; color:#3f7a12; }
:root[data-mode="light"] .slide-cell[data-v="4"] { background:#fbe8cf; color:#a35a00; }
:root[data-mode="light"] .slide-cell[data-v="8"] { background:#fde0e0; color:#c0353b; }
:root[data-mode="light"] .slide-cell[data-v="16"] { background:#dcefff; color:#1767b0; }
:root[data-mode="light"] .slide-cell[data-v="32"] { background:#efe3ff; color:#7a35c4; }
:root[data-mode="light"] .slide-cell[data-v="64"] { background:#fde2f3; color:#b02d83; }
:root[data-mode="light"] .slide-cell[data-v="128"] { background:#d6f2dd; color:#22803f; }
:root[data-mode="light"] .game-card:hover, :root[data-mode="light"] .pickup-card:hover { box-shadow:0 8px 24px rgba(40,34,90,.12); }
:root[data-mode="light"] .home-banner, :root[data-mode="light"] .result-box, :root[data-mode="light"] .modal-box, :root[data-mode="light"] .info-box, :root[data-mode="light"] .stat-card, :root[data-mode="light"] .tetris-panel { box-shadow:0 4px 14px rgba(40,34,90,.06); }

/* HIT & BLOW */
.hb-h { color:#fff; background:#ef4b5c; }
.hb-b { color:#1d1a2b; background:#ffd24d; }
.hb-howto { max-width:440px; margin:0 auto 14px; padding:14px 16px; display:grid; gap:8px; background:var(--surface); border:1px solid var(--border); border-radius:18px; font-size:14px; line-height:1.5; }
.hb-howto b, .hb-score b { display:inline-block; min-width:36px; padding:2px 8px; margin-right:6px; border-radius:999px; font-size:12px; font-weight:900; text-align:center; }
.hb-howto small { color:var(--text2); font-size:12px; }
.hb-modes { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; max-width:440px; margin:0 auto; }
.hb-mode { display:flex; flex-direction:column; align-items:center; gap:6px; padding:18px 10px; border:2px solid var(--mc); border-radius:20px; background:var(--surface); color:var(--text); font:inherit; cursor:pointer; box-shadow:var(--shadow); transition:transform .12s; }
.hb-mode:hover { transform:translateY(-2px); }
.hb-mode strong { font-size:17px; }
.hb-mode small { color:var(--text2); font-size:12px; }
.hb-mode-digits { display:flex; gap:4px; }
.hb-mode-digits i { width:26px; height:32px; display:grid; place-items:center; border-radius:8px; background:var(--mc); color:#fff; font-style:normal; font-weight:900; }
.hb-history { max-width:440px; max-height:min(38vh,300px); overflow-y:auto; margin:0 auto 12px; padding:6px; display:grid; gap:6px; background:var(--surface); border:1px solid var(--border); border-radius:18px; }
.hb-empty { padding:16px; text-align:center; color:var(--text2); font-size:13px; }
.hb-row { display:flex; align-items:center; gap:10px; padding:8px 10px; border-radius:12px; background:var(--surface2); animation:wsPop .25s ease both; }
.hb-row.win { background:var(--good-bg); box-shadow:inset 0 0 0 2px var(--accent3); }
.hb-no { width:22px; color:var(--text2); font-size:12px; font-weight:800; text-align:right; }
.hb-digits { display:flex; gap:4px; }
.hb-digits i { width:30px; height:34px; display:grid; place-items:center; border-radius:8px; background:var(--surface); font-style:normal; font-size:18px; font-weight:900; }
.hb-digits i.m1 { opacity:.4; text-decoration:line-through; }
.hb-digits i.m2 { color:var(--accent3); box-shadow:inset 0 0 0 2px var(--accent3); }
.hb-pegs { display:grid; grid-template-columns:repeat(2,10px); gap:3px; margin-left:auto; }
.hb-pegs i { width:10px; height:10px; border-radius:50%; background:color-mix(in srgb, var(--text) 15%, transparent); }
.hb-pegs i.h { background:#ef4b5c; } .hb-pegs i.b { background:#ffd24d; }
.hb-score { display:flex; gap:4px; } .hb-score b { margin:0; min-width:34px; }
.hb-entry { display:flex; justify-content:center; gap:8px; margin:6px auto 4px; }
.hb-slot { width:52px; height:62px; display:grid; place-items:center; border-radius:14px; background:var(--surface); border:2px solid var(--border); font-size:30px; font-weight:900; }
.hb-slot.cur { border-color:var(--accent4); box-shadow:0 0 0 4px color-mix(in srgb, var(--accent4) 22%, transparent); }
.hb-slot.on { border-color:var(--accent2); animation:wsPop .2s ease both; }
.hb-entry.shake { animation:shake .25s; }
.hb-status { min-height:40px; max-width:440px; margin:8px auto; padding:8px 12px; display:grid; place-items:center; border-radius:12px; background:var(--surface2); color:var(--text2); text-align:center; font-size:14px; font-weight:700; }
.hb-status[data-tone="good"] { background:var(--good-bg); color:var(--accent3); }
.hb-status[data-tone="bad"] { background:var(--bad-bg); color:var(--accent1); }
.hb-pad { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:8px; max-width:440px; margin:0 auto; }
.hb-key { min-height:52px !important; border:1px solid var(--border); border-radius:14px; background:var(--surface); color:var(--text); font:inherit; font-size:22px; font-weight:900; cursor:pointer; box-shadow:inset 0 -4px 0 rgba(0,0,0,.14); touch-action:manipulation; }
.hb-key:active:not(:disabled) { transform:translateY(2px); box-shadow:none; }
.hb-key:disabled { opacity:.35; cursor:default; }
.hb-key.m1 { color:var(--text2); text-decoration:line-through; }
.hb-key.m2 { box-shadow:inset 0 0 0 2px var(--accent3), inset 0 -4px 0 rgba(0,0,0,.14); color:var(--accent3); }
.hb-key.hb-del { grid-column:span 2; font-size:20px; }
.hb-key.hb-go { grid-column:span 3; background:var(--accent4); color:#fff; border-color:transparent; font-size:18px; }
.hb-memo-wrap { max-width:440px; margin:14px auto 0; padding:10px 12px; background:var(--surface); border:1px solid var(--border); border-radius:16px; }
.hb-memo-title { font-size:13px; font-weight:800; margin-bottom:8px; } .hb-memo-title small { color:var(--text2); font-weight:500; }
.hb-memo { display:grid; grid-template-columns:repeat(10,minmax(0,1fr)); gap:4px; }
.hb-memo-key { min-height:44px !important; padding:0; border:1px solid var(--border); border-radius:10px; background:var(--surface2); color:var(--text); font:inherit; font-weight:900; font-size:15px; line-height:1.1; cursor:pointer; display:flex; flex-direction:column; align-items:center; justify-content:center; }
.hb-memo-key small { font-size:11px; min-height:12px; }
.hb-memo-key.m1 { background:var(--bad-bg); color:var(--accent1); }
.hb-memo-key.m2 { background:var(--good-bg); color:var(--accent3); }
.hb-answer { display:flex; justify-content:center; gap:8px; margin:8px 0; }
.hb-answer span { width:46px; height:56px; display:grid; place-items:center; border-radius:12px; background:var(--accent2); color:#1d1a2b; font-size:28px; font-weight:900; animation:wsPop .3s ease both; }
@media (max-width:520px) { .hb-slot { width:46px; height:56px; font-size:26px; } .hb-digits i { width:26px; height:30px; font-size:16px; } .hb-row { gap:8px; padding:7px 8px; } }
.hb-result-answer { margin:4px 0 12px; display:grid; justify-items:center; gap:2px; color:var(--text2); font-size:12px; font-weight:700; }

/* Keyboard and touch support shared by games (see js/input.js). */
[role="button"], [data-nav] { -webkit-tap-highlight-color:transparent; touch-action:manipulation; }
[role="button"]:focus-visible, [data-nav]:focus-visible, .chip:focus-visible { outline:3px solid var(--accent4); outline-offset:2px; z-index:1; }
.kbd-hint { font-size:12px; color:var(--text2); }
.kbd-hint kbd { display:inline-block; min-width:1.7em; padding:1px 5px; border:1px solid var(--border); border-bottom-width:2px; border-radius:6px; background:var(--surface); font:700 11px/1.4 ui-monospace,monospace; text-align:center; }
@media (hover:none) and (pointer:coarse) { .kbd-hint { display:none; } }

/* ===== Mobile usability pass ===== */
/* While a game runs, swipes must not trigger pull-to-refresh or rubber-band scrolling. */
html:has(body.playing-game), body.playing-game { overscroll-behavior-y:none; }
/* Notices never take taps, and during a game they sit under the top bar instead of over the controls. */
#lvup-toast { pointer-events:none; }
body.playing-game #lvup-toast { top:calc(76px + env(safe-area-inset-top)); bottom:auto; }
/* Option rows wrap instead of squeezing labels into one character per line ("かんた/ん"). */
#game-screen .flex-center { flex-wrap:wrap; }
#game-screen .btn { word-break:keep-all; overflow-wrap:anywhere; }
/* Hold-to-repeat buttons (data-repeat, see js/input.js) show that they are being held. */
.btn[data-repeat] { touch-action:none; }
.btn.is-held { transform:scale(.95); filter:brightness(1.15); }
/* Tetris: one full-width pad under the board, thumb-sized on phones. */
.tet-btns { grid-template-columns:repeat(6,minmax(0,1fr)); width:min(100%,460px); margin:12px auto 0; }
.tet-btns .btn { min-width:0; min-height:52px; padding:8px 0; font-size:22px; }
.tet-touch-hint { display:none; margin-top:6px; text-align:center; font-size:11px; color:var(--text2); }
@media (hover:none) and (pointer:coarse) { .tet-touch-hint { display:block; } }
/* The main action of betting games stays reachable while the player scrolls the options. */
.sticky-actions { display:flex; gap:8px; justify-content:center; flex-wrap:wrap; margin-top:10px; }
@media (max-width:520px) {
  .sticky-action, .sticky-actions { position:sticky; bottom:calc(10px + env(safe-area-inset-bottom)); z-index:6; }
  .sticky-action { box-shadow:0 10px 26px rgba(0,0,0,.45); }
  .sticky-actions { padding:8px; border-radius:16px; background:color-mix(in srgb,var(--bg) 84%,transparent); backdrop-filter:blur(10px); }
  /* Boards sized to the screen height so their controls are visible without scrolling. */
  #tetris-wrap { gap:8px; }
  #tetris-side { flex-basis:100px; gap:6px; }
  .tetris-panel { padding:6px 6px 8px; border-radius:12px; }
  .tetris-panel .tp-val { font-size:18px; }
  .tp-sub { font-size:15px; }
  #game-screen[data-game="tetris"] #tetris-canvas { height:min(calc(100dvh - 222px),calc((100vw - 24px - 100px - 8px - 8px) * 2)); }
  #game-screen[data-game="pinball"] #pin-canvas { width:min(100%,calc((100dvh - 265px) * .65625)); }
  #game-screen[data-game="pinball"] #pin-status { margin:4px 0 0; font-size:13px; }
  #game-screen[data-game="pinball"] .pin-controls { margin-top:8px; }
  #game-screen[data-game="gaterunner"] #gate-canvas { width:min(100%,calc((100dvh - 345px) * .8)); min-width:230px; }
  #game-screen[data-game="gaterunner"] .gate-controls { margin:8px auto; }
  .skill-grid { grid-template-columns:1fr 1fr; }
  #game-screen .monster-sprite { width:84px; height:84px; font-size:50px; }
  .battle-log { min-height:72px; padding:10px 12px; }
  #game-screen[data-game="roulette"] .roulette-canvas { width:min(52vw,200px); height:auto; margin-bottom:10px; }
}
/* Text-style link button used in home widgets ("詳細 →"). */
.section-link { flex-shrink:0; background:transparent; border:1px solid var(--border); border-radius:999px; color:var(--accent4); font:inherit; font-size:12px; font-weight:800; padding:6px 12px; cursor:pointer; white-space:nowrap; }
.section-link:hover { border-color:var(--accent4); }
.section-link:focus-visible { outline:3px solid var(--accent4); outline-offset:2px; }
/* Phones held sideways: boards fill the screen height; the Tetris pad sits at the bottom right. */
@media (max-height:520px) and (orientation:landscape) {
  #game-screen[data-game="tetris"] > .game-header { display:none; }
  #game-screen[data-game="tetris"] #tetris-canvas { height:calc(100dvh - 92px); }
  #game-screen[data-game="tetris"] #tetris-wrap { flex-wrap:nowrap; justify-content:flex-start; padding-left:max(0px,env(safe-area-inset-left)); }
  #game-screen[data-game="tetris"] #tetris-side { flex:0 0 228px; display:grid; grid-template-columns:1fr 1fr; grid-template-areas:"hold next" "stats next"; align-items:start; gap:8px; }
  #game-screen[data-game="tetris"] #tet-hold-panel { grid-area:hold; }
  #game-screen[data-game="tetris"] #tetris-side .tp-preview:not(#tet-hold-panel) { grid-area:next; }
  #game-screen[data-game="tetris"] #tetris-side .tp-stats { grid-area:stats; }
  #game-screen[data-game="tetris"] #tetris-side .tet-hint { grid-column:1 / -1; }
  #game-screen[data-game="tetris"] .tet-btns { position:fixed; right:max(12px,env(safe-area-inset-right)); bottom:max(12px,env(safe-area-inset-bottom)); width:min(228px,34vw); grid-template-columns:repeat(3,1fr); z-index:6; }
  #game-screen[data-game="tetris"] .tet-touch-hint { display:none; }
  #game-screen[data-game="pinball"] #pin-canvas { width:min(100%,calc((100dvh - 24px) * .65625)); }
}
/* Pause screen (see pauseGame in js/core.js). */
.pause-overlay { position:fixed; inset:0; z-index:900; display:flex; align-items:center; justify-content:center; padding:24px; background:rgba(8,8,20,.72); backdrop-filter:blur(6px); }
.pause-overlay[hidden] { display:none; }
.pause-card { width:min(100%,320px); display:grid; gap:10px; justify-items:center; text-align:center; padding:26px 22px 20px; background:var(--surface); border:1px solid var(--border); border-radius:22px; box-shadow:0 20px 50px rgba(0,0,0,.45); }
.pause-icon { font-size:40px; line-height:1; }
.pause-card h2 { font-size:22px; }
.pause-card p { color:var(--text2); font-size:13px; margin-bottom:6px; }
.pause-card .pause-resume { width:100%; min-height:54px; font-size:18px; }
.pause-card .pause-home { width:100%; background:var(--surface2); color:var(--text); }
/* Phones: during a game the top bar is one compact row of icon buttons, and the game's
   own header shrinks, so the board starts about 100px higher than before. */
@media (max-width:520px) {
  body.playing-game #topbar { padding-top:calc(6px + env(safe-area-inset-top)); padding-bottom:6px; gap:6px; }
  body.playing-game #topbar h1, body.playing-game #tb-lv, body.playing-game #tb-pt, body.playing-game #profile-btn { display:none; }
  body.playing-game #topbar-right { margin-left:0; }
  body.playing-game .topbar-game { margin-left:auto; }
  .topbar-game .qb-label { display:none; }
  .topbar-game #game-quit-btn { width:auto; padding:0 10px; gap:3px; font-size:13px; }
  .topbar-game .game-quick-btn, body.playing-game .tb-bgm-btn { width:42px; min-width:42px; height:42px; min-height:42px; padding:0; font-size:17px; border-radius:12px; }
  body.playing-game .back-btn { min-height:42px; }
  body.playing-game #game-screen { padding-top:10px; }
  #game-screen[data-game] > .game-header { padding:8px 12px; margin-bottom:10px; border-radius:14px; }
  #game-screen[data-game] > .game-header h2 { font-size:18px; margin-bottom:2px; }
  #game-screen[data-game] > .game-header p { font-size:12px; line-height:1.45; }
  body.playing-game #lvup-toast { top:calc(62px + env(safe-area-inset-top)); }
}
@media (max-width:380px) {
  body.playing-game #topbar, .topbar-game, .game-quit-bar { gap:4px; }
  .topbar-game .game-quick-btn, body.playing-game .tb-bgm-btn { width:38px; min-width:38px; font-size:16px; }
  .topbar-game #game-quit-btn { width:auto; padding:0 8px; }
  body.playing-game .back-btn { padding:8px 10px; }
}
@media (max-width:340px) {
  /* Smallest phones: the back button shows only its arrow (its text stays for screen readers). */
  body.playing-game .back-btn { font-size:0; width:42px; padding:0; }
  body.playing-game .back-btn::before { content:'←'; font-size:17px; }
}
/* Phones held sideways get the same compact in-game top bar as portrait phones. */
@media (max-height:520px) and (orientation:landscape) {
  body.playing-game #topbar { padding-top:max(6px,env(safe-area-inset-top)); padding-bottom:6px; gap:6px; flex-wrap:nowrap; }
  body.playing-game #topbar h1, body.playing-game #tb-lv, body.playing-game #tb-pt, body.playing-game #profile-btn { display:none; }
  body.playing-game #topbar-right { margin-left:0; }
  body.playing-game .topbar-game { margin-left:auto; }
  .topbar-game .qb-label { display:none; }
  .topbar-game .game-quick-btn, body.playing-game .tb-bgm-btn { width:42px; min-width:42px; height:42px; min-height:42px; padding:0; font-size:17px; border-radius:12px; }
  .topbar-game #game-quit-btn { width:auto; padding:0 10px; gap:3px; font-size:13px; }
  body.playing-game .back-btn { min-height:42px; white-space:nowrap; }
}
