@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ── TOKENS ──────────────────────────────────────────────── */
:root {
    --bg:        #0f0f11;
    --surface:   #18181c;
    --surface2:  #222228;
    --border:    #2e2e38;
    --text:      #f0f0f0;
    --muted:     #6b6b7a;
    --accent:    #e8e8e8;
    --green:     #4ade80;
    --red:       #f87171;
    --radius:    10px;
    --mono:      'DM Mono', monospace;
    --sans:      'DM Sans', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    min-height: 100vh;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

/* ── SCREENS ─────────────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: block; }

/* ── LOBBY ───────────────────────────────────────────────── */
#screen-lobby {
    max-width: 440px;
    margin: 0 auto;
    padding: 48px 20px;
}

.logo {
    font-family: var(--mono);
    font-size: 2.8rem;
    font-weight: 500;
    letter-spacing: -2px;
    margin-bottom: 8px;
    color: var(--text);
}

.tagline {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 40px;
    font-weight: 300;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 12px;
}

.card-label {
    font-size: 0.75rem;
    font-family: var(--mono);
    color: var(--muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 12px;
}

input[type=text] {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--sans);
    font-size: 0.95rem;
    margin-bottom: 10px;
    outline: none;
    transition: border-color 0.15s;
}

input[type=text]:focus {
    border-color: var(--muted);
}

.btn {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-family: var(--sans);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s;
}

.btn:hover { opacity: 0.85; }

.btn-primary {
    background: var(--text);
    color: var(--bg);
}

.btn-secondary {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-green {
    background: var(--green);
    color: #000;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: var(--muted);
}

.toggle-btn {
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
    font-size: 0.8rem;
    cursor: pointer;
    font-family: var(--mono);
    transition: all 0.15s;
}

.toggle-btn.active {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}

.error { color: var(--red); font-size: 0.85rem; margin-top: 8px; }
.hint  { color: var(--muted); font-size: 0.8rem; margin-bottom: 10px; }

/* ── WAITING ROOM ────────────────────────────────────────── */
#screen-waiting {
    max-width: 480px;
    margin: 0 auto;
    padding: 48px 20px;
}

.room-code {
    font-family: var(--mono);
    font-size: 3rem;
    font-weight: 500;
    letter-spacing: 8px;
    color: var(--text);
    margin: 8px 0 4px;
}

.player-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.player-entry:last-child { border-bottom: none; }

.player-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.player-type {
    color: var(--muted);
    font-size: 0.8rem;
    font-family: var(--mono);
    margin-left: auto;
}

.bot-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0;
}

.bot-controls button {
    padding: 5px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 0.8rem;
    font-family: var(--mono);
    cursor: pointer;
    transition: border-color 0.15s;
}

.bot-controls button:hover { border-color: var(--muted); }

/* Color picker */
.color-picker {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s;
}

.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: var(--text); }

/* ── GAME SCREEN ─────────────────────────────────────────── */
#game-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    font-family: var(--mono);
    font-size: 0.85rem;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

#round-display { color: var(--muted); }
#turn-display  { color: var(--text); font-weight: 500; }

.btn-small {
    margin-left: auto;
    padding: 5px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted);
    font-size: 0.8rem;
    font-family: var(--mono);
    cursor: pointer;
    transition: border-color 0.15s;
}

.btn-small:hover { border-color: var(--muted); color: var(--text); }

#game-main {
    display: flex;
    height: calc(100vh - 45px);
    max-width: 1200px;
    margin: 40px auto 0;
    width: 100%;
}

#game-left {
    flex: 1;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    border-right: 1px solid var(--border);
}

#game-right {
    width: 460px;
    min-width: 460px;
    padding: 20px;
    overflow-y: auto;
}

/* ── DICE ────────────────────────────────────────────────── */
#dice-area {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

#dice-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    min-height: 80px;
    align-items: center;
}

.die {
    width: 76px;
    height: 76px;
    background: var(--accent);
    border-radius: 10px;
    display: grid;
    grid-template-areas:
        "a . b"
        "c e d"
        "f . g";
    padding: 10px;
    gap: 2px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.12s;
    user-select: none;
}

