/* Rope Swing — GameCMB (gamecmb.com) */

:root {
    --accent: #5ad1ff;
    --accent-warm: #ffe066;
    --bg-dark: #05060f;
    --panel: rgba(10, 14, 30, 0.86);
    --panel-border: rgba(255, 255, 255, 0.12);
    --text: #eef4ff;
    --text-dim: #9fb0d0;
    --danger: #ff5c8a;
    --radius: 16px;
    --font: 'Poppins', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-dark);
    color: var(--text);
    font-family: var(--font);
    overscroll-behavior: none;
}

[hidden] { display: none !important; }

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100dvh;
}

a { color: var(--accent); }

.site-header {
    width: 100%;
    max-width: 1200px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
}

.site-header .brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text);
    text-decoration: none;
}
.site-header .brand svg { width: 26px; height: 26px; }
.site-header nav a {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 14px;
    margin-left: 14px;
}
.site-header nav a:hover { color: var(--accent); }

#gameShell {
    position: relative;
    width: 100%;
    max-width: 1100px;
    aspect-ratio: 16 / 9;
    max-height: 82vh;
    margin: 6px auto;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--panel-border);
    background: #000;
    touch-action: none;
}

@media (max-width: 720px) {
    #gameShell {
        max-width: 100vw;
        width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        aspect-ratio: auto;
        border-radius: 0;
        margin: 0;
    }
    .site-header, .seo-section, .ad-slot { display: none; }
}

/* Fullscreen mode: the game area should actually grow to fill the
   screen, not just hide the browser chrome while staying capped at its
   normal small max-width — toggling the Fullscreen API alone would not
   look "fullscreen" without this. */
body.is-fullscreen .site-header,
body.is-fullscreen .seo-section,
body.is-fullscreen .ad-slot,
body.is-fullscreen .site-footer {
    display: none;
}
body.is-fullscreen #gameShell {
    max-width: 100vw;
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    aspect-ratio: auto;
    border-radius: 0;
    margin: 0;
}

#gameCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    cursor: pointer;
}

/* ---------- Top controls ---------- */
#topControls {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 70;
}
.icon-btn {
    min-width: 40px;
    min-height: 40px;
    border-radius: 10px;
    border: 1px solid var(--panel-border);
    background: rgba(10, 14, 30, 0.6);
    color: var(--text);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.12); }

/* ---------- HUD ---------- */
#hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 40;
    font-weight: 700;
}
.hud-stat {
    position: absolute;
    top: 56px;
    padding: 6px 14px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    font-size: 15px;
    line-height: 1.35;
}
.hud-stat .label { font-size: 10px; color: var(--text-dim); font-weight: 600; letter-spacing: 0.08em; display: block; }
#hudScoreBox { left: 12px; }
#hudBestBox { right: 12px; text-align: right; }
#hudCombo {
    position: absolute;
    top: 56px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--accent-warm), #ff9d5c);
    color: #201200;
    padding: 5px 16px;
    border-radius: 999px;
    font-size: 14px;
    box-shadow: 0 6px 18px rgba(255, 190, 80, 0.4);
}

/* ---------- Overlays (menu / game over / leaderboard) ---------- */
.overlay {
    position: absolute;
    inset: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px;
    text-align: center;
    background: radial-gradient(120% 120% at 50% 0%, rgba(30, 20, 60, 0.55), rgba(2, 2, 10, 0.92));
    backdrop-filter: blur(2px);
}

.logo {
    font-size: clamp(30px, 6vw, 52px);
    font-weight: 800;
    letter-spacing: 0.03em;
    background: linear-gradient(90deg, #5ad1ff, #ff9dfa, #ffe066);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin: 0;
    text-shadow: 0 0 40px rgba(120, 180, 255, 0.25);
}
.subtitle {
    color: var(--text-dim);
    font-size: clamp(13px, 2.4vw, 16px);
    margin: -6px 0 8px;
    letter-spacing: 0.04em;
}

.btn {
    min-width: 220px;
    min-height: 52px;
    padding: 12px 28px;
    font-size: 17px;
    font-weight: 700;
    font-family: var(--font);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    letter-spacing: 0.03em;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
    background: linear-gradient(135deg, #5ad1ff, #7a7bff);
    color: #04101f;
    box-shadow: 0 10px 30px rgba(90, 209, 255, 0.35);
}
.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border: 1px solid var(--panel-border);
    min-height: 44px;
    min-width: 180px;
    font-size: 15px;
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.16); }

