:root {
    --ink: #16120c;
    --text: #231c14;
    --text-dim: #6d604f;
    --cream: #f7efe0;
    --surface: #fffcf5;
    --line: rgba(60, 42, 18, 0.14);
    --amber: #ffb000;
    --amber-text: #a85a00;
    --red: #e23b22;
    --red-dark: #a8261a;
    --stencil: "Black Ops One", "Impact", sans-serif;
    --ui: "Barlow Condensed", "Arial Narrow", sans-serif;
    --body: "Barlow", system-ui, sans-serif;
    --aspect: 1.3333;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body.app {
    min-height: 100dvh;
    font-family: var(--body);
    color: var(--text);
    background:
        radial-gradient(700px 360px at 50% -8%, rgba(255, 176, 0, 0.2), transparent 60%),
        var(--cream);
    overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
img { display: block; }
[hidden] { display: none !important; }

/* ---------- screens ---------- */

.screen { min-height: 100dvh; padding: calc(var(--safe-top) + 14px) 16px calc(var(--safe-bottom) + 24px); }
.screen.enter { animation: screen-in 0.32s ease-out both; }
@keyframes screen-in {
    from { opacity: 0; transform: translateX(18px); }
    to { opacity: 1; transform: none; }
}

/* ---------- home ---------- */

.screen-home {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 26px;
    text-align: center;
    padding-bottom: calc(var(--safe-bottom) + 120px);
}
.account-chip {
    position: absolute;
    top: calc(var(--safe-top) + 14px);
    right: 16px;
    z-index: 3;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 999px;
    padding: 8px 14px 7px;
    font-family: var(--ui);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.85rem;
    box-shadow: 0 6px 16px rgba(70, 48, 18, 0.1);
}
.account-chip.is-signed { color: #2f7d14; }
.home-title { position: relative; z-index: 2; }
.home-welcome {
    margin: 0 0 6px;
    font-family: var(--ui);
    letter-spacing: 0.4em;
    text-transform: uppercase;
    font-size: 0.85rem;
    color: var(--amber-text);
    opacity: 0;
}
.logo {
    margin: 0;
    font-family: var(--stencil);
    font-weight: 400;
    font-size: clamp(58px, 19vw, 110px);
    line-height: 0.95;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.logo span {
    display: inline-block;
    color: transparent;
    background: linear-gradient(105deg, #e23b22 0%, #ff7a00 30%, #ffb000 44%, #fff4c7 50%, #ffb000 56%, #ff7a00 70%, #e23b22 100%);
    background-size: 300% 100%;
    background-position: 100% 0;
    -webkit-background-clip: text;
    background-clip: text;
    filter: drop-shadow(0 4px 0 #2a1208) drop-shadow(0 10px 18px rgba(226, 59, 34, 0.25));
    opacity: 0;
}
.logo .gap { display: inline-block; width: 0.28em; }
.domain {
    margin: 14px 0 0;
    min-height: 1.6em;
    font-family: var(--ui);
    font-weight: 700;
    font-size: clamp(20px, 6.4vw, 30px);
    letter-spacing: 0.12em;
    color: var(--ink);
}
.caret {
    display: inline-block;
    width: 0.5em;
    height: 1em;
    margin-left: 3px;
    vertical-align: -0.12em;
    background: var(--red);
    animation: caret 0.8s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }
.home-tag {
    margin: 8px 0 0;
    color: var(--text-dim);
    font-size: 0.98rem;
    opacity: 0;
}
.home-actions { position: relative; z-index: 2; opacity: 0; }

.is-playing .home-welcome { animation: fade-up 0.5s ease-out 0.05s both; }
.is-playing .logo span { animation: drop 0.7s cubic-bezier(0.2, 1.5, 0.45, 1) calc(0.2s + var(--i) * 0.08s) both, shine 3.2s ease-in-out calc(1.4s + var(--i) * 0.05s) infinite; }
.is-playing .home-tag { animation: fade-up 0.6s ease-out 2.4s both; }
.is-playing .home-actions { animation: fade-up 0.6s ease-out 2.6s both; }
@keyframes drop {
    0% { opacity: 0; transform: translateY(-120px) rotate(-14deg) scale(1.3); }
    60% { opacity: 1; }
    100% { opacity: 1; transform: none; }
}
@keyframes shine {
    0%, 55% { background-position: 100% 0; }
    100% { background-position: 0 0; }
}
@keyframes fade-up {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
}

.press-start {
    border: 0;
    border-radius: 14px;
    padding: 16px 34px 14px;
    font-family: var(--stencil);
    font-size: 1.35rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
    background: linear-gradient(180deg, #f2553a, var(--red) 55%, var(--red-dark));
    box-shadow: 0 6px 0 #7c1a10, 0 14px 30px rgba(226, 59, 34, 0.35);
    animation: pulse 1.6s ease-in-out infinite;
}
.press-start:active { transform: translateY(4px); box-shadow: 0 2px 0 #7c1a10, 0 8px 18px rgba(226, 59, 34, 0.3); }
.press-start:disabled { opacity: 0.55; animation: none; }
@keyframes pulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.15); }
}

.home-sky { position: absolute; inset: 0; pointer-events: none; }
.home-sky i {
    position: absolute;
    bottom: -40px;
    width: 14px;
    height: 14px;
    background: var(--amber);
    opacity: 0.35;
    animation: rise 9s linear infinite;
}
.home-sky i:nth-child(1) { left: 8%; animation-delay: 0s; }
.home-sky i:nth-child(2) { left: 22%; width: 10px; height: 10px; background: var(--red); animation-delay: 2.5s; animation-duration: 11s; }
.home-sky i:nth-child(3) { left: 37%; width: 8px; height: 8px; animation-delay: 5s; }
.home-sky i:nth-child(4) { left: 52%; background: #1fb5a8; animation-delay: 1.2s; animation-duration: 12s; }
.home-sky i:nth-child(5) { left: 66%; width: 18px; height: 18px; animation-delay: 3.6s; }
.home-sky i:nth-child(6) { left: 78%; width: 9px; height: 9px; background: var(--red); animation-delay: 6.2s; animation-duration: 10s; }
.home-sky i:nth-child(7) { left: 90%; animation-delay: 4.4s; animation-duration: 13s; }
.home-sky i:nth-child(8) { left: 45%; width: 6px; height: 6px; background: #3d7adf; animation-delay: 7.5s; }
@keyframes rise {
    from { transform: translateY(0) rotate(0); opacity: 0; }
    10% { opacity: 0.4; }
    to { transform: translateY(-110vh) rotate(180deg); opacity: 0; }
}

.stripes {
    position: absolute;
    left: -10%;
    right: -10%;
    bottom: calc(var(--safe-bottom) + 26px);
    display: grid;
    gap: 6px;
    transform: rotate(-6deg);
    pointer-events: none;
}
.stripes i { display: block; height: 10px; transform-origin: left; transform: scaleX(0); }
.stripes i:nth-child(1) { background: var(--red); }
.stripes i:nth-child(2) { background: #ff7a00; }
.stripes i:nth-child(3) { background: var(--amber); }
.stripes i:nth-child(4) { background: #1fb5a8; }
.is-playing .stripes i { animation: stripe 0.7s cubic-bezier(0.3, 0.9, 0.3, 1) both; }
.is-playing .stripes i:nth-child(1) { animation-delay: 1.5s; }
.is-playing .stripes i:nth-child(2) { animation-delay: 1.6s; }
.is-playing .stripes i:nth-child(3) { animation-delay: 1.7s; }
.is-playing .stripes i:nth-child(4) { animation-delay: 1.8s; }
@keyframes stripe { to { transform: scaleX(1); } }

.recent {
    position: relative;
    z-index: 2;
    width: 100%;
    text-align: left;
    animation: fade-up 0.6s ease-out 2.8s both;
}
.row-label {
    margin: 0 0 8px;
    font-family: var(--ui);
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    font-size: 0.8rem;
    color: var(--amber-text);
}
.recent-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; }
.recent-card {
    flex: 0 0 132px;
    scroll-snap-align: start;
    display: grid;
    gap: 3px;
    text-align: left;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 12px;
    padding: 6px 6px 8px;
}
.recent-pic { display: block; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: #241c14; }
.recent-pic img { width: 100%; height: 100%; object-fit: cover; }
.recent-card strong { font-size: 0.86rem; line-height: 1.15; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.recent-card small { color: var(--text-dim); font-size: 0.75rem; }

/* ---------- bars, machines ---------- */

.bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.bar h2 { margin: 0; font-family: var(--stencil); font-weight: 400; font-size: 1.7rem; line-height: 1; }
.bar-eyebrow, .boot-card .bar-eyebrow {
    margin: 0 0 3px;
    font-family: var(--ui);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: var(--amber-text);
}
.bar-back {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    font-size: 1.8rem;
    line-height: 1;
    text-decoration: none;
    padding-bottom: 4px;
}
.bar-sticky {
    position: sticky;
    top: 0;
    z-index: 4;
    margin: calc(-14px - var(--safe-top)) -16px 0;
    padding: calc(var(--safe-top) + 14px) 16px 12px;
    background: rgba(247, 239, 224, 0.94);
    backdrop-filter: blur(8px);
}

.machine-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.machine-card {
    position: relative;
    display: grid;
    border-radius: 16px;
    overflow: hidden;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: 0 10px 22px rgba(70, 48, 18, 0.12);
    animation: pop 0.45s cubic-bezier(0.2, 1.3, 0.4, 1) calc(var(--i) * 0.06s) both;
}
.machine-card:active { transform: scale(0.97); }
.machine-card img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; background: #241c14; }
.machine-info { display: grid; gap: 1px; padding: 9px 10px 11px; border-top: 4px solid var(--accent); }
.machine-info strong { font-family: var(--ui); font-weight: 700; font-size: 1.15rem; letter-spacing: 0.03em; }
.machine-info small { color: var(--text-dim); font-size: 0.78rem; }
.machine-info em { font-style: normal; font-family: var(--ui); font-size: 0.8rem; letter-spacing: 0.05em; color: color-mix(in srgb, var(--accent) 70%, #000); }
@keyframes pop {
    from { opacity: 0; transform: translateY(16px) scale(0.94); }
    to { opacity: 1; transform: none; }
}

/* ---------- game list ---------- */

.search-wrap { display: grid; gap: 10px; margin: 12px 0 10px; }
.search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: 0 4px 12px rgba(70, 48, 18, 0.06);
}
.search span { font-size: 1.3rem; color: var(--text-dim); }
.search input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    padding: 14px 0;
    font: inherit;
    font-size: 1rem;
    color: var(--text);
}
.chips { display: flex; gap: 8px; }
.chips button {
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 999px;
    padding: 7px 14px 6px;
    font-family: var(--ui);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: 0.82rem;
}
.chips button.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.count { margin: 0; color: var(--text-dim); font-size: 0.85rem; }

.game-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.game-row {
    width: 100%;
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    text-align: left;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 14px;
    padding: 7px 10px 7px 7px;
}
.game-row:active { transform: scale(0.985); background: #fff; }
.game-pic {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 4 / 3;
    border-radius: 9px;
    overflow: hidden;
    background: linear-gradient(160deg, color-mix(in srgb, var(--accent, #ffb000) 55%, #1d1814), #0d0b09);
}
.game-pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.game-pic b { font-family: var(--stencil); font-weight: 400; color: rgba(255, 255, 255, 0.85); font-size: 1.5rem; }
.game-text { display: grid; gap: 2px; min-width: 0; }
.game-text strong { font-size: 0.98rem; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.game-text small { color: var(--text-dim); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-go {
    font-family: var(--ui);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.85rem;
    padding: 8px 12px 7px;
    border-radius: 10px;
    color: #fff;
    background: var(--red);
    box-shadow: 0 3px 0 #7c1a10;
}
.game-row.is-soon { opacity: 0.72; }
.game-row.is-soon .game-go { background: transparent; color: var(--text-dim); box-shadow: inset 0 0 0 1px var(--line); }
.shake { animation: shake 0.35s; }
@keyframes shake {
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
.loading-row, .empty { padding: 26px 10px; text-align: center; color: var(--text-dim); }
.link { border: 0; background: none; color: var(--amber-text); font-weight: 600; text-decoration: underline; padding: 0; }
.more {
    display: block;
    margin: 16px auto 0;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 12px;
    padding: 10px 18px;
    font-family: var(--ui);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ---------- sheets ---------- */

.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(20, 14, 6, 0.45); }
.sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 41;
    max-height: 92dvh;
    overflow-y: auto;
    padding: 10px 20px calc(var(--safe-bottom) + 22px);
    background: var(--surface);
    color: var(--text);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -16px 40px rgba(20, 14, 6, 0.25);
    transform: translateY(100%);
    transition: transform 0.25s ease-out;
}
.sheet.is-open { transform: none; }
.sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet-note { margin: 0 0 14px; color: var(--text-dim); font-size: 0.92rem; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: rgba(70, 48, 18, 0.07); margin-bottom: 14px; }
.tabs button { border: 0; background: transparent; border-radius: 9px; padding: 10px; font-family: var(--ui); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.tabs button.is-on { background: #fff; box-shadow: 0 2px 8px rgba(70, 48, 18, 0.12); }
.auth-form { display: grid; gap: 12px; }
.auth-form label { display: grid; gap: 5px; font-family: var(--ui); letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.8rem; color: var(--text-dim); }
.auth-form input {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 13px 14px;
    font: inherit;
    font-size: 1rem;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
    background: #fff;
}
.auth-form input:focus { outline: 2px solid var(--amber); border-color: transparent; }
.big-btn {
    border: 0;
    border-radius: 12px;
    padding: 14px;
    margin-top: 4px;
    font-family: var(--ui);
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-size: 1.05rem;
    color: #fff;
    background: var(--red);
    box-shadow: 0 4px 0 #7c1a10;
}
.big-btn:disabled { opacity: 0.6; }
.big-btn-ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--line); width: 100%; }
.auth-error { margin: 10px 0 0; min-height: 1.2em; color: #c0392b; font-size: 0.9rem; }
.signed-in p { margin: 0 0 12px; }

/* ---------- play ---------- */

body.play-app {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: #000;
    color: #f3ead7;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}
.stage { position: absolute; inset: 0; }
.screen-box { position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: #000; }
#game { position: absolute; inset: 0; }
#game canvas { width: 100% !important; height: 100% !important; }
#game .ejs_virtualGamepad_open,
#game .ejs_virtualGamepad_parent,
#game .ejs_menu_bar,
#game .ejs_context_menu { display: none !important; }

.boot-card {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: calc(var(--safe-top) + 20px) 24px calc(var(--safe-bottom) + 20px);
    text-align: center;
    background:
        radial-gradient(600px 300px at 50% 0%, rgba(255, 176, 0, 0.18), transparent 60%),
        #0d0b09;
}
.boot-card h1 { margin: 0 0 6px; font-family: var(--stencil); font-weight: 400; font-size: clamp(28px, 8vw, 44px); line-height: 1.05; }
.boot-card .bar-eyebrow { color: var(--amber); }
.boot-pic { width: min(64vw, 280px); aspect-ratio: 4 / 3; border-radius: 14px; overflow: hidden; background: #1d1814; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6); margin-bottom: 6px; }
.boot-pic img { width: 100%; height: 100%; object-fit: cover; }
.boot-note { margin: 4px 0 0; max-width: 34ch; color: #d9cdb6; font-size: 0.92rem; }
.boot-back {
    position: absolute;
    top: calc(var(--safe-top) + 14px);
    left: 16px;
    color: #f3ead7;
    text-decoration: none;
    font-family: var(--ui);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
@media (orientation: landscape) and (max-height: 520px) {
    .boot-card { flex-direction: row; flex-wrap: wrap; gap: 6px 18px; }
    .boot-pic { width: min(36vw, 240px); }
    .boot-card > :not(.boot-pic):not(.boot-back) { flex-basis: 50%; }
}

/* The play script sizes and places every control from the real screen size. */
.pad {
    --b: 64px;
    position: fixed;
    inset: 0;
    z-index: 10;
    touch-action: none;
}
.dpad {
    position: absolute;
    left: 20px;
    bottom: 20px;
    width: 170px;
    height: 170px;
    display: grid;
    grid-template: 1fr 1fr 1fr / 1fr 1fr 1fr;
    opacity: 0.9;
}
.dpad-arm {
    background: rgba(40, 36, 32, 0.86);
    border: 2px solid rgba(255, 255, 255, 0.22);
    position: relative;
}
.dpad-arm::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    border: 9px solid transparent;
    transform: translate(-50%, -50%);
}
.dpad-up { grid-area: 1 / 2; border-radius: 10px 10px 0 0; border-bottom: 0; }
.dpad-down { grid-area: 3 / 2; border-radius: 0 0 10px 10px; border-top: 0; }
.dpad-left { grid-area: 2 / 1; border-radius: 10px 0 0 10px; border-right: 0; }
.dpad-right { grid-area: 2 / 3; border-radius: 0 10px 10px 0; border-left: 0; }
.dpad-up::after { border-bottom-color: rgba(255, 255, 255, 0.7); margin-top: -4px; }
.dpad-down::after { border-top-color: rgba(255, 255, 255, 0.7); margin-top: 4px; }
.dpad-left::after { border-right-color: rgba(255, 255, 255, 0.7); margin-left: -4px; }
.dpad-right::after { border-left-color: rgba(255, 255, 255, 0.7); margin-left: 4px; }
.dpad-hub { grid-area: 2 / 2; background: rgba(40, 36, 32, 0.86); }
.dpad.is-up .dpad-up, .dpad.is-down .dpad-down, .dpad.is-left .dpad-left, .dpad.is-right .dpad-right { background: rgba(255, 176, 0, 0.85); }

.face {
    position: absolute;
    right: 20px;
    bottom: 20px;
    width: calc(var(--b) * 3.1);
    height: calc(var(--b) * 2.6);
}
.face-btn, .mid-btn, .shoulder-btn {
    position: absolute;
    border: 0;
    padding: 0;
    font-family: var(--stencil);
    font-weight: 400;
    color: #fff;
    text-shadow: 0 2px 2px rgba(0, 0, 0, 0.5);
    touch-action: none;
    transition: transform 0.05s, filter 0.05s;
}
.face-btn {
    width: var(--b);
    height: var(--b);
    border-radius: 50%;
    font-size: calc(var(--b) * 0.4);
    background-color: var(--btn);
    background-image: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0) 45%, rgba(0, 0, 0, 0.3) 100%);
    box-shadow: 0 5px 0 rgba(0, 0, 0, 0.45), inset 0 -3px 6px rgba(0, 0, 0, 0.25), 0 0 0 2px rgba(255, 255, 255, 0.18);
}
.face-btn.is-down, .mid-btn.is-down, .shoulder-btn.is-down { transform: translateY(3px) scale(0.94); filter: brightness(1.35); }
.face-btn.is-down { box-shadow: 0 2px 0 rgba(0, 0, 0, 0.45), 0 0 18px var(--btn); }

/* Neo Geo style arc: A low left, D high right. */
.face-arc .face-btn:nth-child(1) { left: 0; bottom: 0; }
.face-arc .face-btn:nth-child(2) { left: 26%; bottom: 30%; }
.face-arc .face-btn:nth-child(3) { left: 52%; bottom: 46%; }
.face-arc .face-btn:nth-child(4) { right: 0; top: 0; }
.face-six .face-btn { width: calc(var(--b) * 0.95); height: calc(var(--b) * 0.95); }
.face-six .face-btn:nth-child(1) { left: 0; top: 4%; }
.face-six .face-btn:nth-child(2) { left: 36%; top: 0; }
.face-six .face-btn:nth-child(3) { right: 0; top: 4%; }
.face-six .face-btn:nth-child(4) { left: 0; bottom: 4%; }
.face-six .face-btn:nth-child(5) { left: 36%; bottom: 0; }
.face-six .face-btn:nth-child(6) { right: 0; bottom: 4%; }
.face-pair .face-btn { width: calc(var(--b) * 1.15); height: calc(var(--b) * 1.15); }
.face-pair .face-btn:nth-child(1) { left: 0; bottom: 0; }
.face-pair .face-btn:nth-child(2) { right: 0; top: 0; }
.face-diamond .face-btn:nth-child(1) { left: 50%; top: 0; transform: translateX(-50%); }
.face-diamond .face-btn:nth-child(2) { left: 0; top: 50%; transform: translateY(-50%); }
.face-diamond .face-btn:nth-child(3) { right: 0; top: 50%; transform: translateY(-50%); }
.face-diamond .face-btn:nth-child(4) { left: 50%; bottom: 0; transform: translateX(-50%); }
.face-diamond .face-btn:nth-child(1).is-down, .face-diamond .face-btn:nth-child(4).is-down { transform: translateX(-50%) scale(0.92); }
.face-diamond .face-btn:nth-child(2).is-down, .face-diamond .face-btn:nth-child(3).is-down { transform: translateY(-50%) scale(0.92); }
.face-row .face-btn { width: calc(var(--b) * 0.98); height: calc(var(--b) * 0.98); }
.face-row .face-btn:nth-child(1) { left: 0; bottom: 0; }
.face-row .face-btn:nth-child(2) { left: 34%; bottom: 25%; }
.face-row .face-btn:nth-child(3) { right: 0; bottom: 50%; }

.mid-btn, .shoulder-btn {
    width: 92px;
    height: 36px;
    border-radius: 999px;
    font-family: var(--ui);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.82rem;
    background: rgba(40, 36, 32, 0.86);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.22);
}
.shoulder-btn { border-radius: 12px; font-family: var(--stencil); font-weight: 400; font-size: 1.05rem; letter-spacing: 0.06em; }

/* When the controls have to sit over the picture, let the game show through. */
.pad.is-overlay .dpad { opacity: 0.55; }
.pad.is-overlay .face-btn { opacity: 0.6; }
.pad.is-overlay .mid-btn, .pad.is-overlay .shoulder-btn { opacity: 0.6; }

.hud {
    position: fixed;
    z-index: 12;
    left: 10px;
    top: calc(var(--safe-top) + 8px);
    display: flex;
    gap: 6px;
}
.hud button {
    min-width: 44px;
    height: 34px;
    padding: 0 10px;
    border: 0;
    border-radius: 10px;
    font-family: var(--ui);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.76rem;
    color: #fff;
    background: rgba(40, 36, 32, 0.8);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.18);
}
.hud button:active { background: rgba(255, 176, 0, 0.9); color: var(--ink); }
.hud.is-stack { display: grid; grid-template-columns: 1fr 1fr; }
#hud-save { background: rgba(60, 170, 74, 0.85); }
#hud-load { background: rgba(61, 122, 223, 0.85); }

.pad-toast {
    position: fixed;
    z-index: 30;
    top: calc(var(--safe-top) + 56px);
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    padding: 9px 16px 8px;
    border-radius: 999px;
    background: rgba(255, 176, 0, 0.95);
    color: var(--ink);
    font-family: var(--ui);
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-size: 0.85rem;
    white-space: nowrap;
    pointer-events: none;
}
.pad-toast.is-on { animation: fade-up 0.25s ease-out both; }

.game-menu { background: #1a1612; color: #f3ead7; }
.game-menu h2 { margin: 0 0 12px; font-family: var(--stencil); font-weight: 400; font-size: 1.6rem; text-align: center; }
.game-menu .sheet-grip { background: rgba(255, 255, 255, 0.2); }
.game-menu .sheet-note { color: #d9cdb6; text-align: center; margin: 10px auto 12px; max-width: 520px; }
.menu-label {
    max-width: 520px;
    margin: 14px auto 8px;
    font-family: var(--ui);
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 0.78rem;
    color: var(--amber);
}
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 520px; margin: 0 auto; }
.menu-grid button, .slot-actions button {
    border: 0;
    border-radius: 12px;
    padding: 14px 10px;
    font-family: var(--ui);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.08);
    color: #f3ead7;
}
.menu-grid .is-main { grid-column: 1 / -1; background: var(--amber); color: var(--ink); font-size: 1.1rem; }
.menu-grid .is-exit { grid-column: 1 / -1; background: rgba(226, 59, 34, 0.9); color: #fff; }

.slot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 520px; margin: 0 auto; }
.slot {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    grid-template-rows: auto auto;
    gap: 6px 10px;
    padding: 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.slot-shot {
    grid-row: 1;
    width: 64px;
    aspect-ratio: 4 / 3;
    border-radius: 6px;
    overflow: hidden;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--stencil);
    color: rgba(255, 255, 255, 0.3);
    font-size: 1.3rem;
}
.slot-shot img { width: 100%; height: 100%; object-fit: cover; }
.slot-info { display: grid; align-content: center; gap: 2px; min-width: 0; }
.slot-info strong { font-family: var(--ui); letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.86rem; }
.slot-info small { color: #b9ad96; font-size: 0.78rem; }
.slot-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.slot-actions button { padding: 9px 6px; font-size: 0.8rem; }
.slot-actions [data-save] { background: rgba(60, 170, 74, 0.85); color: #fff; }
.slot-actions [data-load] { background: rgba(61, 122, 223, 0.85); color: #fff; }
.slot-actions button:disabled { opacity: 0.35; }
.slot.is-empty .slot-info strong { color: #b9ad96; }

@media (orientation: landscape) and (max-height: 520px) {
    .game-menu { max-height: 100vh; max-height: 100dvh; padding-top: 6px; }
    .game-menu h2 { font-size: 1.2rem; margin-bottom: 6px; }
    .game-menu .menu-grid, .game-menu .slot-grid, .menu-label, .game-menu .sheet-note { max-width: 760px; }
    .menu-grid { grid-template-columns: repeat(3, 1fr); }
    .slot-grid { grid-template-columns: repeat(4, 1fr); }
    .slot { grid-template-columns: 1fr; }
    .slot-shot { width: 100%; }
    .menu-label { margin-top: 8px; }
}
