/* Drift Cup Free - Styles */

body {
    font-family: 'Roboto', sans-serif;
}

/* Join card — the light shape, titled in the game's own gold. */
.join-card {
    --join-title: var(--accent-gold);
}

/* Header inside the card: one line — name, best, attempts left. */
.drift-container .cup-free-header {
    padding-top: 0;
    margin-bottom: 10px;
}

.drift-container .cup-free-stats {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 14px;
}

.drift-container .cup-free-player {
    color: var(--text-main);
    font-size: 0.95rem;
}

.drift-container .cup-free-best-label { color: var(--accent-teal); }

.drift-container .cup-free-best-num {
    color: var(--text-main);
    font-size: 1.25rem;
}

/* The board sits on the same light card as everything else on the page. */
.drift-container {
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
    padding: 14px 12px 10px;
    background: transparent;
    border: 1px solid var(--accent-gold);
    border-radius: 12px;
    box-sizing: border-box;
    color: var(--ink);
}

.drift-stat {
    background: var(--bg-primary);
    border: 1px solid var(--accent-gold);
    padding: 6px 14px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-teal);
    min-width: 88px;
}

.drift-stat span {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
    margin-top: 3px;
}

/* Drift uses the shared .grid / .cell component (components/cell.css).
   gap=0 is required so .drift-dot's translate math (col*100% of its own width) stays exact. */
.drift-container .grid {
    --drift-size: 10;
    --grid-gap: 0;
    --grid-padding: 0;
    --grid-bg: #14161b;
    --grid-cell-bg: #14161b;
    --grid-cell-border: var(--ink-2);

    position: relative;
    margin: 12px auto 6px;
    border-radius: 10px;
    /* One hairline closes the lattice on all four sides. */
    box-shadow: inset 0 0 0 1px var(--ink-2);
    overflow: hidden;
}

/* A cell fills its track. The grid width is the one number the board, the
   cells and the dot's translate math all derive from — size a cell from the
   viewport instead and the three disagree on any screen wider than a phone. */
.drift-container .cell {
    width: 100%;
    border-radius: 0;
    transition: background 120ms ease, box-shadow 120ms ease;
}

.drift-container .cell.drift-target {
    background: var(--accent-gold);
}

.drift-container .cell.drift-indicator {
    background: var(--accent-teal);
    box-shadow: inset 0 0 0 2px var(--accent-teal);
}

.drift-container .cell.drift-target.drift-indicator {
    background: var(--accent-gold);
    box-shadow: inset 0 0 0 3px var(--accent-teal);
}

/* Dot: absolutely positioned at top-left of the grid content area, sized to one cell.
   translate(col*100%, row*100%) precisely lands it on cell (col, row). */
.drift-dot {
    position: absolute;
    top: 0;
    left: 0;
    width: calc(100% / var(--drift-size));
    height: calc(100% / var(--drift-size));
    background: #e63946;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(230, 57, 70, 0.7);
    transition: transform 100ms ease;
    pointer-events: none;
    z-index: 2;
    /* Shrink the visual circle slightly so it doesn't cover the cell borders entirely. */
    transform-origin: top left;
    box-sizing: border-box;
    border: 3px solid transparent;
    background-clip: padding-box;
}

/* Off-grid direction arrow overlay (when the random direction points outside the grid). */
.drift-dot.drift-arrow-N::after,
.drift-dot.drift-arrow-S::after,
.drift-dot.drift-arrow-E::after,
.drift-dot.drift-arrow-W::after {
    content: '';
    position: absolute;
    inset: 0;
    color: #ffd166;
    font-weight: 900;
    font-size: 1.4em;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 0 0 4px var(--ink);
}
.drift-dot.drift-arrow-N::after { content: '↑'; }
.drift-dot.drift-arrow-S::after { content: '↓'; }
.drift-dot.drift-arrow-E::after { content: '→'; }
.drift-dot.drift-arrow-W::after { content: '←'; }

/* Status text */
.drift-status {
    text-align: center;
    padding: 10px;
    margin: 10px auto;
    max-width: 500px;
    background: var(--bg-primary);
    border: 1px solid var(--accent-gold);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.875rem;
}

.drift-status:empty { display: none; }

/* Controls */
.drift-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 6px auto 14px;
    max-width: 500px;
    flex-wrap: wrap;
}

/* The button owns its own line, the width of the board. Sized against the
   two stat chips instead, it overflows and leaves one chip stranded below. */
.drift-controls button {
    flex-basis: 100%;
    padding: 22px 52px;
    font-size: 1.35rem;
    letter-spacing: 0.06em;
    cursor: pointer;
    background: var(--accent-teal);
    color: white;
    border: none;
    border-radius: 999px;
    margin: 0;
    font-weight: bold;
    transition: background 120ms ease, transform 80ms ease;
}

.drift-controls button:hover {
    background: var(--accent-teal-dark);
}

.drift-controls button:active {
    transform: translateY(1px);
}

.drift-controls button:disabled {
    background: var(--ink-2);
    cursor: not-allowed;
    opacity: 0.7;
}

#drift-press-btn {
    background: var(--danger);
    min-width: 260px;
}

#drift-press-btn:hover {
    background: var(--danger-dark);
}

/* Leaderboard sits on the page now, so it keeps the shared colours. */
.free-leaderboard table { background: var(--surface); }
.free-leaderboard td { color: var(--ink); }

/* Mobile: minimum padding per project rule */
@media (max-width: 480px) {
    .drift-stat { padding: 5px 10px; min-width: 74px; }
    .drift-stat span { font-size: 1rem; }
    /* responsive.css pads .grid by 4px here as a literal, bypassing
       --grid-padding. That padding widens the dot's containing block without
       widening the row of cells, so the dot drifts off by 0.8px a column. */
    .drift-container .grid { margin: 12px auto 6px; padding: 0; }
    .drift-controls { margin: 6px auto 10px; }
    .drift-container { padding: 8px 2px 4px; }
    .drift-controls button { padding: 18px 34px; font-size: 1.2rem; }
    #drift-press-btn { min-width: 200px; }
}
