/* ========================================================
   Galaxy Conquest – Space Strategy Game
   Dark space theme with glassmorphism & glow effects
   ======================================================== */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-deep:    #0a0a1a;
    --bg-surface: #0d1117;
    --bg-card:    rgba(13, 17, 23, 0.65);
    --blue:       #4a9eff;
    --blue-glow:  rgba(74, 158, 255, 0.45);
    --red:        #ff4a4a;
    --red-glow:   rgba(255, 74, 74, 0.4);
    --gold:       #ff9f1a;
    --gold-glow:  rgba(255, 159, 26, 0.4);
    --text:       #e8eaed;
    --text-dim:   #8b949e;
    --border:     rgba(255, 255, 255, 0.08);
    --radius:     10px;
    --radius-pill: 50px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
            Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
    --transition: 0.2s ease;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg-deep);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Utility ---------- */
.hidden {
    display: none !important;
}

/* ---------- Canvas ---------- */
#game-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: block;
    z-index: 0;
    background: var(--bg-deep);
}

/* ==========================================================
   MENU SCREEN
   ========================================================== */
#menu-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-deep);
    /* Animated starfield via CSS gradients */
    background-image:
        radial-gradient(1.5px 1.5px at  10%  15%, rgba(255,255,255,0.7) 50%, transparent 100%),
        radial-gradient(1px   1px   at  25%  65%, rgba(255,255,255,0.5) 50%, transparent 100%),
        radial-gradient(1.5px 1.5px at  42%  28%, rgba(255,255,255,0.6) 50%, transparent 100%),
        radial-gradient(1px   1px   at  58%  82%, rgba(255,255,255,0.4) 50%, transparent 100%),
        radial-gradient(2px   2px   at  73%  12%, rgba(255,255,255,0.8) 50%, transparent 100%),
        radial-gradient(1px   1px   at  85%  45%, rgba(255,255,255,0.5) 50%, transparent 100%),
        radial-gradient(1.5px 1.5px at  92%  70%, rgba(255,255,255,0.6) 50%, transparent 100%),
        radial-gradient(1px   1px   at  15%  90%, rgba(255,255,255,0.4) 50%, transparent 100%),
        radial-gradient(1px   1px   at  50%  50%, rgba(255,255,255,0.3) 50%, transparent 100%),
        radial-gradient(2px   2px   at  35%  42%, rgba(74,158,255,0.6)  50%, transparent 100%),
        radial-gradient(1.5px 1.5px at  68%  55%, rgba(255,159,26,0.4)  50%, transparent 100%),
        radial-gradient(1px   1px   at   5%  50%, rgba(255,255,255,0.3) 50%, transparent 100%),
        radial-gradient(1px   1px   at  78%  35%, rgba(255,255,255,0.4) 50%, transparent 100%),
        radial-gradient(1.5px 1.5px at  20%  40%, rgba(255,255,255,0.5) 50%, transparent 100%),
        radial-gradient(1px   1px   at  62%  18%, rgba(255,255,255,0.4) 50%, transparent 100%),
        radial-gradient(2px   2px   at  48%  75%, rgba(74,158,255,0.35) 50%, transparent 100%);
    background-size: 200% 200%;
    animation: starDrift 90s linear infinite;
}

@keyframes starDrift {
    0%   { background-position: 0% 0%; }
    50%  { background-position: 100% 100%; }
    100% { background-position: 0% 0%; }
}

/* Glassmorphism card */
.menu-container {
    width: 460px;
    max-width: 92vw;
    padding: 48px 40px 40px;
    background: var(--bg-card);
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow:
        0 0 60px rgba(74, 158, 255, 0.06),
        0 30px 80px rgba(0, 0, 0, 0.55);
    text-align: center;
    animation: cardFadeIn 0.8s ease forwards;
}

