/* ===== Whack — Clay/Neumorphism Style ===== */
:root {
    --bg: #e8e0d8;
    --surface: #f5efe8;
    --surface-2: #ece5dc;
    --shadow-out: 5px 5px 12px #c8c0b8, -5px -5px 12px #ffffff;
    --shadow-in: inset 3px 3px 7px #c8c0b8, inset -3px -3px 7px #ffffff;
    --shadow-btn: 3px 3px 7px #c8c0b8, -3px -3px 7px #ffffff;
    --accent: #e05a2b;
    --accent-2: #f47c4e;
    --green: #2ebd5e;
    --green-bg: #d4f5dc;
    --red: #e53e3e;
    --red-bg: #fde8e8;
    --orange: #dd8800;
    --orange-bg: #fef3d8;
    --blue: #3b82f6;
    --blue-bg: #dbeafe;
    --purple: #7c3aed;
    --purple-bg: #ede9fe;
    --text: #2d2a26;
    --text-2: #6b6560;
    --text-3: #a09890;
    --radius: 16px;
    --radius-sm: 10px;
    --font: 'Baloo 2', 'Noto Sans SC', sans-serif;
    --mono: 'Fira Code', monospace;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; font-family: var(--font); background: var(--bg); color: var(--text); }
body { display: flex; }
.hidden { display: none !important; }

/* ===== Layout ===== */
.layout { display: flex; width: 100%; height: 100vh; }
.panel { height: 100vh; display: flex; flex-direction: column; }
.panel-game { flex: 1; padding: 1rem 1.5rem; gap: 0.8rem; overflow: hidden; display: flex; flex-direction: column; }
.panel-lb { width: 320px; background: var(--surface); box-shadow: -3px 0 15px rgba(0,0,0,0.04); padding: 1rem; display: flex; flex-direction: column; gap: 0.8rem; overflow: hidden; }

/* ===== Top ===== */
.game-top { flex-shrink: 0; display: flex; flex-direction: column; gap: 0.7rem; }
.brand-row { display: flex; align-items: center; justify-content: space-between; }
.brand { font-size: 1.4rem; font-weight: 800; color: var(--accent); }
.online-badge { font-size: 0.72rem; color: var(--text-2); background: var(--surface); box-shadow: var(--shadow-btn); padding: 0.3rem 0.7rem; border-radius: 20px; }

/* Nick */
.nick-row { display: flex; align-items: center; }
.nick-show { display: flex; align-items: center; gap: 0.4rem; padding: 0.35rem 0.7rem; border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-btn); }
.nick-ava { font-size: 1rem; }
.nick-name { font-weight: 700; font-size: 0.85rem; }
.nick-edit { background: none; border: none; cursor: pointer; font-size: 0.75rem; opacity: 0.5; }
.nick-edit:hover { opacity: 1; }
.nick-form { display: flex; align-items: center; gap: 0.3rem; }
.nick-inp { padding: 0.35rem 0.6rem; border-radius: 8px; border: none; background: var(--surface); box-shadow: var(--shadow-in); color: var(--text); font-family: var(--font); font-size: 0.82rem; width: 120px; outline: none; }
.fbtn { width: 26px; height: 26px; border-radius: 7px; border: none; background: var(--surface); box-shadow: var(--shadow-btn); cursor: pointer; font-size: 0.75rem; display: flex; align-items: center; justify-content: center; }
.fbtn.ok:hover { background: var(--green-bg); }
.fbtn.no:hover { background: var(--red-bg); }

/* Controls */
.controls { display: flex; gap: 1rem; flex-wrap: wrap; }
.ctrl-group { display: flex; align-items: center; gap: 0.5rem; }
.ctrl-label { font-size: 0.7rem; color: var(--text-3); text-transform: uppercase; }
.btn-group { display: flex; gap: 0.25rem; }
.btn-seg { padding: 0.3rem 0.65rem; border-radius: 8px; border: none; background: var(--surface); box-shadow: var(--shadow-btn); font-family: var(--font); font-size: 0.72rem; font-weight: 600; color: var(--text-2); cursor: pointer; transition: all 0.15s; }
.btn-seg:hover { color: var(--text); }
.btn-seg.active { box-shadow: var(--shadow-in); color: var(--accent); }

