/* =========================================================================
   PARCHÍS ONLINE — design tokens
   A premium tabletop look: lacquered walnut frame, emerald felt table,
   brass inlay accents, ivory cards. Not a generic SaaS palette.
   ========================================================================= */
:root {
    --wood-dark:   #241209;
    --wood:        #3e2113;
    --wood-mid:    #5a3018;
    --wood-light:  #7a4423;
    --felt-dark:   #06301f;
    --felt:        #0d4a30;
    --felt-light:  #14663f;
    --gold:        #cf9a2e;
    --gold-light:  #ecc866;
    --gold-dim:    #8a6a2c;
    --cream:       #f4ecd8;
    --cream-dim:   #d9cba9;
    --ink:         #201408;
    --red:      #e0483f;
    --blue:     #2f74e0;
    --yellow:   #eab823;
    --green:    #279c5c;
    --shadow: 0 18px 40px rgba(0,0,0,0.45);

    --font-display: 'Fraunces', 'Georgia', serif;
    --font-body: 'Manrope', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: var(--font-body);
    color: var(--cream);
    background: radial-gradient(ellipse at top, #452712 0%, var(--wood-dark) 55%, #150a04 100%);
    background-attachment: fixed;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

::selection { background: var(--gold); color: var(--ink); }

a { color: var(--gold-light); }

/* subtle wood-grain overlay */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: repeating-linear-gradient(115deg, rgba(0,0,0,0.05) 0px, rgba(0,0,0,0.05) 1px, transparent 2px, transparent 6px);
    mix-blend-mode: overlay;
    z-index: 0;
}

h1, h2, h3 { font-family: var(--font-display); margin: 0; letter-spacing: 0.01em; }

/* -------------------------------------------------------------------- */
/* Brand mark                                                            */
/* -------------------------------------------------------------------- */
.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    justify-content: center;
}
.brand__dice {
    width: 2.2rem; height: 2.2rem;
    border-radius: 7px;
    background: linear-gradient(155deg, var(--cream), var(--cream-dim));
    box-shadow: 0 4px 0 var(--gold-dim), var(--shadow);
    position: relative;
    transform: rotate(-8deg);
}
.brand__dice::before, .brand__dice::after {
    content: "";
    position: absolute;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--ink);
}
.brand__dice::before { top: 6px; left: 6px; }
.brand__dice::after { bottom: 6px; right: 6px; }
.brand__title {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 600;
    color: var(--gold-light);
    text-shadow: 0 2px 0 rgba(0,0,0,0.5);
}
.brand__title small { display: block; font-family: var(--font-body); font-size: 0.62rem; letter-spacing: 0.32em; color: var(--cream-dim); font-weight: 700; text-transform: uppercase; }

/* -------------------------------------------------------------------- */
/* Layout helpers                                                        */
/* -------------------------------------------------------------------- */
.center-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.2rem;
    position: relative;
    z-index: 1;
}

.panel {
    background: linear-gradient(165deg, #2c1b10, #1c110a 80%);
    border: 1px solid rgba(207,154,46,0.35);
    border-radius: 18px;
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.05);
    padding: 2.2rem;
    position: relative;
}
.panel::before {
    content: "";
    position: absolute;
    inset: 7px;
    border: 1px solid rgba(244,236,216,0.08);
    border-radius: 12px;
    pointer-events: none;
}

.field { margin-bottom: 1.1rem; text-align: left; }
.field label {
    display: block;
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold-light);
    margin-bottom: 0.4rem;
    font-weight: 700;
}
.field input {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border-radius: 9px;
    border: 1px solid rgba(244,236,216,0.18);
    background: rgba(0,0,0,0.28);
    color: var(--cream);
    font-family: var(--font-body);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(207,154,46,0.25); }
