:root {
    --bg-dark: #0a0d14;
    --panel-bg: rgba(22, 27, 34, 0.94);
    --panel-border: #3b4252;
    --wood-border: #5c3a21;
    --wood-bg: #805333;
    --wood-dark: #432818;
    --accent-cyan: #38bdf8;
    --accent-gold: #facc15;
    --accent-red: #ef4444;
    --accent-blue: #3b82f6;
    --accent-green: #22c55e;
    --accent-purple: #a855f7;
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none;
}

body {
    background: #05070a;
    color: var(--text-primary);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameContainer {
    position: relative;
    width: 960px;
    height: 540px;
    background: #000;
    box-shadow: 0 0 35px rgba(0, 0, 0, 0.9), 0 0 20px rgba(56, 189, 248, 0.2);
    border: 3px solid #1e293b;
    border-radius: 8px;
    overflow: hidden;
}

canvas#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
}

/* =====================================================================
   CHARACTER SELECT & CREATION SCREEN (IDLEON STYLE)
   ===================================================================== */
#charSelectScreen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(180deg, #1e3a8a 0%, #0f172a 60%, #050505 100%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px 24px;
}

.char-select-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.account-badge {
    background: #475569;
    border: 2px solid #64748b;
    padding: 6px 14px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    gap: 8px;
}

.server-selector {
    background: #1e293b;
    border: 1px solid #475569;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.char-select-body {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex: 1;
    margin-bottom: 20px;
    position: relative;
}

.pedestal-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

.char-pedestal {
    width: 85px;
    height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.char-pedestal:hover {
    transform: translateY(-5px);
}

.char-pedestal.selected .pedestal-base {
    background: var(--accent-gold);
    box-shadow: 0 0 15px var(--accent-gold);
}

.pedestal-base {
    width: 100%;
    height: 16px;
    background: #334155;
    border-radius: 8px / 4px;
    border: 1px solid #64748b;
}

.char-preview-avatar {
    font-size: 2.8rem;
    margin-bottom: 6px;
}

.char-tag {
    font-size: 0.72rem;
    font-weight: bold;
    color: #fff;
    background: rgba(0,0,0,0.6);
    padding: 2px 6px;
    border-radius: 4px;
    text-align: center;
    white-space: nowrap;
    margin-bottom: 4px;
}

.char-pedestal.locked {
    opacity: 0.45;
    cursor: not-allowed;
}

.char-pedestal.locked:hover {
    transform: none;
}

.char-create-btn {
    background: #0284c7;
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #38bdf8;
    margin-bottom: 8px;
    cursor: pointer;
    animation: bounce 1.5s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* Character Creation Side Panel (Wooden Idleon Style) */
.char-create-panel {
    background: #6f4e37;
    border: 4px solid #4a2e18;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5), 0 8px 20px rgba(0,0,0,0.8);
    border-radius: 10px;
    width: 250px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.panel-block {
    background: #4a2e18;
    border: 2px solid #2e1c0c;
    border-radius: 6px;
    padding: 8px 10px;
    text-align: center;
}

.panel-block-label {
    font-size: 0.7rem;
    color: #fcd34d;
    font-weight: bold;
    text-transform: uppercase;
}

.panel-block-val {
    font-size: 0.88rem;
    font-weight: bold;
    color: #fff;
    margin-top: 2px;
}

.panel-block input {
    background: #2e1c0c;
    border: 1px solid #78350f;
    color: #fff;
    padding: 4px 8px;
    font-size: 0.88rem;
    border-radius: 4px;
    width: 100%;
    text-align: center;
}

.btn-play-wood {
    background: linear-gradient(180deg, #eab308 0%, #ca8a04 100%);
    border: 3px solid #713f12;
    box-shadow: 0 4px 0 #451a03;
    color: #451a03;
    font-size: 1.3rem;
    font-weight: 900;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.1s ease;
}

.btn-play-wood:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #451a03;
}

.btn-play-wood:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #451a03;
}

/* =====================================================================
   IN-GAME HUD (IDLEON STYLE)
   ===================================================================== */
.idleon-hud-bar {
    position: absolute;
    bottom: 8px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.95);
    border: 2px solid #334155;
    border-radius: 8px;
    padding: 6px 12px;
    z-index: 30;
    backdrop-filter: blur(4px);
}

.hud-toon-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 250px;
}