@keyframes cardFadeIn {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ---------- Title ---------- */
.game-title {
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    line-height: 1.1;
    margin-bottom: 6px;
    color: var(--text);
    text-shadow: 0 0 30px rgba(74, 158, 255, 0.35);
    animation: titleGlow 3s ease-in-out infinite alternate;
}

.game-title span {
    display: block;
    font-size: 3.2rem;
    background: linear-gradient(135deg, var(--blue), #7ec8ff, var(--gold));
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 6s ease infinite;
}

@keyframes titleGlow {
    from { text-shadow: 0 0 30px rgba(74, 158, 255, 0.25); }
    to   { text-shadow: 0 0 50px rgba(74, 158, 255, 0.5); }
}

@keyframes gradientShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.tagline {
    color: var(--text-dim);
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    margin-bottom: 36px;
}

/* ---------- Menu Options ---------- */
.menu-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.option-group {
    text-align: left;
    animation: slideUp 0.6s ease both;
}
.option-group:nth-child(1) { animation-delay: 0.15s; }
.option-group:nth-child(2) { animation-delay: 0.25s; }
.option-group:nth-child(3) { animation-delay: 0.35s; }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.option-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin-bottom: 8px;
}

/* Pill-shaped toggle group */
.button-group {
    display: flex;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.button-group button {
    flex: 1;
    padding: 10px 0;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dim);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.button-group button:not(:last-child)::after {
    content: "";
    position: absolute;
    right: 0;
    top: 25%;
    height: 50%;
    width: 1px;
    background: var(--border);
    transition: opacity var(--transition);
}

.button-group button:hover {
    color: var(--text);
    background: rgba(74, 158, 255, 0.08);
}

.button-group button.selected {
    color: #fff;
    background: var(--blue);
    box-shadow:
        0 0 16px var(--blue-glow),
        inset 0 1px 0 rgba(255,255,255,0.15);
}

.button-group button.selected::after {
    opacity: 0;
}

/* ---------- Primary Button ---------- */
.primary-btn {
    display: inline-block;
    width: 100%;
    padding: 16px 32px;
    margin-top: 8px;
    font-family: var(--font);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #fff;
    background: linear-gradient(135deg, var(--blue), #3578d8);
    border: none;
    border-radius: var(--radius-pill);
    cursor: pointer;
    box-shadow:
        0 0 20px var(--blue-glow),
        0 4px 20px rgba(0, 0, 0, 0.3);
    transition: all var(--transition);
    animation: slideUp 0.6s ease 0.45s both;
    position: relative;
    overflow: hidden;
}

.primary-btn::before {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--blue), #7ec8ff, var(--blue));
    background-size: 200% 200%;
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s ease;
    animation: gradientShift 4s ease infinite;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow:
        0 0 35px var(--blue-glow),
        0 8px 30px rgba(0, 0, 0, 0.4);
    animation: pulse 1.5s ease infinite;
}

.primary-btn:hover::before {
    opacity: 1;
}

.primary-btn:active {
    transform: translateY(1px) scale(0.98);
    box-shadow:
        0 0 10px var(--blue-glow),
        0 2px 10px rgba(0, 0, 0, 0.3);
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 20px var(--blue-glow), 0 4px 20px rgba(0,0,0,0.3); }
    50%      { box-shadow: 0 0 40px var(--blue-glow), 0 4px 30px rgba(0,0,0,0.4); }
}

/* ---------- Secondary Button ---------- */
.secondary-btn {
    display: inline-block;
    width: 100%;
    padding: 14px 28px;
    margin-top: 10px;
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all var(--transition);
}

.secondary-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.secondary-btn:active {
    transform: translateY(1px) scale(0.98);
}

/* ---------- Controls Help ---------- */
.controls-help {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    text-align: left;
    animation: slideUp 0.6s ease 0.55s both;
}

.controls-help h3 {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-dim);
    margin-bottom: 10px;
}

.controls-help p {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.4);
    line-height: 1.7;
}

.controls-help strong {
    color: rgba(255, 255, 255, 0.65);
    font-weight: 600;
}

/* ==========================================================
   HUD
   ========================================================== */
#hud {
    position: fixed;
    inset: 0;
    z-index: 50;
    pointer-events: none;
}

#hud-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: linear-gradient(180deg, rgba(10,10,26,0.85) 0%, transparent 100%);
    pointer-events: auto;
}

#hud-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    background: linear-gradient(0deg, rgba(10,10,26,0.85) 0%, transparent 100%);
    pointer-events: auto;
}

