* {
    box-sizing: border-box;
}

:root {
    --bg: #101417;
    --panel: #171d21;
    --panel-2: #20282d;
    --tile: #29333a;
    --tile-hover: #334149;
    --text: #f2f5f7;
    --muted: #93a2ab;
    --line: #334047;
    --accent: #5de2a5;
    --accent-dark: #1ba86a;
    --danger: #ff6474;
    --gem: #7bdcff;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.game-panel {
    width: min(1100px, 100%);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: end;
    margin-bottom: 18px;
}

.eyebrow {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.18em;
    font-weight: 800;
}

h1 {
    margin: 2px 0 0;
    font-size: clamp(34px, 6vw, 56px);
    line-height: 1;
}

.balance-box {
    text-align: right;
}

.balance-box span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}

.balance-box strong {
    font-size: 22px;
}

.layout {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 18px;
}

.controls,
.board-wrap {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
}

.controls {
    padding: 20px;
}

.controls label {
    display: block;
    margin-bottom: 16px;
}

.controls label > span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.input-wrap {
    display: flex;
    align-items: center;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
}

.input-wrap > span {
    padding-left: 12px;
    color: var(--muted);
    font-size: 13px;
}

input,
select {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    padding: 12px;
}

select {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 10px;
}

.quick-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: -8px;
    margin-bottom: 18px;
}

.mini-btn {
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    padding: 9px;
    border-radius: 8px;
}

.stats {
    display: grid;
    gap: 8px;
    margin: 18px 0;
}

.stats > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    padding: 11px 12px;
    border-radius: 10px;
}

.stats span {
    color: var(--muted);
    font-size: 13px;
}

.stats strong {
    font-size: 14px;
}

.primary-btn,
.cashout-btn {
    width: 100%;
    border: 0;
    border-radius: 10px;
    padding: 13px 16px;
    font-weight: 800;
    margin-top: 8px;
}

.primary-btn {
    background: var(--accent);
    color: #0c1a14;
}

.cashout-btn {
    background: #ffc85f;
    color: #2a1d00;
}

.primary-btn:disabled,
.cashout-btn:disabled,
.mini-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.message {
    min-height: 42px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
    margin: 16px 0 0;
}

.board-wrap {
    padding: 20px;
    display: grid;
    place-items: center;
}

.board {
    width: min(620px, 100%);
    aspect-ratio: 1;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 10px;
}

.tile {
    position: relative;
    border: 0;
    border-radius: 13px;
    background: var(--tile);
    box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .16);
    color: var(--text);
    display: grid;
    place-items: center;
    font-size: clamp(24px, 5vw, 44px);
    font-weight: 900;
    transition: transform .12s ease, background .12s ease;
}

.tile:not(:disabled):hover {
    background: var(--tile-hover);
    transform: translateY(-2px);
}

.tile.safe {
    background: rgba(123, 220, 255, .13);
    color: var(--gem);
    box-shadow: inset 0 0 0 2px rgba(123, 220, 255, .25);
}

.tile.mine {
    background: rgba(255, 100, 116, .14);
    color: var(--danger);
    box-shadow: inset 0 0 0 2px rgba(255, 100, 116, .26);
}

.tile.unrevealed-end {
    opacity: .6;
}

@media (max-width: 820px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .controls {
        order: 2;
    }

    .board-wrap {
        order: 1;
    }
}

@media (max-width: 520px) {
    .app-shell {
        padding: 12px;
    }

    .board-wrap,
    .controls {
        border-radius: 12px;
        padding: 12px;
    }

    .board {
        gap: 6px;
    }

    .tile {
        border-radius: 9px;
    }
}

.player-account {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 9px;
}

.player-account > span {
    color: var(--muted);
    font-size: 12px;
}

.logout-form {
    margin: 0;
}

.logout-button {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}
