/* PlayZone game portal: hub (index.html) and play page (play.html) */
:root {
    --bg: #bfe7ff;
    --bg2: #eaf7ff;
    --ink: #0b2545;
    --muted: #4f6a88;
    --card: #fff;
    --line: rgba(11, 37, 69, 0.1);
    --accent: #ff4f6d;
    --accent-ink: #fff;
    --accent-dark: #c42f4b;
    --shadow: 0 6px 14px rgba(11, 37, 69, 0.18);
    --shadow-up: 0 14px 26px rgba(11, 37, 69, 0.3);
    --cell: 104px;
    --gap: 14px;
    --radius: 16px;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0f1d33;
        --bg2: #0a1424;
        --ink: #e8f1ff;
        --muted: #9fb3cc;
        --card: #172741;
        --line: rgba(255, 255, 255, 0.08);
        --shadow: 0 6px 14px rgba(0, 0, 0, 0.45);
        --shadow-up: 0 14px 26px rgba(0, 0, 0, 0.6);
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #0f1d33;
    --bg2: #0a1424;
    --ink: #e8f1ff;
    --muted: #9fb3cc;
    --card: #172741;
    --line: rgba(255, 255, 255, 0.08);
    --shadow: 0 6px 14px rgba(0, 0, 0, 0.45);
    --shadow-up: 0 14px 26px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(var(--bg), var(--bg2) 70vh) fixed, var(--bg2);
    color: var(--ink);
    font-family: "Nunito", "Trebuchet MS", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.4;
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.top {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px max(16px, calc((100vw - 1400px) / 2));
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(10px);
}
.logo {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 14px 6px 6px;
    border-radius: 14px;
    background: var(--card);
    box-shadow: var(--shadow);
    text-decoration: none;
    font-size: 22px;
    font-weight: 900;
    letter-spacing: -0.02em;
    flex: none;
}
.logo svg { width: 38px; height: 38px; display: block; }
.logo b { color: var(--accent); }
.search {
    flex: 1;
    max-width: 520px;
    position: relative;
}
.search input {
    width: 100%;
    height: 50px;
    padding: 0 18px 0 46px;
    border: 0;
    border-radius: 14px;
    background: var(--card);
    box-shadow: var(--shadow);
    font-size: 16px;
    font-weight: 700;
    outline: none;
}
.search input:focus-visible { box-shadow: var(--shadow), 0 0 0 3px var(--accent); }
.search svg { position: absolute; left: 15px; top: 15px; width: 20px; height: 20px; color: var(--muted); pointer-events: none; }
.top-actions { display: flex; gap: 10px; margin-left: auto; }
.icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 50px;
    padding: 0 16px;
    border: 0;
    border-radius: 14px;
    background: var(--card);
    box-shadow: var(--shadow);
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.icon-btn:hover { transform: translateY(-1px); }
.icon-btn svg { width: 20px; height: 20px; flex: none; }

/* ---------- category chips ---------- */
.cats {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px max(16px, calc((100vw - 1400px) / 2)) 10px;
    scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }
.chip {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 15px;
    border: 0;
    border-radius: 999px;
    background: var(--card);
    box-shadow: 0 3px 8px rgba(11, 37, 69, 0.12);
    font-weight: 800;
    font-size: 15px;
    cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* ---------- sections + tile grid ---------- */
main { padding: 6px max(16px, calc((100vw - 1400px) / 2)) 40px; }
.section { margin: 10px 0 30px; }
.section h2 { margin: 0 0 12px; font-size: 22px; font-weight: 900; display: flex; align-items: baseline; gap: 10px; }
.section h2 small { font-size: 14px; font-weight: 700; color: var(--muted); }
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, var(--cell));
    grid-auto-rows: var(--cell);
    grid-auto-flow: dense;
    gap: var(--gap);
    justify-content: center;
}
.row {
    display: flex;
    gap: var(--gap);
    overflow-x: auto;
    padding: 6px 4px 12px;
    margin: -6px -4px 0;
    scrollbar-width: thin;
}
.row .tile { flex: 0 0 var(--cell); height: var(--cell); }