.die.kept {
    background: var(--green);
    border-color: #22c55e;
}

.die:hover { transform: translateY(-2px); }

.pip {
    width: 11px;
    height: 11px;
    background: var(--bg);
    border-radius: 50%;
    margin: auto;
}

.die.kept .pip { background: #000; }

#roll-info {
    text-align: center;
    color: var(--muted);
    margin-top: 10px;
    font-family: var(--mono);
    font-size: 0.8rem;
}

/* ── CONTROLS ────────────────────────────────────────────── */
#controls { display: flex; gap: 8px; }
#controls .btn { margin: 0; }

#message {
    font-size: 0.85rem;
    color: var(--muted);
    font-family: var(--mono);
    min-height: 18px;
}

/* ── CATEGORIES ──────────────────────────────────────────── */
#category-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

#category-panel h3 {
    font-size: 0.75rem;
    font-family: var(--mono);
    color: var(--muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

#category-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}

.cat-btn {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.82rem;
    font-family: var(--sans);
    text-align: left;
    background: transparent;
    color: var(--muted);
    transition: all 0.12s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cat-btn.has-points {
    border-color: var(--green);
    color: var(--text);
    background: rgba(74, 222, 128, 0.05);
}

.cat-btn:hover { border-color: var(--muted); color: var(--text); }

.cat-pts {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--green);
}

/* ── BOT LOG ─────────────────────────────────────────────── */
#bot-log {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
}

#bot-log-content {
    display: none;
    margin-top: 8px;
    max-height: 150px;
    overflow-y: auto;
}

#bot-log-title {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.log-line {
    font-family: var(--mono);
    font-size: 0.78rem;
    margin-bottom: 2px;
    color: var(--muted);
}

.log-line.green { color: var(--green); }
.log-line.gray  { color: #444; }

/* ── SCORECARD ───────────────────────────────────────────── */
.sc-section-label {
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 6px 0 4px;
}

#scorecard table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

#scorecard th {
    text-align: right;
    padding: 4px 4px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.75rem;
    font-weight: 400;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    
    
}

#scorecard th:first-child { text-align: left; }

#scorecard td {
    padding: 4px 4px;
    border-bottom: 1px solid #1a1a20;
    text-align: right;
    font-family: var(--mono);
    color: var(--muted);
    white-space: nowrap;
}

#scorecard td:first-child {
    text-align: left;
    color: var(--text);
    font-family: var(--sans);
    font-size: 0.82rem;
}

#scorecard td.filled { color: var(--text); }
#scorecard td.zero   { color: #333; }

#scorecard tr.section-divider td {
    padding: 2px 0;
    border: none;
    background: transparent;
}

#scorecard tr.bonus-row td { color: var(--green); }
#scorecard tr.total-row td {
    font-weight: 600;
    color: var(--text);
    border-top: 1px solid var(--border);
    padding-top: 8px;
    font-size: 0.9rem;
}

#your-turn-banner {
    display: none;
    background: var(--green);
    color: #000;
    text-align: center;
    padding: 8px;
    font-family: var(--mono);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 1px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.6; }
}

/* ── GAME OVER ───────────────────────────────────────────── */
#game-over-banner {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    font-family: var(--mono);
}

/* ── MOBILE ──────────────────────────────────────────────── */
@media (max-width: 768px) {
    #game-main { flex-direction: column; height: auto; }
    #game-left { width: 100%; min-width: unset; border-right: none; border-bottom: 1px solid var(--border); }
    #game-right { width: 100%; min-width: unset; }
    #dice-container { gap: 8px; }
    .die { width: 62px; height: 62px; padding: 8px; }
    .pip { width: 9px; height: 9px; }
    #controls { flex-direction: column; }
    #category-list { grid-template-columns: 1fr; }
    .room-code { font-size: 2.2rem; letter-spacing: 6px; }
    #scorecard table { font-size: 0.72rem; }
    #scorecard th, #scorecard td { padding: 3px 4px; }
}