.field input::placeholder { color: rgba(244,236,216,0.35); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.8rem 1.2rem;
    border-radius: 10px;
    border: none;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
    box-shadow: 0 3px 0 rgba(0,0,0,0.35);
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.35); }
.btn-gold { background: linear-gradient(160deg, var(--gold-light), var(--gold)); color: var(--ink); }
.btn-gold:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border: 1px solid rgba(244,236,216,0.3); color: var(--cream); box-shadow: none; }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-light); }
.btn-felt { background: linear-gradient(160deg, var(--felt-light), var(--felt-dark)); color: var(--cream); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { width: auto; padding: 0.5rem 1rem; font-size: 0.82rem; }

.error-msg {
    background: rgba(224,72,63,0.15);
    border: 1px solid rgba(224,72,63,0.5);
    color: #ffb4af;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    display: none;
}
.error-msg.show { display: block; }

.divider {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin: 1.4rem 0;
    color: var(--cream-dim);
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}
.divider::before, .divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: rgba(244,236,216,0.18);
}

.tab-row { display: flex; gap: 0.4rem; margin-bottom: 1.4rem; background: rgba(0,0,0,0.25); padding: 0.3rem; border-radius: 10px; }
.tab-btn { flex: 1; padding: 0.55rem; border: none; background: transparent; color: var(--cream-dim); border-radius: 7px; font-weight: 700; font-size: 0.85rem; cursor: pointer; font-family: var(--font-body); }
.tab-btn.active { background: linear-gradient(160deg, var(--gold-light), var(--gold)); color: var(--ink); }

/* -------------------------------------------------------------------- */
/* Lobby                                                                  */
/* -------------------------------------------------------------------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.6rem;
    background: linear-gradient(180deg, rgba(0,0,0,0.35), transparent);
    position: relative;
    z-index: 2;
}
.topbar__user { display: flex; align-items: center; gap: 0.7rem; font-size: 0.9rem; color: var(--cream-dim); }
.avatar {
    width: 2.1rem; height: 2.1rem; border-radius: 50%;
    background: linear-gradient(160deg, var(--gold-light), var(--gold-dim));
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; color: var(--ink); font-family: var(--font-display);
}

.lobby-wrap { max-width: 920px; margin: 0 auto; width: 100%; padding: 1.4rem; position: relative; z-index: 1; }
.lobby-grid { display: grid; grid-template-columns: 1.1fr 1.4fr; gap: 1.4rem; align-items: start; }
@media (max-width: 800px) { .lobby-grid { grid-template-columns: 1fr; } }

.room-list { display: flex; flex-direction: column; gap: 0.7rem; max-height: 480px; overflow-y: auto; padding-right: 4px; }
.room-card {
    display: flex; align-items: center; justify-content: space-between;
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(244,236,216,0.1);
    border-radius: 12px;
    padding: 0.9rem 1.1rem;
}
.room-card__name { font-weight: 700; }
.room-card__meta { font-size: 0.78rem; color: var(--cream-dim); margin-top: 0.15rem; }
.room-empty { text-align: center; color: var(--cream-dim); padding: 2rem 1rem; font-size: 0.9rem; }

/* -------------------------------------------------------------------- */
/* Waiting room / seats                                                  */
/* -------------------------------------------------------------------- */
.seats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.7rem; margin: 1.2rem 0; }
.seat {
    border-radius: 12px;
    padding: 0.9rem;
    background: rgba(0,0,0,0.22);
    border: 1px solid rgba(244,236,216,0.1);
    display: flex; align-items: center; gap: 0.6rem;
    min-height: 56px;
}
.seat.empty { opacity: 0.4; border-style: dashed; }
.seat__chip { width: 1.4rem; height: 1.4rem; border-radius: 50%; box-shadow: inset 0 -3px 0 rgba(0,0,0,0.3), 0 0 0 2px rgba(255,255,255,0.15); flex-shrink: 0; }
.chip-red { background: var(--red); } .chip-blue { background: var(--blue); }
.chip-yellow { background: var(--yellow); } .chip-green { background: var(--green); }

/* -------------------------------------------------------------------- */
/* Game screen                                                           */
/* -------------------------------------------------------------------- */
.game-wrap {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 1.1rem;
    padding: 1rem;
    max-width: 1180px;
    margin: 0 auto;
    width: 100%;
    position: relative;
    z-index: 1;
}
@media (max-width: 900px) {
    .game-wrap { grid-template-columns: 1fr; }
}