.instructions {
    display: flex;
    gap: 10px;
    color: var(--text-dim);
    font-size: 12px;
    letter-spacing: 0.05em;
    margin-top: 4px;
}
.instructions span {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    padding: 6px 10px;
    border-radius: 8px;
}

.gcmb-footer-badge {
    position: absolute;
    bottom: 10px;
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 0.05em;
}

/* Game over specifics */
#screenGameOver .go-title {
    font-size: clamp(24px, 5vw, 34px);
    font-weight: 800;
    color: var(--danger);
    letter-spacing: 0.04em;
    margin: 0;
}
.go-badge {
    background: linear-gradient(135deg, var(--accent-warm), #ff9d5c);
    color: #201200;
    font-weight: 800;
    padding: 4px 14px;
    border-radius: 999px;
    font-size: 13px;
    letter-spacing: 0.05em;
}
.go-stats {
    display: flex;
    gap: 22px;
    margin: 4px 0;
}
.go-stat { text-align: center; }
.go-stat .value { font-size: 28px; font-weight: 800; }
.go-stat .label { font-size: 11px; color: var(--text-dim); letter-spacing: 0.08em; }
#goMessage { color: var(--text-dim); font-size: 14px; max-width: 320px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* Nickname modal */
#nicknameModal {
    position: absolute;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(2, 2, 10, 0.75);
}
.nickname-form {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: min(320px, 88vw);
    text-align: center;
}
.nickname-form h2 { margin: 0; font-size: 18px; }
.nickname-form input {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--panel-border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    font-size: 16px;
    font-family: var(--font);
    text-align: center;
}
.nickname-hint { font-size: 11px; color: var(--text-dim); }

/* Leaderboard */
#screenLeaderboard { justify-content: flex-start; padding-top: 40px; }
.lb-panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    width: min(420px, 92vw);
    max-height: 72%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.lb-header { padding: 16px 18px 8px; }
.lb-tabs { display: flex; gap: 8px; padding: 0 18px; }
.lb-tab {
    flex: 1;
    padding: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--panel-border);
    color: var(--text-dim);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
}
.lb-tab.active { background: var(--accent); color: #04101f; }
#lbList { overflow-y: auto; padding: 10px 12px; flex: 1; }
.lb-row {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    gap: 8px;
    padding: 8px 8px;
    border-radius: 8px;
    font-size: 14px;
}
.lb-row:nth-child(odd) { background: rgba(255, 255, 255, 0.03); }
.lb-rank { color: var(--accent-warm); font-weight: 700; }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.lb-score { font-weight: 700; }
#lbStatus { padding: 10px 18px; color: var(--text-dim); font-size: 13px; }
.lb-footer { padding: 12px; text-align: center; }

/* Achievement toast */
#achievementToast {
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: linear-gradient(135deg, #1c2340, #2b1f52);
    border: 1px solid rgba(255, 224, 102, 0.4);
    color: var(--accent-warm);
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    opacity: 0;
    z-index: 90;
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}
#achievementToast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- SEO content section below the game (desktop only) ---------- */
.seo-section {
    max-width: 780px;
    width: 100%;
    padding: 28px 20px 60px;
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1.7;
}
.seo-section h1 { color: var(--text); font-size: 22px; margin-bottom: 4px; }
.seo-section h2 { color: var(--text); font-size: 16px; margin-top: 22px; }
.seo-section ul { padding-left: 20px; }

.ad-slot {
    width: 100%;
    max-width: 780px;
    min-height: 90px;
    margin: 14px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 12px;
    border: 1px dashed var(--panel-border);
    border-radius: 10px;
}

.site-footer {
    color: var(--text-dim);
    font-size: 12px;
    padding: 20px;
    text-align: center;
}
