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

:root {
    --felt: #1e6641;
    --felt-dark: #174f32;
    --ink: #1c2420;
    --paper: #f6f3ea;
    --red: #c0322b;
    --black: #22262a;
    --accent: #e8b83a;
    --accent-ink: #3a2c05;
    --panel: #ffffff;
    --muted: #6b7570;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--felt);
    color: var(--paper);
    min-height: 100vh;
}

.hidden { display: none !important; }

/* ---------- Lobby ---------- */

.lobby {
    max-width: 760px;
    margin: 0 auto;
    padding: 40px 16px;
}

.lobby h1 { font-size: 2rem; margin-bottom: 8px; }
.lobby .tagline { color: #cfe3d6; margin-bottom: 24px; }

.panels { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }

.panel {
    background: var(--panel);
    color: var(--ink);
    border-radius: 12px;
    padding: 20px;
    flex: 1;
    min-width: 260px;
}

.panel h2 { font-size: 1.1rem; margin-bottom: 12px; }

.panel label { display: block; font-size: 0.85rem; margin: 10px 0 4px; color: var(--muted); }

.panel input, .panel select {
    width: 100%;
    padding: 10px;
    border: 2px solid #d8d2c2;
    border-radius: 8px;
    font-size: 1rem;
    background: #fff;
    color: var(--ink);
}

.panel button, .lobby button {
    margin-top: 14px;
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: var(--felt-dark);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

.panel button:hover { background: #123d27; }

.alert {
    background: var(--red);
    color: #fff;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.rules-box {
    background: var(--felt-dark);
    border-radius: 12px;
    padding: 20px;
}

.rules-box h2 { margin-bottom: 10px; font-size: 1.1rem; }
.rules-box ul { list-style: none; }
.rules-box li { padding: 5px 0; color: #d9e8de; font-size: 0.95rem; }

/* ---------- Game room ---------- */

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

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: var(--felt-dark);
}

.logo { font-weight: 700; margin-right: 10px; }

.room-code {
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 700;
    letter-spacing: 2px;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
}

#status-line { font-size: 0.9rem; color: #cfe3d6; }

#table {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 14px;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
}

/* Opponents */

#opponents { display: flex; justify-content: center; gap: 24px; flex-wrap: wrap; }

.opponent {
    text-align: center;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--felt-dark);
    min-width: 110px;
    border: 2px solid var(--felt-dark);
}

.opponent.turn { border-color: var(--accent); }

.opponent .op-name { font-weight: 600; margin-bottom: 6px; }
.opponent .op-cards { display: flex; justify-content: center; gap: 2px; }

.mini-back {
    width: 18px;
    height: 26px;
    border-radius: 3px;
    background: #7a2c22;
    border: 1px solid #5c211a;
}

.op-count { font-size: 0.8rem; color: #cfe3d6; margin-top: 4px; }

.op-stats { font-size: 0.72rem; color: #9fc4ab; margin-top: 3px; }

.stat-pos { color: #7ee2a0; font-weight: 700; }
.stat-neg { color: #ff9d96; font-weight: 700; }

.badge {
    display: inline-block;
    font-size: 0.65rem;
    background: var(--accent);
    color: var(--accent-ink);
    border-radius: 4px;
    padding: 1px 5px;
    margin-left: 4px;
    font-weight: 700;
}

/* Center: deck + discard */

#center {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    padding: 18px 0;
}

#deck-area { text-align: center; }
#deck-count { font-size: 0.8rem; color: #cfe3d6; margin-top: 4px; }

#discard-area { text-align: center; position: relative; }

#declared-suit {
    margin-top: 6px;
    font-size: 0.9rem;
    font-weight: 700;
}

#direction { font-size: 1.6rem; }

/* Cards */

.card {
    display: inline-flex;
    flex-direction: column;
    justify-content: space-between;
    width: 62px;
    height: 88px;
    border-radius: 8px;
    background: var(--paper);
    border: 1px solid #b9b19c;
    padding: 5px;
    font-weight: 700;
    cursor: default;
    user-select: none;
    position: relative;
}

.card .corner { font-size: 0.85rem; line-height: 1; }
.card .pip { font-size: 1.6rem; text-align: center; }
.card .corner.bottom { transform: rotate(180deg); }

.card.red { color: var(--red); }
.card.black { color: var(--black); }

.card.back {
    background: #7a2c22;
    border-color: #5c211a;
}

.card.back::after {
    content: "🂠";
    color: #a3453a;
    font-size: 2rem;
    margin: auto;
}

/* My hand */

#my-area { text-align: center; }

#my-hand {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 0;
    min-height: 100px;
}

#my-hand .card { cursor: pointer; transition: transform 0.08s ease; }
#my-hand .card.playable { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
#my-hand .card.selected { transform: translateY(-14px); box-shadow: 0 0 0 3px #ffffff; }
#my-hand .card.drawn-new { outline: 3px dashed var(--accent); outline-offset: 2px; }

#my-name { font-weight: 600; padding-bottom: 2px; }

#my-stats { font-size: 0.8rem; color: #9fc4ab; padding-bottom: 8px; }

#my-actions { display: flex; justify-content: center; gap: 10px; }

#my-actions button {
    padding: 10px 22px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    background: var(--felt-dark);
    color: #fff;
}

#my-actions button.primary { background: var(--accent); color: var(--accent-ink); }
#my-actions button:disabled { opacity: 0.45; cursor: not-allowed; }
#my-actions button.danger { background: var(--red); color: #fff; }

/* Banner + toast + log */

#banner {
    text-align: center;
    font-size: 1.15rem;
    font-weight: 700;
    min-height: 30px;
    padding: 4px;
}

#banner .win { color: var(--accent); }

#last-action {
    text-align: center;
    padding: 8px;
    font-size: 0.85rem;
    color: #cfe3d6;
}

#toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--red);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    z-index: 30;
}

#toast.info { background: var(--accent); color: var(--accent-ink); }

/* Dealer panel */

#dealer-panel {
    position: fixed;
    inset: 0;
    background: rgba(12, 30, 20, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    padding: 16px;
}

#dealer-panel .panel { max-width: 340px; width: 100%; }
#dealer-panel .hint { font-size: 0.8rem; color: var(--muted); margin-top: 8px; }
#dealer-panel button.primary { background: var(--felt-dark); }

/* Suit modal */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(12, 30, 20, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 25;
    padding: 16px;
}

.modal-box {
    background: var(--panel);
    color: var(--ink);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    max-width: 320px;
    width: 100%;
}

.modal-box h2 { margin-bottom: 16px; font-size: 1.1rem; }

.suit-buttons { display: flex; justify-content: center; gap: 10px; margin-bottom: 16px; }

button.suit {
    font-size: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 10px;
    border: 2px solid #d8d2c2;
    background: var(--paper);
    cursor: pointer;
}

button.suit.red { color: var(--red); }
button.suit.black { color: var(--black); }
button.suit:hover { border-color: var(--accent); }

#suit-cancel {
    border: none;
    background: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: underline;
}

@media (max-width: 560px) {
    .card { width: 50px; height: 72px; }
    .card .pip { font-size: 1.2rem; }
    #center { gap: 20px; }
}
