/* =========================================
   VIKING — MEDIEVAL COMBAT
   Main Game Stylesheet
========================================= */

:root {
    color-scheme: dark;

    --background: #11110f;
    --panel: rgba(20, 19, 16, 0.78);
    --border: rgba(210, 183, 132, 0.22);
    --gold: #c6a568;
    --gold-light: #e5c990;
    --text: #f0e9dc;
    --muted: #a49b8b;
    --danger: #a84335;
    --success: #8baf76;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--background);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", sans-serif;
}

body {
    user-select: none;
    -webkit-user-select: none;
    overscroll-behavior: none;
}

button {
    font: inherit;
    color: inherit;
    cursor: pointer;
    touch-action: manipulation;
}

#game {
    position: relative;
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    isolation: isolate;
    background:
        radial-gradient(ellipse at center, #37352c 0%, #11110f 100%);
}

#game-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    outline: none;
    touch-action: none;
}

/* =========================================
   LOADING SCREEN
========================================= */

#loading-screen {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    background:
        radial-gradient(ellipse at center, #302c22 0%, #11110f 75%);
    transition:
        opacity 0.7s ease,
        visibility 0.7s ease;
}

#loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-content {
    width: min(340px, 80vw);
    text-align: center;
}

.loading-content h1 {
    color: var(--gold-light);
    font-size: clamp(2.5rem, 9vw, 4.5rem);
    font-weight: 900;
    letter-spacing: 0.2em;
    text-indent: 0.2em;
    text-shadow: 0 0 35px rgba(198, 165, 104, 0.2);
}

.loading-content p {
    margin-top: 14px;
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.loading-bar {
    height: 3px;
    margin-top: 28px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.1);
}

#loading-progress {
    width: 0%;
    height: 100%;
    background: var(--gold);
    box-shadow: 0 0 12px rgba(198, 165, 104, 0.5);
    transition: width 0.25s ease;
}

/* =========================================
   GAME HUD
========================================= */

#game-ui {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
}

.game-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 22px 28px;

    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.55),
        transparent
    );
}

.game-title {
    display: flex;
    align-items: center;
    gap: 13px;
}

.title-icon {
    display: grid;
    place-items: center;

    width: 44px;
    height: 44px;

    border: 1px solid var(--border);
    border-radius: 8px;

    color: var(--gold-light);
    font-size: 1.6rem;
    background: rgba(20, 19, 16, 0.65);
}

.game-title h1 {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.22em;
}

.game-title p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.6rem;
    letter-spacing: 0.18em;
}

#status-indicator {
    display: flex;
    align-items: center;
    gap: 9px;

    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: 6px;

    background: var(--panel);
    color: var(--muted);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 10px rgba(198, 165, 104, 0.4);
}

#status-indicator.ready .status-dot {
    background: var(--success);
    box-shadow: 0 0 10px rgba(139, 175, 118, 0.4);
}

#status-indicator.error .status-dot {
    background: var(--danger);
}

/* =========================================
   CROSSHAIR
========================================= */

#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;

    transform: translate(-50%, -50%);

    color: rgba(240, 233, 220, 0.75);
    font-size: 22px;
    font-weight: 300;

    opacity: 0.55;
    transition: opacity 0.2s ease;
}

#crosshair.hidden {
    opacity: 0;
}

/* =========================================
   COMBAT MESSAGES
========================================= */

#combat-message {
    position: absolute;
    top: 22%;
    left: 50%;

    transform: translate(-50%, -8px);

    max-width: 90%;
    padding: 10px 18px;

    border: 1px solid var(--border);
    border-radius: 5px;

    background: rgba(15, 14, 12, 0.82);
    color: var(--gold-light);

    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-align: center;
    text-transform: uppercase;

    opacity: 0;
    transition:
        opacity 0.2s ease,
        transform 0.2s ease;
}

#combat-message.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* =========================================
   DESKTOP CONTROL HINTS
========================================= */

#controls-hint {
    position: absolute;
    bottom: 25px;
    left: 50%;

    transform: translateX(-50%);

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;

    padding: 11px 16px;

    border: 1px solid var(--border);
    border-radius: 7px;

    background: var(--panel);
    color: var(--muted);

    font-size: 0.65rem;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

#controls-hint span {
    padding: 5px 7px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 4px;

    color: var(--text);
    font-size: 0.65rem;
    font-weight: 800;
}

/* =========================================
   MOBILE CONTROLS
========================================= */

#mobile-controls {
    display: none;

    position: absolute;
    inset: 0;

    pointer-events: none;
}

#movement-controls {
    position: absolute;
    bottom: 28px;
    left: 22px;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;

    pointer-events: auto;
}

.movement-row {
    display: flex;
    align-items: center;
    gap: 7px;
}

#mobile-controls button {
    display: grid;
    place-items: center;

    width: 48px;
    height: 48px;

    border: 1px solid rgba(229, 201, 144, 0.35);
    border-radius: 12px;

    background: rgba(20, 19, 16, 0.68);
    color: var(--gold-light);

    font-size: 1rem;
    font-weight: 800;

    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);

    touch-action: none;

    transition:
        background 0.1s ease,
        transform 0.1s ease;
}

#mobile-controls button:active,
#mobile-controls button.pressed {
    background: rgba(198, 165, 104, 0.35);
    transform: scale(0.94);
}

#action-controls {
    position: absolute;
    right: 22px;
    bottom: 35px;

    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;

    pointer-events: auto;
}

#mobile-controls #attack-button {
    width: 78px;
    height: 78px;

    border-radius: 50%;
    border-color: rgba(198, 165, 104, 0.7);

    background: rgba(117, 48, 34, 0.78);
    color: #fff0d4;

    font-size: 0.75rem;
    letter-spacing: 0.08em;
}

#mobile-controls #block-button {
    width: 62px;
    height: 62px;

    border-radius: 50%;
    font-size: 0.65rem;
    letter-spacing: 0.04em;
}

/* =========================================
   RESPONSIVE LAYOUT
========================================= */

@media (max-width: 700px) {
    .game-header {
        padding: 16px;
    }

    .title-icon {
        width: 37px;
        height: 37px;
        font-size: 1.3rem;
    }

    .game-title h1 {
        font-size: 0.85rem;
    }

    .game-title p {
        font-size: 0.52rem;
    }

    #status-indicator {
        padding: 8px 10px;
        font-size: 0.55rem;
    }

    #controls-hint {
        display: none;
    }

    #mobile-controls {
        display: block;
    }

    #combat-message {
        top: 18%;
        font-size: 0.72rem;
    }
}

@media (max-width: 380px) {
    #movement-controls {
        left: 12px;
        bottom: 20px;
    }

    #movement-controls button {
        width: 42px;
        height: 42px;
    }

    #action-controls {
        right: 12px;
        bottom: 25px;
    }

    #mobile-controls #attack-button {
        width: 68px;
        height: 68px;
    }

    #mobile-controls #block-button {
        width: 54px;
        height: 54px;
    }
}

/* Respect reduced-motion preferences. */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}