:root {
    --bg-deep: #06131f;
    --bg-mid: #0c2434;
    --panel: rgba(7, 24, 36, 0.82);
    --panel-border: rgba(148, 208, 255, 0.18);
    --text-main: #f5fbff;
    --text-dim: rgba(225, 242, 255, 0.72);
    --accent: #33d17a;
    --accent-strong: #1fa561;
    --accent-alt: #56b4ff;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

* {
    box-sizing: border-box;
    font-family: "Segoe UI", "Trebuchet MS", sans-serif;
}

html,
body {
    width: 100%;
    height: 100%;
    /* Robust fix for Telegram Mini App and mobile browsers */
    height: 100dvh;
    min-height: -webkit-fill-available;
    margin: 0;
    padding: 0;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    touch-action: none;
    background:
        radial-gradient(circle at top, rgba(64, 182, 255, 0.16), transparent 35%),
        radial-gradient(circle at 20% 20%, rgba(51, 209, 122, 0.14), transparent 25%),
        linear-gradient(180deg, var(--bg-mid) 0%, var(--bg-deep) 100%);
}

body {
    color: var(--text-main);
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
}

div {
    -webkit-user-select: none;
    -moz-user-select: none;
    -khtml-user-select: none;
    -ms-user-select: none;
}

#split,
#feed {
    position: absolute;
    bottom: 16px;
    width: 86px;
    height: 86px;
    padding: 10px;
    border: 0;
    border-radius: 999px;
    background: rgba(8, 30, 44, 0.74);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.26);
}

#split {
    left: 16px;
}

#feed {
    right: 16px;
}

#status {
    position: absolute;
    top: 16px;
    right: 16px;
    min-width: 210px;
    padding: 14px 16px;
    color: var(--text-main);
    text-align: left;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.55;
    background: rgba(4, 20, 30, 0.74);
    border: 1px solid rgba(125, 194, 255, 0.18);
    border-radius: 18px;
    backdrop-filter: blur(14px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
}

#status .title {
    display: block;
    margin-bottom: 8px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

#status .me {
    color: #8df1b5;
}

#startMenuWrapper {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    height: 100dvh;
    padding: 24px;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

#startMenu {
    width: min(100%, 520px);
    padding: 28px;
    border: 1px solid var(--panel-border);
    border-radius: 30px;
    background:
        linear-gradient(180deg, rgba(14, 38, 54, 0.94) 0%, rgba(5, 19, 29, 0.92) 100%);
    box-shadow: var(--shadow);
}

.hero-copy {
    margin-bottom: 20px;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 10px;
    padding: 6px 10px;
    border-radius: 999px;
    color: #a7def8;
    background: rgba(86, 180, 255, 0.15);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

#startMenu p {
    margin: 0;
    font-size: 44px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.04em;
}

.subtitle {
    display: block;
    margin-top: 12px;
    color: var(--text-dim);
    font-size: 16px;
    line-height: 1.5;
}

#playerNameInput {
    width: 100%;
    margin-bottom: 10px;
    padding: 15px 16px;
    color: var(--text-main);
    text-align: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

#playerNameInput:focus,
#playerNameInput.focus {
    border-color: rgba(86, 180, 255, 0.46);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 4px rgba(86, 180, 255, 0.12);
}

.input-error {
    display: block;
    min-height: 18px;
    margin-bottom: 8px;
    color: #ff8c8c;
    opacity: 0;
    font-size: 12px;
}

.menu-actions {
    display: grid;
    gap: 10px;
}

#startButton,
#spectateButton,
#settingsButton {
    width: 100%;
    min-height: 48px;
    border: 0;
    border-radius: 16px;
    color: var(--text-main);
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease;
}

#startButton {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    box-shadow: 0 16px 35px rgba(31, 165, 97, 0.28);
}

#spectateButton {
    background: linear-gradient(135deg, #2d8fd8 0%, var(--accent-alt) 100%);
    box-shadow: 0 16px 35px rgba(45, 143, 216, 0.24);
}

#settingsButton {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

#startButton:hover,
#spectateButton:hover,
#settingsButton:hover,
#startButton:focus,
#spectateButton:focus,
#settingsButton:focus {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.panel {
    margin-top: 18px;
    padding: 18px 18px 10px;
    border-radius: 20px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
}

#settings {
    max-height: 0;
    margin-top: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, margin-top 0.35s ease, padding 0.35s ease, border-width 0.35s ease;
}

#settings.open {
    max-height: 300px;
    margin-top: 18px;
    padding-top: 18px;
    padding-bottom: 10px;
    border-width: 1px;
}

#startMenu h3 {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #8fccf2;
}

#startMenu ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

#settings label,
#instructions li {
    display: block;
    color: var(--text-dim);
    line-height: 1.55;
    margin: 0 0 10px;
}

#settings input {
    margin-right: 8px;
}

#gameAreaWrapper {
    position: absolute !important;
    inset: 0;
    opacity: 0;
}

@media only screen and (min-width: 1225px) {
    #mobile {
        display: none;
    }
}

@media only screen and (max-width: 1224px) {
    #status {
        min-width: 180px;
        font-size: 14px;
    }
}

@media only screen and (max-width: 640px) {
    #startMenuWrapper {
        padding: 14px;
    }

    #startMenu {
        padding: 20px;
        border-radius: 24px;
    }

    #startMenu p {
        font-size: 34px;
    }

    .subtitle {
        font-size: 14px;
    }

    #split,
    #feed {
        width: 72px;
        height: 72px;
    }
}

input[type="image"]:focus,
*:focus {
    outline: 1px solid transparent;
    border-style: none;
}
