/* Fonts */
@font-face {
    font-family: 'Orbitron';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/orbitron.woff') format('woff');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Anta';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/anta-math.woff2') format('woff2');
    unicode-range: U+0302-0303, U+0305, U+0307-0308, U+0310, U+0312, U+0315, U+031A, U+0326-0327, U+032C, U+032F-0330, U+0332-0333, U+0338, U+033A, U+0346, U+034D, U+0391-03A1, U+03A3-03A9, U+03B1-03C9, U+03D1, U+03D5-03D6, U+03F0-03F1, U+03F4-03F5, U+2016-2017, U+2034-2038, U+203C, U+2040, U+2043, U+2047, U+2050, U+2057, U+205F, U+2070-2071, U+2074-208E, U+2090-209C, U+20D0-20DC, U+20E1, U+20E5-20EF, U+2100-2112, U+2114-2115, U+2117-2121, U+2123-214F, U+2190, U+2192, U+2194-21AE, U+21B0-21E5, U+21F1-21F2, U+21F4-2211, U+2213-2214, U+2216-22FF, U+2308-230B, U+2310, U+2319, U+231C-2321, U+2336-237A, U+237C, U+2395, U+239B-23B7, U+23D0, U+23DC-23E1, U+2474-2475, U+25AF, U+25B3, U+25B7, U+25BD, U+25C1, U+25CA, U+25CC, U+25FB, U+266D-266F, U+27C0-27FF, U+2900-2AFF, U+2B0E-2B11, U+2B30-2B4C, U+2BFE, U+3030, U+FF5B, U+FF5D, U+1D400-1D7FF, U+1EE00-1EEFF;
}

@font-face {
    font-family: 'Anta';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/anta-symbols.woff2') format('woff2');
    unicode-range: U+0001-000C, U+000E-001F, U+007F-009F, U+20DD-20E0, U+20E2-20E4, U+2150-218F, U+2190, U+2192, U+2194-2199, U+21AF, U+21E6-21F0, U+21F3, U+2218-2219, U+2299, U+22C4-22C6, U+2300-243F, U+2440-244A, U+2460-24FF, U+25A0-27BF, U+2800-28FF, U+2921-2922, U+2981, U+29BF, U+29EB, U+2B00-2BFF, U+4DC0-4DFF, U+FFF9-FFFB, U+10140-1018E, U+10190-1019C, U+101A0, U+101D0-101FD, U+102E0-102FB, U+10E60-10E7E, U+1D2C0-1D2D3, U+1D2E0-1D37F, U+1F000-1F0FF, U+1F100-1F1AD, U+1F1E6-1F1FF, U+1F30D-1F30F, U+1F315, U+1F31C, U+1F31E, U+1F320-1F32C, U+1F336, U+1F378, U+1F37D, U+1F382, U+1F393-1F39F, U+1F3A7-1F3A8, U+1F3AC-1F3AF, U+1F3C2, U+1F3C4-1F3C6, U+1F3CA-1F3CE, U+1F3D4-1F3E0, U+1F3ED, U+1F3F1-1F3F3, U+1F3F5-1F3F7, U+1F408, U+1F415, U+1F41F, U+1F426, U+1F43F, U+1F441-1F442, U+1F444, U+1F446-1F449, U+1F44C-1F44E, U+1F453, U+1F46A, U+1F47D, U+1F4A3, U+1F4B0, U+1F4B3, U+1F4B9, U+1F4BB, U+1F4BF, U+1F4C8-1F4CB, U+1F4D6, U+1F4DA, U+1F4DF, U+1F4E3-1F4E6, U+1F4EA-1F4ED, U+1F4F7, U+1F4F9-1F4FB, U+1F4FD-1F4FE, U+1F503, U+1F507-1F50B, U+1F50D, U+1F512-1F513, U+1F53E-1F54A, U+1F54F-1F5FA, U+1F610, U+1F650-1F67F, U+1F687, U+1F68D, U+1F691, U+1F694, U+1F698, U+1F6AD, U+1F6B2, U+1F6B9-1F6BA, U+1F6BC, U+1F6C6-1F6CF, U+1F6D3-1F6D7, U+1F6E0-1F6EA, U+1F6F0-1F6F3, U+1F6F7-1F6FC, U+1F700-1F7FF, U+1F800-1F80B, U+1F810-1F847, U+1F850-1F859, U+1F860-1F887, U+1F890-1F8AD, U+1F8B0-1F8BB, U+1F8C0-1F8C1, U+1F900-1F90B, U+1F93B, U+1F946, U+1F984, U+1F996, U+1F9E9, U+1FA00-1FA6F, U+1FA70-1FA7C, U+1FA80-1FA89, U+1FA8F-1FAC6, U+1FACE-1FADC, U+1FADF-1FAE9, U+1FAF0-1FAF8, U+1FB00-1FBFF;
}

