:root {
    --bg-dark: #06110a;
    --bg-panel: #0d1b14;
    --border-glass: #2a3a2e;
    --border-gold: #c29b2b;
    --text-main: #f8fafc;
    --text-muted: #5b6b5e;
    --primary: #15803d; /* Green button */
    --primary-hover: #166534;
    --gold: #c29b2b;
    --danger: #ef4444;
    --card-bg: #ffffff;
    --card-text: #0f172a;
    --card-skipbo: #1e3a8a; /* Dark blue for SkipBo */
}

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

body {
    font-family: 'Inter', sans-serif;
    background: radial-gradient(circle at center, #0a1f13 0%, var(--bg-dark) 100%);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    user-select: none;
}

h1, h2, h3, .logo-title, .card {
    font-family: 'Outfit', sans-serif;
}

/* Landscape orientation enforcement */
#rotate-device-warning {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-dark);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

@media screen and (orientation: portrait) {
    #rotate-device-warning {
        display: flex;
    }
}

.screen {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0; left: 0;
    transition: opacity 0.3s ease;
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.screen.active {
    opacity: 1;
    pointer-events: all;
}

/* Glassmorphism Panel -> Solid Dark Panel with Gold Border */
.glass-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-gold);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.lobby-panel {
    max-width: 600px;
    margin: 40px auto;
    text-align: left;
}

.logo-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--gold);
    margin-bottom: 5px;
    text-transform: uppercase;
    text-shadow: none;
}

.lobby-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 25px;
}

input[type="text"], input[type="number"] {
    width: 100%;
    padding: 12px 15px;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    color: white;
    font-size: 1rem;
    margin-bottom: 15px;
    outline: none;
    transition: border-color 0.2s;
}

input[type="text"]:focus, input[type="number"]:focus {
    border-color: var(--primary);
}

.color-picker-group {
    margin-bottom: 20px;
    text-align: left;
}
.color-picker-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
}
.color-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}
.color-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}
.color-btn:hover {
    transform: scale(1.1);
}
.color-btn.active {
    border-color: white;
    box-shadow: 0 0 10px rgba(255,255,255,0.5);
    transform: scale(1.1);
}