.toon-avatar-box {
    width: 44px;
    height: 44px;
    background: #1e293b;
    border: 2px solid #475569;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.6rem;
}

.toon-bars {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
}

.toon-name-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 800;
}

.hud-action-icons {
    display: flex;
    gap: 8px;
}

.hud-icon-btn {
    width: 46px;
    height: 46px;
    background: #1e293b;
    border: 2px solid #475569;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.hud-icon-btn:hover {
    border-color: var(--accent-cyan);
    transform: translateY(-2px);
    background: #334155;
}

.hud-icon-btn .icon { font-size: 1.2rem; }
.hud-icon-btn .label { font-size: 0.58rem; font-weight: bold; text-transform: uppercase; margin-top: 1px; color: #cbd5e1; }

.hud-icon-btn.auto-active {
    border-color: var(--accent-green);
    background: rgba(34, 197, 94, 0.2);
}

/* =====================================================================
   AFK GAINS POPUP (AUTHENTIC IDLEON SCREENSHOT CLONE)
   ===================================================================== */
#afkGainsModal {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 150;
    backdrop-filter: blur(3px);
}

.afk-stone-card {
    background: #71717a;
    border: 4px solid #3f3f46;
    box-shadow: inset 0 0 15px #27272a, 0 12px 30px rgba(0,0,0,0.9);
    border-radius: 12px;
    width: 360px;
    padding: 16px;
    text-align: center;
}

.afk-title {
    font-size: 1.3rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
    margin-bottom: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.afk-time-sub {
    font-size: 0.85rem;
    color: #fde047;
    font-weight: bold;
    border-bottom: 1px solid #52525b;
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.afk-list {
    text-align: left;
    font-size: 0.82rem;
    font-weight: bold;
    color: #f4f4f5;
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 14px;
}

.afk-item-line {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-claim-green {
    background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
    border: 3px solid #14532d;
    box-shadow: 0 4px 0 #052e16;
    color: white;
    font-size: 1.2rem;
    font-weight: 900;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
}

.btn-claim-green:hover { transform: translateY(-2px); }
.btn-claim-green:active { transform: translateY(2px); box-shadow: 0 1px 0 #052e16; }

/* =====================================================================
   TALENTS MODAL
   ===================================================================== */
.talent-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 12px;
}

.talent-card {
    background: #1e293b;
    border: 2px solid #334155;
    border-radius: 6px;
    padding: 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.talent-btn-add {
    background: var(--accent-gold);
    color: #000;
    font-weight: bold;
    font-size: 0.9rem;
    border: none;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    margin-top: 4px;
}

/* =====================================================================
   GENERIC MODALS & FLOATING TEXTS
   ===================================================================== */
.hidden {
    display: none !important;
}

.game-modal {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

#authModal {
    z-index: 9999 !important;
}

.game-modal.hidden { display: none; }

.modal-box {
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    padding: 18px;
    width: 90%;
    max-width: 520px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.8);
}

.close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.2rem;
    cursor: pointer;
}

.combat-text {
    position: absolute;
    pointer-events: none;
    font-weight: 800;
    font-size: 1.1rem;
    text-shadow: 1px 1px 3px #000;
    animation: floatUp 0.8s forwards ease-out;
}

@keyframes floatUp {
    0% { opacity: 1; transform: translate(0, 0) scale(1); }
    100% { opacity: 0; transform: translate(0, -35px) scale(1.2); }
}