.tile {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--tile, #5b8cff);
    box-shadow: var(--shadow);
    text-decoration: none;
    transition: transform 0.16s ease, box-shadow 0.16s ease;
    -webkit-tap-highlight-color: transparent;
}
.tile.big { grid-column: span 2; grid-row: span 2; }
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.tile:hover, .tile:focus-visible { transform: scale(1.06); box-shadow: var(--shadow-up); z-index: 2; outline: none; }
.tile:focus-visible { box-shadow: var(--shadow-up), 0 0 0 3px var(--accent); }
.tile:active { transform: scale(0.98); }
.tile .fallback {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
    text-align: center;
    color: #fff;
    font-size: 15px;
    font-weight: 900;
    line-height: 1.1;
    background: linear-gradient(150deg, rgba(255, 255, 255, 0.22), transparent 55%), var(--tile, #5b8cff);
    word-break: break-word;
}
.tile.web .fallback::before { content: "🌐"; font-size: 30px; }
.tile.big .fallback { font-size: 26px; }
.tile.big.web .fallback::before { font-size: 54px; }
.tile .name {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 22px 9px 8px;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.15;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.16s, transform 0.16s;
}
.tile.big .name { font-size: 18px; padding: 30px 14px 12px; }
.tile:hover .name, .tile:focus-visible .name { opacity: 1; transform: none; }
.tile.web .name { display: none; }
@media (hover: none) {
    .tile:not(.web) .name { opacity: 1; transform: none; }
}
.badge {
    position: absolute;
    top: 7px;
    left: 7px;
    z-index: 1;
    padding: 2px 7px;
    border-radius: 7px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.04em;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}
.badge.proxy { background: rgba(0, 0, 0, 0.45); letter-spacing: 0; }

.empty {
    max-width: 520px;
    margin: 30px auto;
    padding: 26px;
    border-radius: 20px;
    background: var(--card);
    box-shadow: var(--shadow);
    text-align: center;
}
.empty h2 { margin: 0 0 6px; }
.empty p { margin: 0 0 16px; color: var(--muted); }
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    box-shadow: 0 4px 0 var(--accent-dark);
    font-weight: 900;
    text-decoration: none;
    cursor: pointer;
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--accent-dark); }

footer {
    padding: 24px 16px 40px;
    color: var(--muted);
    text-align: center;
    font-size: 14px;
    font-weight: 700;
}
footer a { font-weight: 800; }

/* ---------- play page ---------- */
.play-layout { max-width: 1240px; margin: 0 auto; }
.stage {
    position: relative;
    width: min(100%, calc((100vh - 190px) * var(--ar, 1.6)));
    aspect-ratio: var(--ar, 1.6);
    margin: 0 auto;
    overflow: hidden;
    border-radius: 20px;
    background: #0b1222;
    box-shadow: var(--shadow-up);
}
@supports (height: 100dvh) {
    .stage { width: min(100%, calc((100dvh - 190px) * var(--ar, 1.6))); }
}
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.stage.max {
    position: fixed;
    inset: 0;
    z-index: 100;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border-radius: 0;
}
.stage:fullscreen { width: 100%; height: 100%; aspect-ratio: auto; border-radius: 0; }
.stage .exit-max {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3;
    display: none;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}
.stage.max .exit-max { display: block; }
.stage .loading, .stage .missing {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: #fff;
    text-align: center;
    font-weight: 800;
}
.stage .missing p { margin: 0; color: #b9c6dd; font-weight: 700; max-width: 380px; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 5px solid rgba(255, 255, 255, 0.2); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.game-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    width: min(100%, 900px);
    margin: 14px auto 0;
    padding: 10px 12px;
    border-radius: 18px;
    background: var(--card);
    box-shadow: var(--shadow);
}
.game-bar img { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; flex: none; background: var(--line); }
.game-bar h1 { margin: 0; font-size: 20px; line-height: 1.15; }
.game-bar .cat { color: var(--muted); font-size: 14px; font-weight: 700; text-decoration: none; }
.game-bar .cat:hover { text-decoration: underline; }
.game-bar .actions { margin-left: auto; display: flex; gap: 8px; }
.round-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 44px;
    height: 44px;
    padding: 0 12px;
    border: 0;
    border-radius: 12px;
    background: color-mix(in srgb, var(--ink) 8%, transparent);
    font-weight: 800;
    cursor: pointer;
}
.round-btn:hover { background: color-mix(in srgb, var(--ink) 14%, transparent); }
.round-btn svg { width: 20px; height: 20px; }
.round-btn[aria-pressed="true"] { color: var(--accent); }
.round-btn[aria-pressed="true"] svg path { fill: currentColor; }

.about {
    width: min(100%, 900px);
    margin: 16px auto 28px;
    padding: 18px 22px;
    border-radius: 18px;
    background: var(--card);
    box-shadow: var(--shadow);
}
.about h2 { margin: 0 0 4px; font-size: 18px; }
.about p { margin: 0 0 12px; color: var(--muted); font-weight: 600; }
.about p:last-child { margin-bottom: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tags a { padding: 3px 10px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 8%, transparent); font-size: 13px; font-weight: 800; text-decoration: none; }

/* ---------- phones ---------- */
@media (max-width: 700px) {
    .top { flex-wrap: wrap; gap: 10px; }
    .search { order: 3; flex-basis: 100%; max-width: none; }
    .search input, .icon-btn { height: 44px; }
    .search svg { top: 12px; }
    .icon-btn .label { display: none; }
    .icon-btn { padding: 0 12px; }
    .logo { font-size: 20px; }
    .logo svg { width: 32px; height: 32px; }
    .stage { border-radius: 14px; width: min(100%, calc((100vh - 260px) * var(--ar, 1.6))); }
    .game-bar h1 { font-size: 17px; }
    .round-btn .label { display: none; }
}
@media (max-width: 560px) {
    :root { --gap: 10px; --cell: calc((100vw - 32px - 2 * var(--gap)) / 3); --radius: 14px; }
}
@media (prefers-reduced-motion: reduce) {
    .tile, .tile .name, .spinner { transition: none; animation: none; }
    .tile:hover { transform: none; }
}