@font-face {
    font-family: 'Anta';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/anta-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Anta';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/anta-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Base element styling */
* {
    touch-action: manipulation;
}

html,
body {
    margin: 0;
    padding: 0;
    background: #000;
    color: #fff;
    font-family: sans-serif;
    font-size: 16px;
}

a {
    color: #66ccff;
    text-decoration: none;
}

strong {
    font-family: 'Anta', system-ui;
}

/* Layout */
#pageContainer {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    gap: 1.875em;
}

#leftColumn {
    flex: 1;
    box-sizing: border-box;
    padding: 0.625em;
    max-width: calc(100% - 20.625em);
    margin: 0 auto;
    transition: max-width 0.3s ease, margin 0.3s ease;
}

#gameTitle {
    text-align: center;
    font-size: 4em;
    margin: 0.5em 0 0 0;
    font-family: 'Orbitron', system-ui;
}

#gameSubTitle {
    text-align: center;
    font-size: 1em;
    margin: 0 0 1em 0;
    font-family: 'Anta', system-ui;
}

/* Canvas and game elements */
.canvasContainer {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    background: #000;
    box-sizing: border-box;
    transition: max-width 0.3s ease;
}

#gameCanvas {
    width: 100%;
    background: #111;
    border: 1px solid #444;
    height: auto;
    display: block;
    -webkit-user-select: none;
    user-select: none;
}

#instructions {
    max-width: 800px;
    margin: 10px auto;
    line-height: 1.4;
}

/* Sidebar */
#sidebarContainer {
    position: relative;
    width: 18.75em;
    box-sizing: border-box;
    padding: 0.625em;
    flex-shrink: 0;
    transition: width 0.3s ease, margin 0.3s ease;
}

#sidebarContainer.closed {
    margin-right: 2.5em;
}

#toggleSidebar {
    position: absolute;
    top: 0.625em;
    width: 2.5em;
    height: 2.5em;
    background: #444;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: left 0.3s ease;
}

#sidePanel {
    background: #222;
    height: 98vh;
    overflow-y: auto;
    box-sizing: border-box;
    padding: 10px;
    display: flex;
    flex-direction: column;
}

#sidePanel h2 {
    font-family: 'Anta', system-ui;
    margin: 0 0 1em 0;
    text-align: center;
    font-size: 1.5em;
    padding-bottom: 0.5em;
    border-bottom: 1px solid #444;
    position: sticky;
    top: 0;
    background: #222;
    z-index: 1;
    margin-bottom: 0.5em;
}

#sidePanel .articleList {
    overflow-y: auto;
    flex: 1;
    padding-top: 0.5em;
}

/* Article snippets */
.articleSnippet {
    background: #333;
    border-radius: 0.3125em;
    margin-bottom: 0.625em;
    padding: 0.625em;
    animation: 1s linear fadein;
}

.articleSnippet strong {
    font-family: 'Anta', system-ui;
    font-size: 1.1em;
}

.articleSnippet div:not(.extraInfo) {
    font-size: 0.9em;
    margin-top: 0.3em;
    line-height: 1.4;
}

.articleSnippet a {
    color: #66ccff;
    text-decoration: none;
    font-family: 'Anta', system-ui;
}

.articleSnippet .extraInfo {
    font-size: 0.75em;
    color: #ccc;
    margin-top: 0.3125em;
}

.articleSnippet img {
    max-width: 100%;
    max-height: 150px;
    height: auto;
    width: 100%;
    display: block;
    margin: 0.3125em 0;
    border-radius: 0.1875em;
    object-fit: cover;
}

.articleSnippet--new {
    background-color: #445566;
}

.tag {
    margin-left: 6px;
    position: relative;
    top: -3px;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 10px;
    display: inline-block;
    color: #fff;
}

.tag--lang {
    background: #666;
}

.tag--new {
    background: #6699cc;
}

/* Game settings controls */
.gameButton {
    position: absolute;
    padding: 8px;
    background: #444;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.gameButton:hover {
    background: #555;
}

#fullscreenButton {
    top: 10px;
    right: 10px;
}

#muteButton {
    top: 10px;
}

#muteButton svg {
    display: block;
}

#toggleControlsButton {
    top: 10px;
    right: 90px;
}