/* HUD */
.hud { display: flex; gap: 0.75rem; }
.hud-item { padding: 0.4rem 0.8rem; border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-out); text-align: center; display: flex; flex-direction: column; gap: 0.05rem; }
.hud-label { font-size: 0.6rem; color: var(--text-3); text-transform: uppercase; }
.hud-val { font-family: var(--mono); font-size: 1.1rem; font-weight: 700; color: var(--accent); }

/* ===== Grid ===== */
.grid-area { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; min-height: 0; max-height: 340px; }

.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 0.75rem;
    width: 100%;
    max-width: 520px;
    aspect-ratio: 4/3;
    max-height: 100%;
}

.hole {
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-in);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: transform 0.1s, box-shadow 0.1s;
    position: relative;
    overflow: hidden;
    min-height: 70px;
}

.hole:active { transform: scale(0.95); }

.hole.active {
    box-shadow: var(--shadow-out);
    animation: hole-pop 0.2s ease-out;
}

@keyframes hole-pop {
    0% { transform: scale(0.9); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.hole.hit {
    background: var(--green-bg);
    box-shadow: inset 2px 2px 6px #a8e6b0, inset -2px -2px 6px #f0fff4;
}

.hole.missed {
    background: var(--red-bg);
    box-shadow: inset 2px 2px 6px #e8b0b0, inset -2px -2px 6px #fff8f8;
}

/* Mole content (skin-specific) */
.mole-content {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.4rem;
    width: 100%;
    height: 100%;
    animation: mole-up 0.2s ease-out;
}

.hole.active .mole-content { display: flex; }

@keyframes mole-up {
    from { transform: translateY(30%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.mole-icon { font-size: 1.5rem; line-height: 1; }
.mole-text { font-size: 0.6rem; color: var(--text-2); margin-top: 0.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* Score float */
.score-float {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--mono);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--green);
    pointer-events: none;
    animation: float-up 0.6s ease-out forwards;
    z-index: 10;
}

.score-float.bonus { color: var(--purple); font-size: 1rem; }
.score-float.penalty { color: var(--red); }

@keyframes float-up {
    0% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-30px); }
}

/* ===== Overlays ===== */
.overlay {
    position: absolute;
    inset: 0;
    background: rgba(232, 224, 216, 0.92);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    border-radius: var(--radius);
}

.ov-content { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }
.ov-emoji { font-size: 3rem; }
.ov-title { font-size: 1.4rem; font-weight: 800; }
.ov-score { font-size: 1.1rem; color: var(--text-2); }
.ov-score strong { color: var(--accent); font-family: var(--mono); font-size: 1.4rem; }
.ov-detail { font-size: 0.8rem; color: var(--text-3); }
.ov-hint { font-size: 0.7rem; color: var(--text-3); margin-top: 0.5rem; }
.ov-achievements { font-size: 0.8rem; color: var(--purple); }

.btn-start {
    padding: 0.6rem 1.5rem;
    border-radius: 12px;
    border: none;
    background: var(--accent);
    color: white;
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(224, 90, 43, 0.3);
    transition: all 0.15s;
}

.btn-start:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(224, 90, 43, 0.4); }
.btn-start.btn-daily { background: var(--purple); box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3); }
.btn-start.btn-daily:hover { box-shadow: 0 6px 16px rgba(124, 58, 237, 0.4); }

/* ===== Toast ===== */
.toast-container { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 0.5rem; pointer-events: none; }
.toast {
    padding: 0.5rem 1.2rem;
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-out);
    font-size: 0.82rem;
    font-weight: 600;
    animation: toast-in 0.3s ease-out, toast-out 0.3s ease-in 2.5s forwards;
}