.board-frame {
    background: linear-gradient(150deg, var(--wood-light), var(--wood) 55%, var(--wood-dark));
    border-radius: 20px;
    padding: 16px;
    box-shadow: var(--shadow), inset 0 0 0 2px rgba(0,0,0,0.3);
    position: relative;
}
.board-frame::before {
    content: "";
    position: absolute; inset: 6px;
    border-radius: 14px;
    border: 2px solid rgba(207,154,46,0.5);
    pointer-events: none;
}
.board-canvas-wrap { position: relative; width: 100%; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden; box-shadow: inset 0 0 30px rgba(0,0,0,0.6); }
#boardCanvas { width: 100%; height: 100%; display: block; }

.side-panel { display: flex; flex-direction: column; gap: 1rem; }

.card {
    background: linear-gradient(165deg, #2c1b10, #1c110a 80%);
    border: 1px solid rgba(207,154,46,0.3);
    border-radius: 14px;
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow);
}
.card h3 { font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold-light); margin-bottom: 0.7rem; }

.turn-order { display: flex; flex-direction: column; gap: 0.5rem; }
.turn-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.6rem; border-radius: 9px; font-size: 0.88rem; font-weight: 600; }
.turn-row.active { background: rgba(207,154,46,0.18); box-shadow: inset 0 0 0 1px rgba(207,154,46,0.5); }
.turn-row .dot { width: 0.85rem; height: 0.85rem; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 2px rgba(255,255,255,0.15); }
.turn-row .status { margin-left: auto; font-size: 0.7rem; color: var(--cream-dim); }

.dice-zone { display: flex; flex-direction: column; align-items: center; gap: 0.9rem; }
.dice3d {
    width: 76px; height: 76px;
    border-radius: 16px;
    background: linear-gradient(155deg, var(--cream), var(--cream-dim));
    box-shadow: 0 6px 0 var(--gold-dim), var(--shadow);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: 11px;
}
.dice3d.rolling { animation: diceRoll 0.55s ease; }
@keyframes diceRoll {
    0% { transform: rotate(0deg) scale(1); }
    30% { transform: rotate(120deg) scale(1.1); }
    60% { transform: rotate(240deg) scale(0.95); }
    100% { transform: rotate(360deg) scale(1); }
}
.pip { border-radius: 50%; background: var(--ink); opacity: 0; align-self: center; justify-self: center; width: 12px; height: 12px; }
.pip.on { opacity: 1; }

.roll-btn { width: 100%; }
.hint-text { font-size: 0.78rem; color: var(--cream-dim); text-align: center; min-height: 1.1em; }

.log-box { max-height: 160px; overflow-y: scroll; scrollbar-width: thin; display: flex; flex-direction: column-reverse; gap: 0.35rem; font-size: 0.8rem; color: var(--cream-dim); }
.log-box .entry { border-left: 2px solid var(--gold-dim); padding-left: 0.5rem; }

.you-badge { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.72rem; padding: 0.15rem 0.5rem; border-radius: 999px; background: rgba(207,154,46,0.2); color: var(--gold-light); font-weight: 700; }

.modal-overlay {
    position: fixed; inset: 0; background: rgba(6,3,1,0.72);
    display: none; align-items: center; justify-content: center; z-index: 50; padding: 1rem;
}
.modal-overlay.show { display: flex; }
.modal-box { max-width: 380px; text-align: center; }
.modal-box .trophy { font-size: 3rem; margin-bottom: 0.6rem; }

.toast {
    position: fixed; top: 1.1rem; left: 50%; transform: translateX(-50%);
    background: linear-gradient(160deg, var(--gold-light), var(--gold));
    color: var(--ink); font-weight: 700; padding: 0.6rem 1.1rem; border-radius: 10px;
    box-shadow: var(--shadow); z-index: 60; opacity: 0; pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(6px); }

.footer-note { text-align: center; color: var(--cream-dim); font-size: 0.72rem; padding: 1rem; opacity: 0.6; position: relative; z-index: 1; }

.code-pill {
    font-family: 'Courier New', monospace;
    letter-spacing: 0.2em;
    background: rgba(0,0,0,0.35);
    border: 1px dashed var(--gold-dim);
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
    text-align: center;
    font-size: 1.1rem;
    color: var(--gold-light);
    font-weight: 700;
}

.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(0,0,0,0.25); border-top-color: var(--ink); animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
