/* ============================================================
   Tower Defense — Tactical Command Theme
   Accent: #8fae3b (olive)   Secondary: #64748b (steel)
   Font: Syne (display) · DM Sans (body)
   ============================================================ */

/* ─── Layout ─── */
.td-layout {
    display: grid;
    grid-template-columns: 160px minmax(0, 860px) 160px;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
        ".    game  .    "
        "left game  right"
        ".    game  .    ";
    justify-content: center;
    gap: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    min-height: calc(100vh - 80px);
}

#td-app {
    grid-area: game;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ─── Ad Slots ─── */
.ad-slot { display: flex; align-items: flex-start; justify-content: center; }
.ad-slot--left  { grid-area: left;  padding-top: 2rem; }
.ad-slot--right { grid-area: right; padding-top: 2rem; }
.ad-slot--top, .ad-slot--bottom { display: none; }
.ad-placeholder {
    background: rgba(255,255,255,0.03);
    border: 1px dashed rgba(255,255,255,0.08);
    border-radius: 10px;
    color: rgba(255,255,255,0.12);
    font-size: 0.7rem; font-weight: 700; letter-spacing: 3px;
    text-align: center; padding: 2rem 1rem; width: 100%;
}
.ad-placeholder--vertical {
    min-height: 500px; display: flex; align-items: center; justify-content: center;
    position: sticky; top: 5rem;
}

/* ─── Screens ─── */
.screen { display: none; }
.screen.active { display: flex; flex-direction: column; }