@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }

/* ===== Leaderboard ===== */
.lb-head { flex-shrink: 0; }
.lb-title { font-size: 1rem; font-weight: 800; }
.lb-tabs { display: flex; gap: 0.25rem; margin-top: 0.5rem; }
.lb-tab { padding: 0.25rem 0.6rem; border-radius: 7px; border: none; background: var(--surface-2); font-family: var(--font); font-size: 0.68rem; font-weight: 600; color: var(--text-3); cursor: pointer; transition: all 0.15s; }
.lb-tab.active { background: var(--accent); color: white; box-shadow: 0 2px 6px rgba(224,90,43,0.2); }

.lb-scroll { flex: 1; overflow-y: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: #d0c8c0 transparent; }
.lb-scroll::-webkit-scrollbar { width: 4px; }
.lb-scroll::-webkit-scrollbar-thumb { background: #d0c8c0; border-radius: 4px; }
.lb-scroll-sm { max-height: 140px; flex: none; }

.lb-row { display: grid; grid-template-columns: 28px 1fr 55px; align-items: center; padding: 0.4rem 0.3rem; border-radius: 8px; gap: 0.4rem; }
.lb-row:hover { background: var(--surface-2); }
.lb-rank { font-family: var(--mono); font-size: 0.75rem; font-weight: 700; color: var(--text-3); text-align: center; }
.lb-row:nth-child(1) .lb-rank { color: #d4a012; font-size: 0.95rem; }
.lb-row:nth-child(2) .lb-rank { color: #8a8a8a; }
.lb-row:nth-child(3) .lb-rank { color: #b87333; }
.lb-name { font-size: 0.78rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-score { font-family: var(--mono); font-size: 0.78rem; font-weight: 700; color: var(--accent); text-align: right; }
.lb-empty { text-align: center; padding: 1.5rem; color: var(--text-3); font-size: 0.8rem; }

/* Daily */
.daily-section { flex-shrink: 0; }
.daily-title { font-size: 0.85rem; font-weight: 700; margin-bottom: 0.4rem; }

/* Achievements */
.achieve-section { flex-shrink: 0; }
.achieve-title { font-size: 0.85rem; font-weight: 700; margin-bottom: 0.4rem; }
.achieve-grid { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.achieve-item { width: 32px; height: 32px; border-radius: 8px; background: var(--surface-2); box-shadow: var(--shadow-btn); display: flex; align-items: center; justify-content: center; font-size: 0.9rem; opacity: 0.3; transition: opacity 0.2s; }
.achieve-item.unlocked { opacity: 1; box-shadow: var(--shadow-in); }
.achieve-item[title] { cursor: help; }

/* ===== Boss Screen ===== */
.boss-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #fff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #172b4d;
    overflow-y: auto;
}

.boss-content { max-width: 800px; margin: 0 auto; padding: 0; }
.boss-header { display: flex; gap: 0; border-bottom: 1px solid #dfe1e6; background: #f4f5f7; }
.boss-tab { padding: 0.7rem 1.2rem; font-size: 0.82rem; color: #5e6c84; border-bottom: 2px solid transparent; }
.boss-tab.active { color: #0052cc; border-bottom-color: #0052cc; background: #fff; }
.boss-body { padding: 2rem 2.5rem; line-height: 1.7; }
.boss-body h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.boss-body h2 { font-size: 1.1rem; margin: 1.2rem 0 0.5rem; color: #172b4d; }
.boss-body ul { margin-left: 1.5rem; }
.boss-body li { margin-bottom: 0.4rem; font-size: 0.9rem; }
.boss-meta { font-size: 0.8rem; color: #5e6c84; margin-bottom: 1rem; }
.boss-green { color: #00875a; font-weight: 600; }
.boss-yellow { color: #ff8b00; font-weight: 600; }
.boss-red { color: #de350b; font-weight: 600; }
.boss-comment { margin-top: 1.5rem; padding: 1rem; background: #f4f5f7; border-radius: 6px; font-size: 0.85rem; }
.boss-footer { position: fixed; bottom: 1rem; right: 1.5rem; font-size: 0.7rem; color: #aaa; }

/* ===== Responsive ===== */
@media (max-width: 800px) {
    .layout { flex-direction: column; overflow-y: auto; height: auto; }
    html, body { overflow: auto; height: auto; }

    .panel-game {
        height: auto;
        min-height: unset;
        padding: 0.8rem 1rem;
        gap: 0.6rem;
    }

    .panel-lb {
        width: 100%;
        height: auto;
        max-height: none;
        box-shadow: none;
        border-top: 1px solid #d8d0c8;
        padding: 1rem;
    }

    /* Topbar compact */
    .brand { font-size: 1.2rem; }
    .brand-row { flex-wrap: wrap; gap: 0.4rem; }
    .online-badge { font-size: 0.65rem; padding: 0.2rem 0.5rem; }

    /* Controls inline */
    .controls { flex-direction: row; gap: 0.5rem; flex-wrap: wrap; }
    .ctrl-group { gap: 0.3rem; }
    .ctrl-label { font-size: 0.6rem; }
    .btn-seg { padding: 0.25rem 0.5rem; font-size: 0.65rem; }

    /* HUD compact */
    .hud { gap: 0.4rem; flex-wrap: wrap; }
    .hud-item { padding: 0.3rem 0.5rem; }
    .hud-val { font-size: 0.9rem; }
    .hud-label { font-size: 0.55rem; }

    /* Grid: fit screen */
    .grid-area { min-height: 220px; }
    .grid {
        max-width: 100%;
        gap: 0.5rem;
    }
    .hole { min-height: 55px; border-radius: 12px; }
    .mole-icon { font-size: 1.2rem; }
    .mole-text { font-size: 0.5rem; }

    /* Overlays */
    .ov-emoji { font-size: 2.2rem; }
    .ov-title { font-size: 1.1rem; }
    .btn-start { padding: 0.5rem 1.2rem; font-size: 0.82rem; }

    /* Recent */
    .recent { min-height: 22px; }
    .chip { font-size: 0.6rem; padding: 0.15rem 0.4rem; }

    /* Leaderboard */
    .lb-scroll { max-height: 200px; }
    .lb-scroll-sm { max-height: 120px; }
    .lb-title { font-size: 0.9rem; }
    .daily-title, .achieve-title { font-size: 0.78rem; }
    .achieve-item { width: 28px; height: 28px; font-size: 0.75rem; }

    /* Stats compact */
    .sbox { padding: 0.4rem 0.7rem; }
    .sbox-num { font-size: 1rem; }
    .sbox-label { font-size: 0.58rem; }

    /* Nick compact */
    .nick-show { padding: 0.3rem 0.5rem; }
    .nick-name { font-size: 0.78rem; }
}

/* Extra small screens (phones < 400px) */
@media (max-width: 400px) {
    .panel-game { padding: 0.6rem 0.7rem; gap: 0.5rem; }
    .grid { gap: 0.4rem; }
    .hole { min-height: 48px; border-radius: 10px; }
    .mole-icon { font-size: 1rem; }
    .mole-text { display: none; }
    .stats-bar { gap: 0.4rem; }
    .sbox { padding: 0.3rem 0.5rem; }
    .sbox-num { font-size: 0.85rem; }
    .hud { gap: 0.3rem; }
    .hud-item { padding: 0.25rem 0.4rem; }
    .hud-val { font-size: 0.8rem; }
    .controls { gap: 0.3rem; }
    .btn-seg { padding: 0.2rem 0.4rem; font-size: 0.6rem; }
}