/* Mobile controls */
#mobileControls {
    position: fixed;
    bottom: env(safe-area-inset-bottom, 0);
    left: 0;
    padding: 0 10px;
    z-index: 2000;
    pointer-events: none;
    width: 100%;
    box-sizing: border-box;
}

#mobileControls button {
    width: min(45px, 11vw);
    height: min(45px, 11vw);
    font-size: min(20px, 5vw);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    background: #333;
    color: #fff;
    border: 1px solid #666;
    margin: 0.3125em;
    border-radius: 0.3125em;
    transition: opacity 0.1s, transform 0.1s;
    cursor: pointer;
}

#mobileControls button:active {
    opacity: 0.7;
}

#mobileControls button.pressed {
    opacity: 0.7;
    transform: scale(0.95);
}

.controlRow {
    display: flex;
    justify-content: center;
    margin: 5px 0;
}

.horizontalButtons {
    display: flex;
    gap: 2em;
}

.mobileLeft {
    position: absolute;
    bottom: 0.5em;
    left: 0.5em;
    width: min-content;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px;
    border-radius: 12px;
    pointer-events: auto;
}

.mobileRight {
    position: absolute;
    bottom: 0.5em;
    right: 0.5em;
    width: min-content;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: auto;
}

.mobilePause {
    display: none;
}

#btnUp,
#btnLeft,
#btnRight {
    width: min(50px, 12vw);
    height: min(50px, 12vw);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: min(24px, 6vw);
}

#btnLeft {
    content: "◀";
}

#btnRight {
    content: "▶";
}

#btnUp {
    content: "▲";
}

/* On-screen shoot button */
#btnShoot {
    width: min(50px, 12vw) !important;
    height: min(50px, 12vw) !important;
    background: rgba(255, 50, 50, 0.7) !important;
    border-radius: 50% !important;
    padding: 0 !important;
    aspect-ratio: 1 / 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: min(50px, 12vw) !important;
    min-height: min(50px, 12vw) !important;
}

#btnShoot svg {
    width: 60%;
    height: 60%;
}

/* On-screen pause button */
#btnPause {
    width: min(40px, 10vw) !important;
    height: min(40px, 10vw) !important;
    min-width: min(40px, 10vw) !important;
    min-height: min(40px, 10vw) !important;
    aspect-ratio: 1 / 1 !important;
    padding: 0 !important;
    font-family: 'Anta', system-ui;
    font-size: min(16px, 4vw) !important;
    background: rgba(51, 51, 51, 0.9) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 auto !important;
}

/* Language selector */
#languageSelector {
    margin: 2em auto;
    padding: 1em;
    background: #222;
    border-radius: 0.5em;
}

.languageSelector-title {
    font-family: 'Anta', system-ui;
    text-align: center;
    margin: 1em 0;
}

.languageSelector-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1em;
    display: flex;
    flex-wrap: wrap;
    gap: 1em;
    justify-content: center;
}

.wikiToggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    padding: 0.5em 1em;
    background: #333;
    border-radius: 0.3em;
    cursor: pointer;
    transition: background-color 0.2s;
}

.wikiToggle:hover {
    background: #444;
}

.wikiToggle input {
    margin: 0;
}

.articleCount {
    font-size: 0.8em;
    padding: 0.2em 0.5em;
    background: #555;
    border-radius: 1em;
    min-width: 1.5em;
    text-align: center;
    display: inline-block;
}

.wikiToggle.active .articleCount {
    display: inline-block;
}

/* Fullscreen */
.canvasContainer.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-width: none;
    z-index: 90;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    box-sizing: border-box;
}

.canvasContainer.fullscreen canvas {
    max-height: 85vh;
    max-width: min(calc(85vh * 4/3), 85vw);
    width: auto;
    height: auto;
    margin: auto;
    object-fit: contain;
}

/* Animations */
@keyframes fadein {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media (max-width: 900px) {
    #pageContainer {
        flex-direction: column;
        gap: 0.625em;
        margin-bottom: 100px;
    }

    #leftColumn {
        max-width: 100%;
    }

    #sidebarContainer {
        width: 100%;
        margin-top: 0.625em;
    }

    #toggleSidebar {
        display: none;
    }

    #languageSelector {
        margin-bottom: 100px;
    }

    .canvasContainer.fullscreen~#mobileControls {
        display: block !important;
    }
}

@media (max-width: 900px) {
    #gameTitle {
        font-size: min(3em, 12vw);
    }
}

@media (max-width: 300px) {
    #gameTitle {
        font-size: min(2em, 6vw);
    }
}

@supports (-webkit-touch-callout: none) {
    .canvasContainer.fullscreen {
        height: 100%;
    }
}