/* ─── Menu ─── */
.menu-card {
    background: linear-gradient(135deg, #1a1f2e 0%, #16213e 100%);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 2.5rem;
    max-width: 720px;
    margin: 2rem auto;
    text-align: center;
}
.menu-title {
    font-family: 'Syne', sans-serif;
    font-size: 2.8rem; font-weight: 900;
    letter-spacing: 8px;
    background: linear-gradient(135deg, #8fae3b, #00bcd4, #2196f3);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}
.menu-sub { color: rgba(255,255,255,0.5); margin-bottom: 1.5rem; font-size: 0.95rem; }

.menu-info-grid {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem; margin-bottom: 1.5rem;
}
.info-item {
    background: rgba(255,255,255,0.05);
    border-radius: 8px; padding: 0.5rem 0.8rem;
    display: flex; align-items: center; gap: 0.5rem;
    color: rgba(255,255,255,0.7); font-size: 0.85rem;
}
.info-icon { font-size: 1.2rem; }

.tower-guide {
    background: rgba(0,0,0,0.2);
    border-radius: 10px; padding: 1rem 1.2rem;
    margin-bottom: 1.5rem; text-align: left;
}
.tower-guide h3 { color: rgba(255,255,255,0.6); font-size: 0.8rem; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 0.6rem; }
.tower-guide-list { display: flex; flex-direction: column; gap: 0.35rem; }
.tg-row { display: flex; align-items: center; gap: 0.6rem; }
.tg-icon { width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.tg-name { font-size: 0.85rem; color: #ccc; font-weight: 600; min-width: 90px; }
.tg-desc { font-size: 0.78rem; color: rgba(255,255,255,0.45); }

.menu-actions { display: flex; gap: 0.8rem; justify-content: center; margin-bottom: 0.8rem; flex-wrap: wrap; }
.control-hint { font-size: 0.72rem; color: rgba(255,255,255,0.3); }
.volume-row {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.8rem; color: rgba(255,255,255,0.55);
    justify-content: center; margin-top: 0.4rem;
}
.volume-row input[type=range] { width: 90px; accent-color: #8fae3b; }
.volume-row span { min-width: 24px; text-align: right; font-size: 0.75rem; }

/* ─── Tutorial ─── */
.td-tutorial {
    position: fixed; inset: 0; z-index: 600;
    background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
}
.td-tutorial.hidden { display: none; }
.td-tut-card {
    background: linear-gradient(135deg, #1a1f2e, #16213e);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 16px;
    padding: 2rem;
    max-width: 460px; width: 100%;
    text-align: center;
}
.td-tut-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1rem;
}
.td-tut-badge {
    background: rgba(143,174,59,0.2); border: 1px solid #8fae3b;
    border-radius: 20px; padding: 0.2rem 0.7rem;
    font-size: 0.7rem; color: #8fae3b; font-weight: 700; letter-spacing: 1px;
    text-transform: uppercase;
}
.td-tut-step { font-size: 0.75rem; color: rgba(255,255,255,0.4); }
.td-tut-icon { font-size: 2.8rem; margin-bottom: 0.5rem; }
.td-tut-title { color: #eee; font-size: 1.1rem; margin: 0 0 0.5rem; }
.td-tut-body { color: rgba(255,255,255,0.65); font-size: 0.88rem; line-height: 1.6; margin: 0 0 1.5rem; }
.td-tut-footer { display: flex; justify-content: space-between; align-items: center; }
.td-tut-nav { display: flex; gap: 0.5rem; }
.btn--sm { padding: 0.35rem 0.75rem; font-size: 0.78rem; }

/* ─── Buttons ─── */
.btn {
    border: none; border-radius: 8px; cursor: pointer;
    font-family: inherit; font-weight: 600; transition: all 0.15s ease;
    padding: 0.5rem 1.2rem; font-size: 0.85rem;
}
.btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; filter: none; }
.btn--primary { background: #8fae3b; color: #fff; }
.btn--outline { background: transparent; border: 1.5px solid rgba(255,255,255,0.3); color: rgba(255,255,255,0.8); }
.btn--ghost  { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.6); }
.btn--lg { padding: 0.8rem 2rem; font-size: 1rem; border-radius: 10px; }
.btn--upgrade { background: linear-gradient(135deg, #ff9800, #f44336); color: #fff; width: 100%; padding: 0.5rem; font-size: 0.78rem; line-height: 1.3; text-align: center; border-radius: 6px; }
.btn--sell    { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.7); border: 1px solid rgba(255,255,255,0.15); width: 100%; padding: 0.5rem; font-size: 0.78rem; line-height: 1.3; text-align: center; border-radius: 6px; margin-top: 0.3rem; }
.btn--wave { background: linear-gradient(135deg, #8fae3b, #00bcd4); color: #fff; font-weight: 700; padding: 0.6rem 1rem; font-size: 0.85rem; width: 100%; border-radius: 8px; }

/* ─── HUD ─── */
#game-hud {
    display: flex; align-items: center; gap: 0.5rem;
    background: linear-gradient(90deg, #0d1117, #161b22, #0d1117);
    border: 1px solid rgba(255,255,255,0.08);
    border-bottom: none;
    padding: 0.4rem 0.8rem;
    border-radius: 10px 10px 0 0;
}
.hud-cell { display: flex; align-items: center; gap: 0.25rem; flex: 1; }
.hud-cell--center { justify-content: center; }
.hud-icon { font-size: 0.9rem; }
.hud-label { font-size: 0.65rem; color: rgba(255,255,255,0.4); }
.hud-val { font-size: 1rem; font-weight: 700; color: #eee; }
.hud-val--wave { color: #ff9800; }
.btn-speed {
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
    color: #fff; border-radius: 5px; padding: 0.2rem 0.5rem; cursor: pointer;
    font-size: 0.75rem; font-weight: 700; font-family: inherit;
    transition: background 0.15s;
}
.btn-speed:hover { background: rgba(255,255,255,0.2); }

/* ─── Canvas ─── */
.canvas-area {
    position: relative;
    border: 1px solid rgba(255,255,255,0.1);
    border-top: none; border-bottom: none;
    line-height: 0;
    overflow: hidden;
}
#td-canvas {
    display: block;
    width: 100%;
    max-width: 800px;
    cursor: crosshair;
}

/* ─── Float Notice ─── */
.float-notice {
    position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
    background: rgba(244,67,54,0.9); color: #fff;
    border-radius: 20px; padding: 0.4rem 1rem;
    font-size: 0.82rem; font-weight: 600;
    pointer-events: none; white-space: nowrap;
    transition: opacity 0.3s;
}
.float-notice.hidden { display: none; }

/* ─── Wave Banner ─── */
.wave-banner {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.75);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 12px;
    color: #fff; font-size: 1.5rem; font-weight: 900;
    padding: 0.7rem 2rem;
    letter-spacing: 3px;
    pointer-events: none;
    transition: opacity 0.8s ease;
}
.wave-banner.fade-out { opacity: 0; }
.wave-banner.hidden { display: none; }

/* ─── Tower Panel ─── */
.tower-panel {
    display: flex; gap: 0.6rem; align-items: flex-start;
    background: #0d1117;
    border: 1px solid rgba(255,255,255,0.08);
    border-top: none;
    padding: 0.6rem;
    border-radius: 0 0 10px 10px;
}
.tower-btns {
    display: flex; gap: 0.4rem; flex-wrap: wrap;
    flex-shrink: 0;
}
.tower-btn {
    display: flex; flex-direction: column; align-items: center;
    background: rgba(255,255,255,0.05);
    border: 1.5px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 0.4rem 0.5rem;
    cursor: pointer; transition: all 0.15s ease;
    width: 72px; gap: 0.15rem;
    font-family: inherit;
}
.tower-btn:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.25); transform: translateY(-2px); }
.tower-btn.active { border-color: #8fae3b; background: rgba(143,174,59,0.15); box-shadow: 0 0 10px rgba(143,174,59,0.3); }
.tb-icon { width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.tb-name { font-size: 0.7rem; color: #ccc; font-weight: 600; }
.tb-cost { font-size: 0.65rem; color: #ffd700; }

/* ─── Panel Right ─── */
.panel-right { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }

/* ─── Tower Info Panel ─── */
.tower-info-panel {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    font-size: 0.8rem;
}
.tower-info-panel.hidden { display: none; }
.ti-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.ti-emoji { font-size: 1.4rem; }
.ti-name { color: #eee; font-weight: 700; font-size: 0.85rem; }
.ti-desc { color: rgba(255,255,255,0.45); font-size: 0.72rem; }
.ti-stats { display: flex; gap: 0.6rem; color: rgba(255,255,255,0.7); font-size: 0.78rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.ti-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem; }
.ti-maxlv { font-size: 0.72rem; color: #ffd700; text-align: center; padding: 0.4rem; background: rgba(255,215,0,0.1); border-radius: 6px; display: block; }

/* ─── Wave Control ─── */
#wave-control { display: flex; align-items: center; flex-direction: column; gap: 0.25rem; }

/* ─── Next Wave Preview ─── */
.next-wave-preview {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.55);
    padding: 0.2rem 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    min-height: 20px;
}
.next-wave-preview .nwp-label {
    color: rgba(255,255,255,0.3);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ─── Pause Overlay ─── */
.overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex; align-items: center; justify-content: center;
    z-index: 500;
}
.overlay.hidden { display: none; }
.overlay-box {
    background: #1a1f2e;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 14px;
    padding: 2rem;
    text-align: center;
    min-width: 260px;
    display: flex; flex-direction: column; gap: 0.8rem;
}
.overlay-box h2 { color: #eee; margin: 0; }

/* ─── Result Screens ─── */
.result-card {
    background: linear-gradient(135deg, #1a1f2e, #16213e);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 2rem;
    max-width: 500px;
    margin: 2rem auto;
    text-align: center;
    display: flex; flex-direction: column; gap: 0.8rem;
}
.result-card h2 { font-size: 1.8rem; color: #eee; margin: 0; }
.result-card--victory { border-color: #ffd700; box-shadow: 0 0 30px rgba(255,215,0,0.2); }
.result-card--victory h2 { background: linear-gradient(135deg, #ffd700, #ff9800); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.result-sub { color: rgba(255,255,255,0.5); font-size: 0.9rem; margin: 0; }
.result-stats { background: rgba(0,0,0,0.2); border-radius: 10px; padding: 0.8rem 1rem; }
.rs-row { display: flex; justify-content: space-between; padding: 0.3rem 0; border-bottom: 1px solid rgba(255,255,255,0.06); color: rgba(255,255,255,0.7); font-size: 0.88rem; }
.rs-row:last-child { border: none; }
.rs-row span:last-child { color: #eee; font-weight: 700; }
.result-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
#go-nickname-input input, #vic-nickname-input input {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px; padding: 0.5rem 1rem;
    color: #eee; font-family: inherit; font-size: 0.9rem; width: 200px;
    outline: none;
}
#go-nickname-input input:focus, #vic-nickname-input input:focus {
    border-color: #8fae3b;
}

/* ─── Leaderboard ─── */
.lb-card {
    background: linear-gradient(135deg, #1a1f2e, #16213e);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px; padding: 2rem;
    max-width: 500px; margin: 2rem auto;
    text-align: center;
}
.lb-card h2 { color: #eee; margin-bottom: 1rem; }
#leaderboard-list { list-style: none; padding: 0; margin: 0 0 1.2rem; display: flex; flex-direction: column; gap: 0.4rem; }
#leaderboard-list li {
    display: flex; align-items: center; gap: 0.6rem;
    background: rgba(255,255,255,0.05);
    border-radius: 8px; padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
}
.rank { width: 24px; font-weight: 900; color: #ffd700; }
.lb-name { flex: 1; color: #eee; text-align: left; }
.lb-score { font-weight: 700; color: #8fae3b; }
.lb-time { font-size: 0.7rem; color: rgba(255,255,255,0.3); }

/* ─── Achievement Toast ─── */
.achievement-toast {
    position: absolute; top: 8px; left: 50%;
    transform: translateX(-50%) translateY(-80px);
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 1px solid #ffd700; border-radius: 10px;
    padding: 0.45rem 0.85rem;
    display: flex; align-items: center; gap: 0.5rem;
    min-width: 175px; max-width: 260px; z-index: 200;
    transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1), opacity 0.35s ease;
    opacity: 0; pointer-events: none;
}
.achievement-toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.ach-icon { font-size: 1.35rem; flex-shrink: 0; }
.ach-body { display: flex; flex-direction: column; }
.ach-label { font-size: 0.58rem; color: #ffd700; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.ach-name  { font-size: 0.78rem; color: #eee; font-weight: 600; }

/* ─── Achievement Summary ─── */
.achievement-summary { margin: 0.3rem 0; }
.ach-summary-title { font-size: 0.72rem; color: rgba(255,255,255,0.4); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 0.4rem; }
.ach-badge-list { display: flex; flex-wrap: wrap; gap: 0.25rem; justify-content: center; }
.ach-badge { width: 30px; height: 30px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 1rem; cursor: default; }
.ach-badge.earned { background: rgba(255,215,0,0.12); border: 1px solid rgba(255,215,0,0.35); }
.ach-badge.locked  { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1); color: rgba(255,255,255,0.2); font-size: 0.72rem; }

/* ─── Responsive ─── */
@media (max-width: 900px) {
    .td-layout {
        grid-template-columns: 1fr;
        grid-template-areas: "game";
        max-width: 100%;
        padding: 0 0.5rem;
    }
    .ad-slot--left, .ad-slot--right { display: none; }
    .ad-slot--top, .ad-slot--bottom { display: flex; grid-area: unset; }
}
@media (max-width: 600px) {
    .menu-card { padding: 1.5rem 1rem; margin: 0.5rem; }
    .menu-title { font-size: 2rem; letter-spacing: 4px; }
    .tower-btn { width: 60px; }
    .tower-panel { flex-wrap: wrap; }
    .result-card { margin: 0.5rem; padding: 1.2rem; }
    #game-hud { padding: 0.3rem 0.5rem; gap: 0.3rem; }
    .hud-val { font-size: 0.85rem; }
}
