/* GameSieuDang — launcher styles. Flat "sticker" look: ink outlines, hard offset
   shadows, one solid color per category. */
:root {
    --ink: #14213d;
    --bg: #e4efff;
    --dot: #cfe0fb;
    --panel: #ffffff;
    --panel-2: #f2f6ff;
    --line: #14213d;
    --text: #14213d;
    --muted: #54607c;
    --yellow: #ffc93c;
    --coral: #ff5a5f;
    --focus: #2457d6;
    --shadow: #14213d;

    --cat-arcade:   #6fa8ff;
    --cat-shooter:  #ff8a80;
    --cat-puzzle:   #bb9bff;
    --cat-board:    #ffc45c;
    --cat-strategy: #55cfb8;
    --cat-sports:   #7ddb86;
    --cat-physics:  #ff9fcb;
    --cat-construction: #9fd3f5;
    --cat-frankforce: #8fe3ee;
    --cat-extra:    #c3cad8;
}
:root[data-theme="dark"] {
    --bg: #131a33;
    --dot: #1d2747;
    --panel: #222c52;
    --panel-2: #2b3763;
    --line: #070b1a;
    --text: #f3f6ff;
    --muted: #b4bedb;
    --focus: #ffc93c;
    --shadow: #070b1a;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; height: 100dvh; overflow: hidden; }
body {
    display: flex; flex-direction: column;
    background: var(--bg); color: var(--text);
    font: 15px/1.45 ui-rounded, "SF Pro Rounded", "Nunito", "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif;
    user-select: none; -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}
input { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
#topbar {
    flex: none; z-index: 40;
    display: flex; align-items: center; gap: 16px;
    padding: 10px 28px; background: var(--panel);
    border-bottom: 3px solid var(--line);
}
#brand { display: flex; align-items: center; gap: 10px; padding: 0; border: 0; background: none; font-size: 24px; font-weight: 900; letter-spacing: -.4px; white-space: nowrap; }
#brand img { display: block; transition: transform .2s; }
@media (hover: hover) { #brand:hover img { transform: rotate(-10deg) scale(1.06); } }
#search-box {
    flex: 0 1 460px; margin: 0 auto; display: flex; align-items: center; gap: 8px;
    height: 46px; padding: 0 16px; border: 3px solid var(--line); border-radius: 23px; background: var(--panel-2);
}
#search-box:focus-within { background: var(--panel); box-shadow: 0 0 0 3px var(--yellow); }
.floor-search { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: inherit; font: inherit; font-size: 16px; }
.floor-search::placeholder, #search::placeholder { color: var(--muted); opacity: 1; }
#now-title { flex: 1; min-width: 0; font-size: 18px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#top-actions { display: flex; gap: 8px; }
.icon-btn {
    width: 44px; height: 44px; padding: 0; display: grid; place-items: center;
    border: 3px solid var(--line); border-radius: 14px; background: var(--panel);
    font-size: 18px; font-weight: 800; line-height: 1; transition: transform .1s, background .15s;
}
@media (hover: hover) { .icon-btn:hover { background: var(--yellow); color: var(--ink); } }
.icon-btn:active { transform: translateY(2px); }
body:not(.in-game) :is(.game-only, #now-title) { display: none; }
body.in-game :is(.home-only, #search-box) { display: none; }
body.touch #fullscreen-toggle { display: none; }
/* phones hand the whole screen to the game; its own toolbar opens the list */
body.touch.in-game #topbar { display: none; }
@media (orientation: portrait) { html.ios-topbar #topbar { padding-top: 40px; } }

#shell { flex: 1; min-height: 0; display: flex; }
#stage { flex: 1; min-width: 0; position: relative; overflow: hidden; }
#frame { width: 100%; height: 100%; border: 0; display: block; background: #000; }

/* ---------- Game list (right panel / touch drawer) ---------- */
#sidebar { flex: 0 0 288px; width: 288px; display: flex; flex-direction: column; overflow: hidden; background: var(--panel); border-left: 3px solid var(--line); }
body:not(.touch):not(.in-game) #sidebar, body:not(.touch).in-game.sidebar-collapsed #sidebar { display: none; }
body.touch #sidebar { position: fixed; inset: 0 0 0 auto; width: 330px; max-width: 86vw; z-index: 60; transform: translateX(102%); transition: transform .25s ease-out; }
body.touch #sidebar.open { transform: none; }
#sidebar-header { padding: 12px; display: grid; gap: 10px; border-bottom: 3px solid var(--line); background: var(--panel-2); }
#drawer-home { display: none; min-height: 44px; border: 3px solid var(--line); border-radius: 14px; background: var(--yellow); color: var(--ink); font-weight: 800; }
body.touch #drawer-home { display: block; }
#search { width: 100%; height: 44px; padding: 0 14px; border: 3px solid var(--line); border-radius: 22px; background: var(--panel); color: inherit; font: inherit; font-size: 16px; outline: 0; }
#search:focus { box-shadow: 0 0 0 3px var(--yellow); }
#filter-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
#filter-chips::-webkit-scrollbar { display: none; }
.chip-filter { flex: none; min-height: 36px; padding: 0 12px; border: 2px solid var(--line); border-radius: 18px; background: var(--panel); font-size: 13px; font-weight: 700; }
.chip-filter.active { background: var(--cat-color, var(--yellow)); color: var(--ink); }
#list { flex: 1; overflow-y: auto; padding: 8px; overflow-anchor: none; }
.list-divider { margin: 16px 8px 6px; color: var(--muted) !important; font-size: 13px; font-weight: 800; }
.card { display: flex; align-items: center; gap: 12px; width: 100%; padding: 6px; border: 2px solid transparent; border-radius: 16px; background: none; text-align: left; }
.card .cover { flex: 0 0 64px; height: 48px; border-width: 2px; border-radius: 12px; }
.card .cover .emoji { font-size: 26px; }
.card .info { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.card .name { font-weight: 700; line-height: 1.25; }
@media (hover: hover) { .card:hover { background: var(--panel-2); } }
.card.selected { background: var(--yellow); border-color: var(--line); color: var(--ink); }
#backdrop { display: none; position: fixed; inset: 0; z-index: 50; background: rgba(7, 11, 26, .6); opacity: 0; pointer-events: none; transition: opacity .2s; }
body.touch #backdrop { display: block; }
#backdrop.show { opacity: 1; pointer-events: auto; }

/* ---------- Covers ---------- */
.cover {
    position: relative; overflow: hidden; display: grid; place-items: center;
    border: 3px solid var(--line); border-radius: 18px;
    background-color: var(--cat-color, #c3cad8); color: var(--ink);
}
.cover::before { content: ''; position: absolute; inset: 0; opacity: .34; }
.cover[data-pattern="0"]::before { background: radial-gradient(#fff 22%, transparent 24%) 0 0 / 26px 26px; }
.cover[data-pattern="1"]::before { background: repeating-linear-gradient(45deg, #fff 0 10px, transparent 10px 26px); }
.cover[data-pattern="2"]::before { background: radial-gradient(circle at 50% 120%, #fff 0 34%, transparent 35% 48%, #fff 49% 62%, transparent 63%); }
.cover[data-pattern="3"]::before { background: conic-gradient(#fff 25%, transparent 0 50%, #fff 0 75%, transparent 0) 0 0 / 44px 44px; opacity: .2; }
.cover .emoji {
    position: relative; line-height: 1;
    /* white die-cut edge, like a sticker */
    filter: drop-shadow(2px 0 0 #fff) drop-shadow(-2px 0 0 #fff) drop-shadow(0 2px 0 #fff) drop-shadow(0 -2px 0 #fff) drop-shadow(0 3px 0 rgba(20, 33, 61, .35));
    transition: transform .2s;
}
.card .cover .emoji { filter: drop-shadow(1px 0 0 #fff) drop-shadow(-1px 0 0 #fff) drop-shadow(0 1px 0 #fff) drop-shadow(0 -1px 0 #fff); }
.cover .shot { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .2s; }
.cover .pad { position: absolute; right: 8px; top: 8px; z-index: 1; padding: 1px 8px; border: 2px solid var(--ink); border-radius: 12px; background: #fff; font-size: 13px; line-height: 1.4; }

/* ---------- Home ---------- */
#welcome {
    position: absolute; inset: 0; overflow-y: auto; padding: 24px 28px 56px;
    background: radial-gradient(var(--dot) 2.2px, transparent 2.8px) 0 0 / 26px 26px var(--bg);
}
#welcome > * { max-width: 1280px; margin-left: auto; margin-right: auto; }
.home-top { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; margin-bottom: 26px; }
#hero-cabinet, .picks { border: 3px solid var(--line); border-radius: 26px; box-shadow: 0 6px 0 var(--shadow); }
#hero-cabinet { display: flex; flex-direction: row-reverse; overflow: hidden; background: var(--yellow); color: var(--ink); min-height: 330px; }
.hero-screen { position: relative; flex: 0 0 60%; background: #000 center / cover; border-left: 3px solid var(--ink); }
#hero-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; pointer-events: none; opacity: 0; transition: opacity .35s; }
.hero-clip { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; opacity: 0; transition: opacity .25s; }
.hero-clip.ready { opacity: 1; }
.hero-hit { position: absolute; inset: 0; width: 100%; padding: 0; border: 0; background: none; }
.hero-bar { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 10px; padding: 24px; }
.hero-now { font-size: 14px; font-weight: 700; }
.hero-name { font-size: clamp(26px, 3vw, 40px); font-weight: 900; line-height: 1.12; letter-spacing: -.6px; text-wrap: balance; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 2px 10px; border: 2px solid var(--ink); border-radius: 12px; background: #fff; color: var(--ink); font-size: 12.5px; font-weight: 700; }
.hero-coin { min-height: 50px; margin-top: 6px; padding: 0 26px; border: 3px solid var(--ink); border-radius: 25px; background: var(--coral); color: var(--ink); font-size: 18px; font-weight: 900; box-shadow: 0 4px 0 var(--ink); transition: transform .1s, box-shadow .1s; }
.hero-coin:active { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }
.hero-shuffle { min-height: 40px; padding: 0 4px; border: 0; background: none; font-weight: 700; text-decoration: underline; text-underline-offset: 4px; }
body.touch .hero-shuffle { display: none; }
.picks { counter-reset: n; list-style: none; margin: 0; padding: 12px; background: var(--panel); display: flex; flex-direction: column; justify-content: space-between; gap: 2px; }
.picks li { counter-increment: n; display: flex; align-items: center; gap: 6px; }
.picks li::before { content: counter(n); flex: 0 0 28px; text-align: center; font-size: 22px; font-weight: 900; color: var(--muted); }
.picks .card { min-width: 0; }

.row { margin-bottom: 22px; }
.row h2, .floor-heading { margin: 0 0 12px; font-size: 22px; font-weight: 900; letter-spacing: -.3px; line-height: 1.25; }
.row .row-bar, .row .row-emoji { display: none; }
.tiles-wrap { position: relative; }
.tiles { display: flex; gap: 16px; overflow-x: auto; padding: 4px 4px 12px; margin: -4px; scrollbar-width: none; cursor: grab; }
.tiles::-webkit-scrollbar { display: none; }
.tiles.dragging { cursor: grabbing; }
.tiles.dragging .tile { pointer-events: none; }
.tiles .tile { flex: 0 0 178px; }
.edge-scroll { position: absolute; top: 34px; z-index: 5; width: 44px; height: 44px; border: 3px solid var(--line); border-radius: 50%; background: var(--panel); font-size: 24px; font-weight: 900; line-height: 1; }
.edge-scroll.left { left: -10px; } .edge-scroll.right { right: -10px; }
body.touch .edge-scroll { display: none; }

.floor-controls { position: sticky; top: -24px; z-index: 20; margin: 0 -28px 18px; padding: 10px 28px; background: var(--bg); }
.floor-chips { display: flex; flex-wrap: wrap; gap: 8px; max-width: 1280px; margin: 0 auto; }
.floor-chip { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px; border: 3px solid var(--line); border-radius: 22px; background: var(--panel); font-size: 14px; font-weight: 800; transition: background .15s, transform .1s; }
.floor-chip .ct { min-width: 24px; padding: 0 6px; border-radius: 10px; background: var(--panel-2); color: var(--muted); font-size: 12.5px; line-height: 20px; text-align: center; }
@media (hover: hover) { .floor-chip:hover { background: var(--cat-color, var(--yellow)); color: var(--ink); } }
.floor-chip:active { transform: translateY(2px); }
.floor-chip.on { background: var(--cat-color, var(--yellow)); color: var(--ink); }
.floor-chip.on .ct { background: #fff; color: var(--ink); }
.floor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 22px 18px; }
.floor-heading, .floor-divider { grid-column: 1 / -1; margin: 10px 0 -8px; }
.floor-divider { font-weight: 800; color: var(--muted); }
.empty { grid-column: 1 / -1; padding: 28px 12px; text-align: center; color: var(--muted); font-size: 16px; }

.tile {
    display: flex; flex-direction: column; padding: 0; border: 0; background: none; text-align: left;
    transition: transform .15s; animation: tile-enter .28s ease-out backwards; animation-delay: calc(var(--i, 0) * 20ms);
}
@keyframes tile-enter { from { opacity: 0; transform: translateY(8px); } }
.tile .cover { aspect-ratio: 4 / 3; box-shadow: 0 5px 0 var(--shadow); transition: transform .12s, box-shadow .12s; }
.tile .cover .emoji { font-size: 68px; }
.tile .info { padding: 14px 4px 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.tile .name { font-size: 17px; font-weight: 800; line-height: 1.25; }
.tile .desc { color: var(--muted); font-size: 13.5px; line-height: 1.35; }
.score-badge { padding: 1px 9px; border: 2px solid var(--ink); border-radius: 11px; background: var(--yellow); color: var(--ink); font-size: 12.5px; font-weight: 800; }
.tile .score-badge { margin-top: 5px; }
.hero-score { background: #fff; }
@media (hover: hover) {
    .tile:hover .cover { transform: translateY(-4px); box-shadow: 0 9px 0 var(--shadow); }
    .tile:hover .shot.ready { opacity: 1; }
}
.tile:focus-visible { outline: none; }
.tile:focus-visible .cover { outline: 4px solid var(--focus); outline-offset: 3px; }
.tile:active .cover { transform: translateY(4px); box-shadow: 0 1px 0 var(--shadow); }

/* ---------- About ---------- */
#about-modal { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; }
.about-backdrop { position: absolute; inset: 0; background: rgba(7, 11, 26, .6); }
.about-panel { position: relative; width: min(460px, 100%); max-height: 90dvh; overflow-y: auto; padding: 28px; border: 3px solid var(--line); border-radius: 26px; background: var(--panel); box-shadow: 0 8px 0 var(--shadow); }
.about-close { position: absolute; top: 14px; right: 14px; width: 44px; height: 44px; border: 3px solid var(--line); border-radius: 14px; background: var(--panel-2); font-weight: 900; }
.about-logo { width: 72px; height: 72px; }
.about-panel h2 { margin: 8px 0 4px; font-size: 28px; font-weight: 900; }
.about-panel h3 { margin: 18px 0 4px; font-size: 17px; }
.about-panel p { margin: 0; line-height: 1.55; }
.about-panel a { color: inherit; text-underline-offset: 3px; }
.about-credit { margin-top: 20px !important; padding-top: 14px; border-top: 2px dashed var(--muted); color: var(--muted); font-size: 13px; }

/* ---------- Account ---------- */
#account-btn { display: flex; align-items: center; gap: 8px; min-height: 44px; max-width: 190px; padding: 0 16px; border: 3px solid var(--line); border-radius: 22px; background: var(--yellow); color: var(--ink); font-weight: 800; white-space: nowrap; }
#account-btn.signed-in { padding: 0 14px 0 4px; background: var(--panel); color: var(--text); }
#account-btn .avatar { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--coral); color: var(--ink); font-weight: 900; }
#account-btn .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#account-modal { position: fixed; inset: 0; z-index: 210; display: grid; place-items: center; padding: 16px; }
#account-modal .about-panel { width: min(420px, 100%); }
#account-modal h2 { margin: 0 52px 16px 0; overflow-wrap: anywhere; }
.account-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 18px; border: 3px solid var(--line); border-radius: 23px; overflow: hidden; }
.account-tabs button { min-height: 44px; border: 0; background: var(--panel-2); font-weight: 800; }
.account-tabs button.on { background: var(--yellow); color: var(--ink); }
.account-form { display: grid; gap: 14px; }
.field { display: grid; gap: 5px; }
.field-label { font-weight: 800; }
.field small { color: var(--muted); font-size: 13px; }
.field-row { display: flex; border: 3px solid var(--line); border-radius: 16px; background: var(--panel-2); overflow: hidden; }
.field-row:focus-within { box-shadow: 0 0 0 3px var(--yellow); background: var(--panel); }
.field-row input { flex: 1; min-width: 0; height: 46px; padding: 0 14px; border: 0; outline: 0; background: none; color: inherit; font: inherit; font-size: 16px; }
.field-row .eye { padding: 0 14px; border: 0; background: none; color: var(--muted); font-size: 14px; font-weight: 700; }
.form-msg { margin: 0; color: #c21f2c; font-weight: 700; } .form-msg:empty { display: none; }
:root[data-theme="dark"] .form-msg { color: #ff9c9c; }
.main-btn { width: 100%; min-height: 50px; border: 3px solid var(--ink); border-radius: 25px; background: var(--yellow); color: var(--ink); font-size: 17px; font-weight: 900; box-shadow: 0 4px 0 var(--shadow); }
.main-btn:active { transform: translateY(4px); box-shadow: none; }
.main-btn:disabled { opacity: .6; cursor: default; }
.main-btn.danger { background: var(--coral); }
.about-panel .account-note { margin: 16px 0; color: var(--muted); font-size: 14px; }
#account-modal details { margin-top: 18px; border-top: 2px dashed var(--muted); padding-top: 10px; }
#account-modal summary { min-height: 40px; display: flex; align-items: center; font-weight: 800; cursor: pointer; }

#account-modal .account-ask { margin: 0 0 16px; padding: 12px 14px; border: 3px solid var(--ink); border-radius: 16px; background: var(--yellow); color: var(--ink); font-weight: 800; }

/* ---------- Narrow ---------- */
@media (max-width: 1080px) { .home-top { grid-template-columns: 1fr; } .picks { flex-direction: row; overflow-x: auto; justify-content: flex-start; scrollbar-width: none; } .picks li { flex: 0 0 236px; } }
@media (max-width: 720px) {
    #topbar { flex-wrap: wrap; gap: 10px 8px; padding: 10px 14px; }
    #brand { font-size: 21px; margin-right: auto; } #brand img { width: 36px; height: 36px; }
    #search-box { order: 3; flex: 1 1 100%; }
    #account-btn { max-width: 130px; padding: 0 12px; }
    #welcome { padding: 14px 14px 40px; }
    .home-top { gap: 14px; margin-bottom: 18px; }
    #hero-cabinet { min-height: 168px; border-radius: 22px; }
    .hero-screen { flex-basis: 48%; }
    .hero-bar { padding: 14px; gap: 6px; }
    .hero-bar .hero-tags, .picks { display: none; }
    .hero-name { font-size: 21px; }
    .hero-now { font-size: 12.5px; }
    .hero-coin { min-height: 46px; padding: 0 18px; font-size: 16px; }
    .floor-controls { top: -14px; margin: 0 -14px 12px; padding: 8px 0; }
    .floor-chips { flex-wrap: nowrap; overflow-x: auto; padding: 0 14px; gap: 8px; scrollbar-width: none; }
    .floor-chips::-webkit-scrollbar { display: none; }
    .floor-chip { flex: none; }
    .floor-grid { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 18px 14px; }
    .tile .cover .emoji { font-size: 58px; }
    .tiles .tile { flex-basis: 148px; }
    .tile .name { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
@media (max-width: 400px) { #account-btn.signed-in .who { display: none; } #account-btn.signed-in { padding: 0 3px; } }
#account-modal summary { justify-content: space-between; list-style: none; }
#account-modal summary::after { content: '▾'; }
#account-modal details[open] summary::after { content: '▴'; }
@media (max-width: 420px) { #brand { gap: 7px; font-size: 18px; } #brand img { width: 32px; height: 32px; } #top-actions { gap: 6px; } #account-btn { font-size: 14px; } #account-btn:not(.signed-in) { padding: 0 10px; } }
@media (max-width: 720px) { #fullscreen-toggle { display: none; } }
.wordmark b { font-weight: 900; color: #d3202d; }
:root[data-theme="dark"] .wordmark b { color: #ff8d85; }
@media (max-width: 420px) {
    #topbar { column-gap: 6px; padding-left: 12px; padding-right: 12px; }
    #brand { gap: 5px; font-size: 15.5px; letter-spacing: -.6px; }
    #brand img { width: 28px; height: 28px; }
    #top-actions { gap: 5px; }
    .icon-btn { width: 40px; }
    #account-btn { font-size: 13.5px; }
    #account-btn:not(.signed-in) { padding: 0 8px; }
}
@media (max-width: 374px) { #topbar { padding-left: 8px; padding-right: 8px; column-gap: 4px; } #brand { font-size: 14px; gap: 4px; } #brand img { width: 26px; height: 26px; } .icon-btn { width: 37px; } #top-actions { gap: 4px; } #account-btn { font-size: 13px; } #account-btn:not(.signed-in) { padding: 0 6px; } }
@media (max-width: 345px) { #brand span { display: none; } .hero-coin { padding: 0 12px; white-space: nowrap; } }
