:root {
    --bg: #13181c;
    --card: #171923;
    --text: #e8eaf0;
    --muted: #9aa0aa;
    --accent: #7dd3fc;
    --danger: #f87171;
    --good: #34d399;
    --shadow: 0 8px 24px rgba(0,0,0,0.35);
    --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin:0; height:100%; }
body { font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji"; background: var(--bg); color: var(--text); }

.app-header{ text-align:center; padding: 12px 16px; }
.app-header h1 { margin:0; font-size: 46px; }
.img-header { width: 64px; height: 64px; border-radius: 999px; object-fit: cover; margin-bottom: 8px; }


.screen { display:none; padding: 12px; max-width: 1000px; margin: 0 auto; }
.screen.active { display:block; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; margin: 12px;}
#card-mobile-app { display: flex; flex-direction: column; align-items: center; text-align: center }

.list-rules { align-content: center }

.btn { appearance:none; border:none; border-radius: 999px; padding: 12px 16px; background: #2a2f3b; color: var(--text); font-weight: 600; cursor: pointer; box-shadow: var(--shadow); }
.btn.primary { background: linear-gradient(135deg, #2563eb, #7c3aed); }
.btn.ghost { background: transparent; border: 1px solid #2f3542; }
.btn.danger { background: var(--danger); color: white; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.players-list { display: grid; gap: 10px; }
.player-row { display: flex; align-items: center; background: #1d2230; border-radius: 12px; padding: 8px; }
.player-row input[type="text"] { width: 100%; padding: 10px 12px; margin: 8px; border-radius: 10px; border: 1px solid #2f3542; background: #0f1320; color: var(--text); }
.order-buttons { display:flex; gap:6px; }
.order-buttons .btn { padding: 8px 10px; }
.remove-btn { background: transparent; color: var(--danger); border: 1px solid var(--danger); padding: 4px 4px; margin: 8px;}

.setup-actions, .start-actions { display:flex; gap: 10px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.legend { color: var(--muted); margin-top: 6px; font-size: 13px; text-align:center; }

.status-bar { display:flex; justify-content: space-between; gap: 8px; margin-bottom: 10px; align-items: center; }
.turn-info { font-weight: 700; }
.game-info { color: var(--muted); }

.scoreboard { overflow: hidden; }
.score-scroll { overflow-x: auto; }
.score-table { border-collapse: separate; border-spacing: 0; width: 100%;}
.score-table thead th { position: sticky; top: 0; background: #0f1320; z-index: 2; }
.col-player { text-align: left; padding: 10px; min-width: 180px; }
.score-table th, .score-table td { border-bottom: 1px solid #2a2f3b; padding: 8px; text-align: center; }
.player-cell { display:flex; align-items:center; gap:8px; font-weight: 700; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid #2f3542; color: var(--muted); }
.total { font-weight: 800; }

.cell { cursor: pointer; border-radius: 8px; }
.cell.selected { outline: 2px solid var(--accent); }
.cell.reset25 { background: rgba(125, 211, 252, 0.15); }
.cell.miss { color: var(--muted); }
.row-eliminated { opacity: 0.6; }
.row-winner { background: rgba(52, 211, 153, 0.12); }

.keypad {}
.keypad-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.key { padding: 14px 0; border-radius: 12px; border: 1px solid #2f3542; background:#0f1320; font-size: 18px; font-weight: 800; cursor: pointer; color: whitesmoke }
.key.special { font-weight: 700; }
.key:active { transform: scale(0.98); }
.keypad-actions { display:flex; gap:8px; margin-top: 10px; }
#missBtn { padding: 14px 0; border-radius: 12px; border: 1px solid #ff1313; background: #fd4c4c; font-size: 18px; font-weight: 800; cursor: pointer; color: whitesmoke }
#appFooter { bottom: 0; left: 0; right: 0; z-index: 10; text-align:center; padding: 12px 16px; color: var(--muted);}

.img-app-icon { border-radius: 12px; width: 48px; height: 48px; object-fit: cover; }
.div-app-icon {display: flex; flex-direction: column; justify-content: center; align-items: center; }

/* Mölkky instruction board */
.molkky-board {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.molkky-title {
    margin: 0 0 4px 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.molkky-rows {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center; /* center triangle within the card */
}

/* Each row is centered; logs have equal spacing */
.molkky-row {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Log styling */
.log {
    --log-size: 48px;            /* tweak size if needed */
    width: var(--log-size);
    height: var(--log-size);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 800;
    color: #0b0b0f;
    background: radial-gradient(ellipse at 30% 30%, #f7e7c6 0%, #e3c89a 55%, #c9a875 100%);
    border: 2px solid rgba(0,0,0,0.2);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2), 0 2px 8px rgba(0,0,0,0.25);
    user-select: none;
}

/* Slight size tuning per row to hint at depth (optional) */
.molkky-row:nth-child(1) .log { --log-size: 46px; }
.molkky-row:nth-child(2) .log { --log-size: 48px; }
.molkky-row:nth-child(3) .log { --log-size: 50px; }
.molkky-row:nth-child(4) .log { --log-size: 52px; }

/* Subtle hover on desktop */
@media (hover: hover) {
    .log:hover {
        transform: translateY(-2px);
        box-shadow: inset 0 2px 4px rgba(0,0,0,0.18), 0 6px 14px rgba(0,0,0,0.35);
    }
}

.molkky-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
    opacity: 0.9;
}

/* Mobile-friendly tightening */
@media (max-width: 420px) {
    .molkky-row { gap: 8px; }
    .molkky-row .log { --log-size: 42px; }
    .molkky-row:nth-child(3) .log { --log-size: 44px; }
    .molkky-row:nth-child(4) .log { --log-size: 46px; }
}




/* Scoreboard container */
#scoreTable {
    display: flex;
    flex-direction: column; /* vertical rounds */
    gap: 5px;
    font-family: Arial, sans-serif;
    margin-top: 20px;
}

/* Each row: header, round, total */
.score-row {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Round number column */
.round-number {
    width: 40px;
    font-weight: bold;
    text-align: center;
    background-color: #222;
    color: #fff;
    border-radius: 4px;
    padding: 4px 0;
}

.round-header {
    width: 40px;
    font-weight: bold;
    text-align: center;
    background-color: #222;
    color: #fff;
    border-radius: 4px;
    padding: 4px 0;
}

/* Header row */
.header-row {
    font-weight: bold;
    font-size: 1.1em;
}

.player-name-header {
    flex: 1;
    text-align: center;
    color: #fff;
    padding: 4px 2px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Score cells for each player */
.score-cell {
    flex: 1;
    text-align: center;
    padding: 6px 0;
    border-radius: 4px;
    background-color: rgba(240, 240, 240, 0.1);
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

/* Highlight current player */
.current-player {
    color: black;
    border: 2px solid #333;
    background-color: #fae56d !important;
}

/* Editing mode */
.score-cell.editing {
    background-color: #ff8e49 !important;
}

/* Totals row */
.total-row {
    font-weight: bold;
    font-size: 1em;
    margin-top: 5px;
}

.total-row .total-cell {
    color: white;
    flex: 1;
    text-align: center;
    padding: 6px 0;
    border-radius: 4px;
    background-color: rgba(240, 240, 240, 0.3);
}

/* Eliminated players */
.player-name-header.eliminated,
.score-cell.eliminated {
    background-color: #b2bec3 !important;
    color: #636e72 !important;
}

/* Optional: spacing for scoreboard */
#scoreTable .score-row + .score-row {
    margin-top: 3px;
}

.current-player-card {
    position: sticky;   /* stays at bottom of viewport */
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card);
    box-shadow: 0 -2px 6px rgba(0,0,0,0.1);
    padding: 12px;
    margin-top: 10px;
    text-align: center;
    z-index: 100;
}

.current-player-card h3 {
    margin: 0;
    font-size: 1.2em;
    font-weight: bold;
}

.current-player-card p {
    margin: 4px 0 0;
    font-size: 1em;
}

