/* Shared Snakes & Ladders styling — hub, local (pass & play) and online pages. */
* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Courier Prime', 'Courier New', monospace;
    -webkit-tap-highlight-color: transparent;
}
.wrap {
    max-width: 640px;
    margin: 0 auto;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.topbar { display: flex; align-items: center; gap: var(--spacing-sm); padding-top: var(--spacing-sm); }
.back-link {
    display: inline-flex; align-items: center; gap: 6px;
    text-decoration: none; color: var(--text-secondary);
    font-size: 0.95rem; padding: 6px 12px; border-radius: 20px;
    background: var(--bg-card); box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform .15s ease;
}
.back-link:hover { transform: translateX(-3px); }

.title { text-align: center; margin: var(--spacing-xs) 0 0; }
.title h1 {
    font-family: 'Cinzel', serif; font-weight: 700;
    font-size: clamp(1.9rem, 7vw, 2.6rem); margin: 0; letter-spacing: 1px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.title .sub { color: var(--text-secondary); font-size: 0.9rem; letter-spacing: 2px; text-transform: uppercase; margin-top: 2px; }

/* ---- Player scoreboard ---- */
.players { display: grid; grid-template-columns: 1fr 1fr; gap: var(--spacing-sm); }
.player {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border-radius: var(--radius-lg); background: var(--bg-card);
    border: 2px solid transparent; box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: border-color .2s, transform .2s, box-shadow .2s; min-width: 0;
}
.player.active {
    border-color: var(--p-color); transform: translateY(-2px);
    box-shadow: 0 6px 16px color-mix(in srgb, var(--p-color) 40%, transparent);
}
.player.offline { opacity: 0.55; }
.pawn-badge {
    width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--p-color) 70%, #fff), var(--p-color));
    box-shadow: inset 0 -3px 5px rgba(0,0,0,0.25), 0 2px 4px rgba(0,0,0,0.2);
    background-size: cover; background-position: center;
}
.player .meta { line-height: 1.3; min-width: 0; flex: 1; }
.player .name-input {
    font-family: 'Special Elite', monospace; font-size: 1rem;
    background: transparent; border: none; border-bottom: 1px dashed transparent;
    color: var(--text-primary); width: 100%; padding: 0; outline: none;
}
.player .name-input:focus { border-bottom-color: var(--p-color); }
.player .name-static { font-family: 'Special Elite', monospace; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .sq { font-size: 0.8rem; color: var(--text-secondary); }
.player.active .sq { color: var(--p-color); font-weight: bold; }
.player .you-tag {
    font-size: 0.6rem; letter-spacing: 1px; text-transform: uppercase;
    background: var(--p-color); color: #fff; padding: 1px 5px; border-radius: 4px; margin-left: 4px;
    display: none;
}
.player.is-you .you-tag { display: inline-block; }

/* ---- Board ---- */
.board-frame {
    position: relative; width: 100%; padding: 14px; border-radius: 16px;
    background:
        repeating-linear-gradient(45deg, rgba(120,72,40,.12) 0 6px, transparent 6px 12px),
        linear-gradient(160deg, #8a5a34, #6b4423);
    box-shadow: 0 10px 30px rgba(0,0,0,0.25), inset 0 0 0 3px rgba(255,255,255,0.08);
}
.board {
    position: relative; aspect-ratio: 1 / 1; width: 100%;
    display: grid; grid-template-columns: repeat(10, 1fr); grid-template-rows: repeat(10, 1fr);
    border-radius: 8px; overflow: hidden; background: #f3ead6;
}
.cell {
    position: relative; display: flex; align-items: flex-start; justify-content: flex-start;
    font-size: clamp(0.5rem, 1.8vw, 0.72rem); font-family: 'Special Elite', monospace;
    padding: 2px 3px; color: #5b4a36;
}
.cell .n { opacity: 0.5; pointer-events: none; }
.cell.dark  { background: #e7d7b8; }
.cell.light { background: #f3ead6; }
.cell.home  { background: linear-gradient(135deg, #f5d67a, #e8b53c); }
.cell.start { background: linear-gradient(135deg, #bfe3c0, #92c996); }

svg.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.pawn {
    position: absolute; width: 7%; height: 7%; border-radius: 50%; z-index: 5;
    transform: translate(-50%, -50%); transition: left .28s ease, top .28s ease;
    box-shadow: inset 0 -3px 5px rgba(0,0,0,0.3), 0 3px 6px rgba(0,0,0,0.35);
    border: 2px solid rgba(255,255,255,0.7);
    background-size: cover; background-position: center;
}

/* ---- Controls ---- */
.controls { display: flex; align-items: center; justify-content: center; gap: var(--spacing-lg); flex-wrap: wrap; }
.dice {
    width: 74px; height: 74px; border-radius: 16px;
    background: linear-gradient(145deg, #ffffff, #eadfce);
    box-shadow: 0 6px 14px rgba(0,0,0,0.2), inset 0 2px 3px rgba(255,255,255,0.9);
    display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
    padding: 12px; gap: 2px;
}
.dice.rolling { animation: shake .5s ease; }
@keyframes shake {
    0%,100% { transform: rotate(0) translateY(0); }
    25% { transform: rotate(-14deg) translateY(-4px); }
    50% { transform: rotate(10deg) translateY(2px); }
    75% { transform: rotate(-6deg) translateY(-2px); }
}
.pip { width: 100%; height: 100%; border-radius: 50%; align-self: center; justify-self: center; }
.pip.on { background: #3a3028; box-shadow: inset 0 -1px 1px rgba(0,0,0,0.4); }
.p1 { grid-area: 1/1; } .p2 { grid-area: 1/2; } .p3 { grid-area: 1/3; }
.p4 { grid-area: 2/1; } .p5 { grid-area: 2/2; } .p6 { grid-area: 2/3; }
.p7 { grid-area: 3/1; } .p8 { grid-area: 3/2; } .p9 { grid-area: 3/3; }

.btn {
    font-family: 'Cinzel', serif; font-weight: 700; font-size: 1.05rem; letter-spacing: 1px;
    color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border: none; padding: 14px 30px; border-radius: 30px; cursor: pointer;
    box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 45%, transparent);
    transition: transform .12s ease, filter .2s;
}
.roll-btn { /* alias kept for clarity */ }
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { filter: grayscale(.5) opacity(.6); cursor: not-allowed; }
.btn.secondary {
    color: var(--text-primary); background: var(--bg-card);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.status {
    text-align: center; min-height: 1.4em; font-family: 'Special Elite', monospace;
    font-size: 1.05rem; color: var(--text-primary);
}
.status b { color: var(--turn-color, var(--accent)); }
.linkbtn {
    display: block; margin: 0 auto; background: none; border: none; color: var(--text-secondary);
    text-decoration: underline; cursor: pointer; font-family: 'Courier Prime', monospace; font-size: 0.9rem;
}

/* ---- Hub / lobby ---- */
.card {
    background: var(--bg-card); border-radius: var(--radius-lg);
    padding: var(--spacing-lg); box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    display: flex; flex-direction: column; gap: var(--spacing-md);
}
.card h2 { font-family: 'Cinzel', serif; margin: 0; font-size: 1.3rem; }
.card p.hint { margin: 0; color: var(--text-secondary); font-size: 0.9rem; }
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--spacing-md); }
@media (max-width: 460px) { .mode-grid { grid-template-columns: 1fr; } }
.mode-card {
    display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
    text-decoration: none; color: var(--text-primary); cursor: pointer;
    background: var(--bg-card); border: 2px solid var(--bg-secondary); border-radius: var(--radius-lg);
    padding: var(--spacing-lg); transition: border-color .2s, transform .2s;
}
.mode-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.mode-card .emoji { font-size: 2.2rem; }
.mode-card .label { font-family: 'Cinzel', serif; font-weight: 700; font-size: 1.05rem; }
.mode-card .desc { font-size: 0.8rem; color: var(--text-secondary); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.8rem; color: var(--text-secondary); letter-spacing: 1px; text-transform: uppercase; }
.field input {
    font-family: 'Special Elite', monospace; font-size: 1.05rem;
    padding: 12px 14px; border-radius: var(--radius-md); border: 2px solid var(--bg-secondary);
    background: var(--bg-primary); color: var(--text-primary); outline: none; width: 100%;
}
.field input:focus { border-color: var(--accent); }
.row { display: flex; gap: var(--spacing-sm); flex-wrap: wrap; }
.row .btn { flex: 1; }
.error { color: var(--danger); font-size: 0.85rem; text-align: center; min-height: 1em; }
.hidden { display: none !important; }
.roomcode-display {
    font-family: 'Cinzel', serif; font-weight: 700; letter-spacing: 4px;
    font-size: 1.8rem; text-align: center; color: var(--accent);
}
.waiting-dots::after { content: '…'; animation: dots 1.4s steps(4, end) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---- High scores ---- */
.scores {
    background: var(--bg-card); border-radius: var(--radius-lg);
    padding: var(--spacing-md); box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.scores-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.scores-head h2 {
    font-family: 'Cinzel', serif; font-size: 1.2rem; margin: 0;
    display: flex; align-items: center; gap: 8px;
}
.period-tabs { display: flex; gap: 4px; }
.period-tabs button {
    font-family: 'Courier Prime', monospace; font-size: 0.78rem; cursor: pointer;
    border: none; background: var(--bg-secondary); color: var(--text-secondary);
    padding: 5px 10px; border-radius: 14px; transition: background .2s, color .2s;
}
.period-tabs button.active { background: var(--accent); color: #fff; }
.score-row {
    display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 10px;
    padding: 8px 6px; border-bottom: 1px solid var(--bg-secondary);
}
.score-row:last-child { border-bottom: none; }
.score-row .rank { font-family: 'Cinzel', serif; font-weight: 700; color: var(--text-secondary); text-align: center; }
.score-row.top1 .rank { color: #e0a500; }
.score-row .who { font-family: 'Special Elite', monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-row .rolls { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: bold; }
.score-row .rolls small { color: var(--text-secondary); font-weight: normal; }
.scores-empty { color: var(--text-secondary); text-align: center; padding: 16px; font-size: 0.9rem; }

/* ---- Win modal ---- */
.modal-back {
    position: fixed; inset: 0; background: rgba(30,20,10,0.55); backdrop-filter: blur(3px);
    display: none; align-items: center; justify-content: center; z-index: 60; padding: 20px;
}
.modal-back.show { display: flex; }
.win-modal {
    background: var(--bg-card); border-radius: var(--radius-lg); padding: 30px 28px;
    max-width: 360px; width: 100%; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,0.4);
    border-top: 6px solid var(--win-color, var(--accent)); animation: pop .35s ease;
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.win-modal h2 { font-family: 'Cinzel', serif; margin: 0 0 6px; font-size: 1.7rem; color: var(--win-color); }
.win-modal p { color: var(--text-secondary); margin: 0 0 6px; }
.win-modal .rolls-line { color: var(--text-primary); font-family: 'Special Elite', monospace; margin: 0 0 18px; }
.win-modal .trophy { font-size: 3rem; }
.win-modal .savenote { font-size: 0.8rem; color: var(--text-secondary); margin-top: 12px; min-height: 1em; }

/* ---- Adventure Time board treatment (cartoon board, per-kingdom palette) ---- */
[data-theme="adventure"] .board-frame,
[data-theme="candy-kingdom"] .board-frame,
[data-theme="ice-kingdom"] .board-frame,
[data-theme="flame-kingdom"] .board-frame,
[data-theme="lumpy-space"] .board-frame,
[data-theme="lemongrab"] .board-frame,
[data-theme="fern"] .board-frame {
    background: linear-gradient(160deg, #7a5230, #503620);
    border: 4px solid #1c1c1c;
    box-shadow: 0 6px 0 rgba(0,0,0,0.25);
}
[data-theme="adventure"] .board,
[data-theme="candy-kingdom"] .board,
[data-theme="ice-kingdom"] .board,
[data-theme="flame-kingdom"] .board,
[data-theme="lumpy-space"] .board,
[data-theme="lemongrab"] .board,
[data-theme="fern"] .board {
    border: 3px solid #1c1c1c;
    background: var(--cell-bg);
}
[data-theme="adventure"] .cell.light,
[data-theme="candy-kingdom"] .cell.light,
[data-theme="ice-kingdom"] .cell.light,
[data-theme="flame-kingdom"] .cell.light,
[data-theme="lumpy-space"] .cell.light,
[data-theme="lemongrab"] .cell.light,
[data-theme="fern"] .cell.light { background: var(--cell-bg); color: #2d3436; }
[data-theme="adventure"] .cell.dark,
[data-theme="candy-kingdom"] .cell.dark,
[data-theme="ice-kingdom"] .cell.dark,
[data-theme="flame-kingdom"] .cell.dark,
[data-theme="lumpy-space"] .cell.dark,
[data-theme="lemongrab"] .cell.dark,
[data-theme="fern"] .cell.dark { background: color-mix(in srgb, var(--cell-border) 22%, var(--cell-bg)); color: #2d3436; }
[data-theme="adventure"] .cell.home,
[data-theme="candy-kingdom"] .cell.home,
[data-theme="ice-kingdom"] .cell.home,
[data-theme="flame-kingdom"] .cell.home,
[data-theme="lumpy-space"] .cell.home,
[data-theme="lemongrab"] .cell.home,
[data-theme="fern"] .cell.home { background: linear-gradient(135deg, #ffe08a, #ffc233); }
[data-theme="adventure"] .cell.start,
[data-theme="candy-kingdom"] .cell.start,
[data-theme="ice-kingdom"] .cell.start,
[data-theme="flame-kingdom"] .cell.start,
[data-theme="lumpy-space"] .cell.start,
[data-theme="lemongrab"] .cell.start,
[data-theme="fern"] .cell.start { background: linear-gradient(135deg, #bff0a8, #8bd66a); }

@media (prefers-reduced-motion: reduce) {
    .pawn, .btn, .back-link { transition: none; }
    .dice.rolling { animation: none; }
    .waiting-dots::after { animation: none; content: '…'; }
}