.stock-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 10px;
    margin-bottom: 20px;
}
.btn-stock {
    background: #112217;
    color: white;
    border: 1px solid var(--border-glass);
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.btn-stock:hover {
    background: #1a3323;
}
.btn-stock.active {
    background: #2a3a2e;
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: none;
}

button {
    cursor: pointer;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
    padding: 12px 24px;
    font-size: 1rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
    background: #2a3a2e;
    color: white;
    border: 1px solid var(--border-glass);
}
.btn-secondary:hover { background: #3b4d40; }

.small { padding: 8px 16px; font-size: 0.9rem; }

.hidden { display: none !important; }

/* Players list in lobby */
.players-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
}

.player-item {
    display: flex;
    align-items: center;
    background: rgba(0,0,0,0.2);
    padding: 10px 15px;
    border-radius: 10px;
}

.player-color-dot {
    width: 16px; height: 16px;
    border-radius: 50%;
    margin-right: 15px;
    border: 2px solid white;
}

.player-name-txt { flex: 1; text-align: left; }
.player-admin-badge {
    font-size: 0.8rem;
    background: var(--primary);
    padding: 2px 8px;
    border-radius: 12px;
}

/* Scoreboard */
.scoreboard-container {
    margin-top: 30px;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    padding: 15px;
}
.scoreboard {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}
.scoreboard th { color: var(--text-muted); font-size: 0.9rem; padding-bottom: 10px; text-align: left; }
.scoreboard td { padding: 10px 0; border-top: 1px solid var(--border-glass); }

.section-title {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: bold;
    letter-spacing: 1px;
    margin-bottom: 10px;
    text-transform: uppercase;
}
.player-item {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #112217;
    border: 1px solid var(--border-glass);
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 10px;
}
.player-item.empty {
    background: rgba(17, 34, 23, 0.5);
    border: 1px dashed var(--border-glass);
    justify-content: flex-start;
}
.settings-box {
    background: #112217;
    border: 1px solid var(--border-glass);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.setting-title {
    font-weight: bold;
    font-size: 0.9rem;
}
.setting-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- GAME BOARD --- */
.top-header {
    height: 40px;
    background: #000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-gold);
}
.top-header .logo {
    color: var(--gold);
    font-family: 'Outfit';
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: 2px;
}
.top-header .info { display: flex; align-items: center; gap: 20px; color: var(--text-muted); }
.top-header .info b { color: white; }
.top-header .turn-green { color: #22c55e; font-weight: bold; }
.btn-exit {
    background: #2a3a2e; color: white; padding: 4px 12px; border-radius: 4px; font-size: 0.8rem; border: none; cursor: pointer;
}

#game-board {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 40px);
    padding: 20px;
    gap: 20px;
}

.card {
    width: 60px;
    height: 90px;
    background: var(--card-bg);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--card-text);
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    position: relative;
    user-select: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card .corner-num {
    position: absolute;
    font-size: 0.8rem;
    font-weight: bold;
}
.card .corner-top { top: 4px; left: 4px; }
.card .corner-bottom { bottom: 4px; right: 4px; transform: rotate(180deg); }

/* Standard colors */
.card[data-val="1"], .card[data-val="2"], .card[data-val="3"], .card[data-val="4"] { color: #3b82f6; }
.card[data-val="5"], .card[data-val="6"], .card[data-val="7"], .card[data-val="8"] { color: #ef4444; }
.card[data-val="9"], .card[data-val="10"], .card[data-val="11"], .card[data-val="12"] { color: #22c55e; }

@media (min-width: 768px) {
    .card { width: 70px; height: 100px; font-size: 3rem; }
}

.card.skipbo {
    background: var(--card-skipbo);
    color: white;
    font-size: 1.2rem;
}

.card-back {
    background: var(--card-skipbo);
    color: white;
    font-size: 1.2rem;
}

.card.selectable {
    cursor: pointer;
}
.card.selectable:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px rgba(0,0,0,0.4);
}
.card.selected {
    transform: translateY(-15px) !important;
    box-shadow: 0 15px 25px rgba(59, 130, 246, 0.5) !important;
    border: 3px solid var(--primary);
}

.pile {
    width: 60px; height: 90px;
    border: 2px dashed var(--border-glass);
    border-radius: 6px;
    position: relative;
}
@media (min-width: 768px) {
    .pile { width: 70px; height: 100px; }
}

.pile.highlight-dest {
    border-color: var(--gold);
    background: rgba(194, 155, 43, 0.1);
    cursor: pointer;
    box-shadow: inset 0 0 15px rgba(194, 155, 43, 0.3);
}

.pile > .card {
    position: absolute;
    top: 0; left: 0;
}

/* Joker played in build pile */
.card.joker-played {
    background: var(--card-skipbo);
    color: var(--gold);
    border: 1px solid var(--gold);
}

/* Discard history badges */
.discard-history {
    position: absolute;
    top: 5px;
    right: -20px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 5;
}
.discard-badge {
    background: #ffffff;
    color: #0f172a;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 2px;
    border: 1px solid #cbd5e1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.count-badge {
    position: absolute;
    bottom: -10px;
    right: -10px;
    background: var(--primary);
    color: white;
    font-size: 0.8rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Center Board */
.center-board {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
}
.build-piles { display: flex; gap: 15px; }
.pile-container { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pile-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; font-weight: bold; }

/* My Area */
.my-area {
    border: 1px solid var(--gold);
    background: var(--bg-panel);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}
.my-area-top {
    display: flex;
    gap: 50px;
    justify-content: flex-start;
    width: 100%;
}
.my-area-bottom {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 20px;
}
.my-discard-piles { display: flex; gap: 25px; }
.my-hand { display: flex; gap: 10px; justify-content: center; }

/* Opponents */
#opponents-container {
    display: flex;
    justify-content: center;
    gap: 30px;
}
.opponent-box {
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--border-glass);
    position: relative;
    width: 260px;
}
.opponent-box.active-turn {
    border-color: var(--gold);
    box-shadow: 0 0 15px rgba(194, 155, 43, 0.2);
}
.opp-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.player-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: #ffffff;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    letter-spacing: 1px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    border: 2px solid rgba(255,255,255,0.15);
    flex-shrink: 0;
}
.opp-name {
    flex: 1;
    font-weight: bold;
    font-size: 0.9rem;
}
.opp-stock-badge {
    background: rgba(194, 155, 43, 0.2);
    color: var(--gold);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
}
.opp-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}
.opp-piles {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}
.opp-pile {
    width: 35px;
    height: 50px;
    border: 1px dashed var(--border-glass);
    border-radius: 4px;
    position: relative;
}
.opp-pile .card {
    width: 100% !important;
    height: 100% !important;
    font-size: 1.2rem !important;
    border-radius: 4px;
}
.opp-pile .card .corner-num {
    font-size: 0.5rem;
    transform: scale(0.8);
}
.opp-hand-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Flight animation class */
.flying-card {
    position: fixed;
    z-index: 9999;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    pointer-events: none;
}