/* Player / AI info */
.player-info, .ai-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.ai-info {
    gap: 16px;
    color: var(--text-dim);
    font-size: 0.8rem;
}

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.player-dot {
    background: var(--blue);
    box-shadow: 0 0 8px var(--blue-glow);
}

#game-timer {
    font-size: 0.85rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-dim);
    letter-spacing: 0.05em;
}

/* HUD Buttons */
.hud-btn {
    padding: 8px 18px;
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all var(--transition);
}

.hud-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.18);
    transform: translateY(-1px);
}

.hud-btn:active {
    transform: translateY(1px) scale(0.97);
}

/* ==========================================================
   GAME OVER SCREEN
   ========================================================== */
#gameover-screen {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 26, 0.7);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    animation: overlayFadeIn 0.5s ease forwards;
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.gameover-container {
    width: 420px;
    max-width: 90vw;
    padding: 48px 40px 36px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow:
        0 0 80px rgba(74, 158, 255, 0.08),
        0 30px 80px rgba(0, 0, 0, 0.6);
    text-align: center;
    animation: cardPopIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes cardPopIn {
    from { opacity: 0; transform: scale(0.85) translateY(30px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

#gameover-title {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}

/* Victory styling */
#gameover-screen[data-result="victory"] #gameover-title {
    background: linear-gradient(135deg, var(--gold), #ffe066, var(--gold));
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    animation: gradientShift 4s ease infinite;
    filter: drop-shadow(0 0 20px var(--gold-glow));
}

/* Defeat styling */
#gameover-screen[data-result="defeat"] #gameover-title {
    color: var(--red);
    text-shadow: 0 0 30px var(--red-glow);
}

#gameover-subtitle {
    font-size: 1rem;
    color: var(--text-dim);
    margin-bottom: 28px;
}

#gameover-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 28px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--text-dim);
    text-align: left;
}

#gameover-stats:empty {
    display: none;
}

/* ==========================================================
   PAUSE SCREEN
   ========================================================== */
#pause-screen {
    position: fixed;
    inset: 0;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 26, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: overlayFadeIn 0.3s ease forwards;
}

.pause-container {
    width: 340px;
    max-width: 88vw;
    padding: 40px 36px 32px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow:
        0 0 60px rgba(74, 158, 255, 0.06),
        0 20px 60px rgba(0, 0, 0, 0.5);
    text-align: center;
    animation: cardPopIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.pause-container h2 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: var(--text);
    margin-bottom: 24px;
    text-shadow: 0 0 20px rgba(74, 158, 255, 0.2);
}

/* ==========================================================
   RESPONSIVE
   ========================================================== */
@media (max-width: 520px) {
    .menu-container {
        padding: 32px 24px 28px;
    }

    .game-title {
        font-size: 2rem;
    }

    .game-title span {
        font-size: 2.3rem;
    }

    .tagline {
        font-size: 0.85rem;
        margin-bottom: 28px;
    }

    .button-group button {
        padding: 9px 0;
        font-size: 0.8rem;
    }

    .primary-btn {
        padding: 14px 24px;
        font-size: 1rem;
    }

    .controls-help p {
        font-size: 0.72rem;
    }

    #hud-top {
        padding: 10px 14px;
        flex-wrap: wrap;
        gap: 6px;
    }

    #hud-bottom {
        padding: 10px 14px;
        gap: 6px;
    }

    .hud-btn {
        padding: 7px 12px;
        font-size: 0.75rem;
    }

    .player-info, #game-timer {
        font-size: 0.78rem;
    }

    .gameover-container,
    .pause-container {
        padding: 32px 24px 24px;
    }

    #gameover-title {
        font-size: 2.2rem;
    }
}

@media (max-width: 360px) {
    .game-title {
        font-size: 1.7rem;
    }

    .game-title span {
        font-size: 1.9rem;
    }

    .menu-container {
        padding: 24px 18px 22px;
    }
}

/* ==========================================================
   UTILITY / SELECTION
   ========================================================== */
::selection {
    background: var(--blue);
    color: #fff;
}

/* Hide scrollbars globally */
::-webkit-scrollbar {
    display: none;
}

body {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
