/* ============================================================
   OGARZ — underground arcade × bioluminescent ink
   Display: Bungee · Body/UI: JetBrains Mono
   ============================================================ */

:root {
    --bg:        #0a0a0d;
    --bg-2:      #14141a;
    --bg-3:      #1c1c25;
    --ink:       #f0eee6;
    --ink-dim:   #8a8a92;
    --ink-soft:  #c5c4bd;
    --accent:    #c7ff35;
    --accent-2:  #ff3e5c;
    --accent-3:  #5ce0ff;
    --line:      rgba(240, 238, 230, 0.10);
    --line-2:    rgba(240, 238, 230, 0.18);
    --shadow:    0 30px 80px -20px rgba(0,0,0,0.7);
}

* { box-sizing: border-box; }

html, body {
    padding: 0;
    margin: 0;
    overflow: hidden;
    background: var(--bg);
    color: var(--ink);
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--ink); }

/* ----- canvas ----- */
#canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #14151a;
    cursor: crosshair;
}

/* ----- chat ----- */
#chat_textbox {
    position: absolute;
    z-index: 5;
    bottom: 16px;
    left: 16px;
    width: 320px;
    height: 36px;
    padding: 0 14px;
    background: rgba(10, 10, 13, 0.55);
    border: 1px solid var(--line);
    border-radius: 0;
    color: var(--ink);
    font-family: inherit;
    font-size: 12px;
    letter-spacing: 0.04em;
    outline: none;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all .25s ease;
}
#chat_textbox::placeholder { color: var(--ink-dim); text-transform: lowercase; }
#chat_textbox:focus {
    background: rgba(10, 10, 13, 0.85);
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(199, 255, 53, 0.15);
}

/* ============================================================
   OVERLAY — main menu
   ============================================================ */
#overlays {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background:
        radial-gradient(circle at 20% 30%, rgba(199, 255, 53, 0.06) 0%, transparent 45%),
        radial-gradient(circle at 80% 70%, rgba(255, 62, 92, 0.05) 0%, transparent 45%),
        var(--bg);
    overflow: hidden;
    animation: overlay-in .4s ease;
}
@keyframes overlay-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ----- background drifting cells ----- */
.bg-cells {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}
.bg-cells .cell {
    position: absolute;
    border-radius: 50%;
    filter: blur(1px);
    opacity: 0.55;
    animation: drift 28s linear infinite;
    will-change: transform;
}
.bg-cells .c1 { width: 220px; height: 220px; top: 10%;  left:  6%; background: radial-gradient(circle at 35% 30%, #c7ff35 0%, #6b8a1d 60%, transparent 70%); animation-duration: 36s; }
.bg-cells .c2 { width: 140px; height: 140px; top: 65%;  left: 12%; background: radial-gradient(circle at 35% 30%, #ff3e5c 0%, #6b1c2b 60%, transparent 70%); animation-duration: 42s; animation-delay: -8s; }
.bg-cells .c3 { width: 320px; height: 320px; top: 60%;  left: 70%; background: radial-gradient(circle at 35% 30%, #5ce0ff 0%, #1c5868 60%, transparent 70%); animation-duration: 50s; animation-delay: -16s; opacity: 0.40; }
.bg-cells .c4 { width:  90px; height:  90px; top: 18%;  left: 78%; background: radial-gradient(circle at 35% 30%, #c7ff35 0%, #4d6612 60%, transparent 70%); animation-duration: 26s; animation-delay: -4s; }
.bg-cells .c5 { width: 180px; height: 180px; top: 32%;  left: 50%; background: radial-gradient(circle at 35% 30%, #f0eee6 0%, #4a4a52 60%, transparent 70%); animation-duration: 44s; animation-delay: -22s; opacity: 0.20; }
.bg-cells .c6 { width:  60px; height:  60px; top: 80%;  left: 40%; background: radial-gradient(circle at 35% 30%, #ff3e5c 0%, #4a1622 60%, transparent 70%); animation-duration: 30s; animation-delay: -12s; }
.bg-cells .c7 { width: 110px; height: 110px; top:  4%;  left: 38%; background: radial-gradient(circle at 35% 30%, #5ce0ff 0%, #1c4858 60%, transparent 70%); animation-duration: 38s; animation-delay: -6s; opacity: 0.45; }
.bg-cells .c8 { width: 250px; height: 250px; top: 55%;  left:-4%; background: radial-gradient(circle at 35% 30%, #c7ff35 0%, #4d6612 60%, transparent 70%); animation-duration: 56s; animation-delay: -28s; opacity: 0.35; }

@keyframes drift {
    0%   { transform: translate(0, 0)        scale(1); }
    25%  { transform: translate(40px, -30px) scale(1.06); }
    50%  { transform: translate(-20px, 50px) scale(0.94); }
    75%  { transform: translate(-50px,-10px) scale(1.03); }
    100% { transform: translate(0, 0)        scale(1); }
}

/* ----- grain texture ----- */
.grain {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    opacity: 0.25;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.45 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ============================================================
   helloDialog — main menu card
   ============================================================ */
#helloDialog {
    position: relative;
    z-index: 10;
    width: min(440px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 36px 32px 28px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(180deg, rgba(28,28,37,0.92), rgba(20,20,26,0.92));
    border: 1px solid var(--line-2);
    border-radius: 0;
    box-shadow:
        var(--shadow),
        inset 0 1px 0 rgba(255,255,255,0.04);
    backdrop-filter: blur(20px) saturate(120%);
    -webkit-backdrop-filter: blur(20px) saturate(120%);
    animation: dialog-in .5s cubic-bezier(.2,.8,.2,1) both;
}
#helloDialog::before {
    content: "";
    position: absolute;
    inset: -1px;
    background: linear-gradient(135deg, transparent 60%, rgba(199,255,53,0.6) 70%, transparent 80%);
    z-index: -1;
    opacity: 0.25;
    pointer-events: none;
}
@keyframes dialog-in {
    from { opacity: 0; transform: translate(-50%, -46%) scale(0.96); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ----- brand block ----- */
.brand { margin-bottom: 28px; }
.meta-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-dim);
}
.meta-line .dot {
    width: 8px; height: 8px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 12px var(--accent);
    animation: dot-pulse 1.6s ease-in-out infinite;
}
@keyframes dot-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.5; transform: scale(0.85); }
}

.title {
    font-family: 'Bungee', system-ui, sans-serif;
    font-size: clamp(56px, 11vw, 88px);
    line-height: 0.95;
    letter-spacing: -0.02em;
    margin: 0 0 12px;
    color: var(--ink);
    padding: 0;
    user-select: none;
}
.title span {
    display: inline-block;
    transform: translateY(20px);
    opacity: 0;
    animation: letter-in .6s cubic-bezier(.2,.8,.2,1) forwards;
    animation-delay: calc(var(--i) * 60ms + 100ms);
}
.title span:nth-child(odd)  { color: var(--ink); }
.title span:nth-child(3)    { color: var(--accent); }
@keyframes letter-in {
    to { transform: translateY(0); opacity: 1; }
}

.tagline {
    font-size: 12px;
    color: var(--ink-dim);
    margin: 0;
    letter-spacing: 0.04em;
    line-height: 1.5;
    max-width: 340px;
}

/* ----- form ----- */
.play-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
}
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.field-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-dim);
}
.play-form input,
.play-form select {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    background: var(--bg);
    border: 1px solid var(--line-2);
    border-radius: 0;
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
    letter-spacing: 0.02em;
    outline: none;
    transition: all .2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}
.play-form input::placeholder { color: var(--ink-dim); }
.play-form input:focus,
.play-form select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(199, 255, 53, 0.15);
}
.play-form select {
    background-image:
        linear-gradient(45deg, transparent 50%, var(--ink-dim) 50%),
        linear-gradient(135deg, var(--ink-dim) 50%, transparent 50%);
    background-position:
        calc(100% - 18px) 50%,
        calc(100% - 13px) 50%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    padding-right: 32px;
    cursor: pointer;
}
.play-form select option {
    background: var(--bg);
    color: var(--ink);
}

/* ----- buttons ----- */
.btn-play {
    margin-top: 8px;
    height: 56px;
    width: 100%;
    padding: 0 20px;
    background: var(--accent);
    color: var(--bg);
    border: 1px solid var(--accent);
    border-radius: 0;
    font-family: 'Bungee', sans-serif;
    font-size: 18px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
    transition: all .2s ease;
    box-shadow: 4px 4px 0 var(--bg);
}
.btn-play::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.4) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform .6s ease;
}
.btn-play:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--bg);
}
.btn-play:hover::before { transform: translateX(100%); }
.btn-play:active {
    transform: translate(2px, 2px);
    box-shadow: 0 0 0 var(--bg);
}
.btn-play[disabled],
.btn-play.btn-needs-server[disabled] {
    background: var(--bg-3);
    color: var(--ink-dim);
    border-color: var(--line-2);
    cursor: not-allowed;
    box-shadow: none;
}

.btn-spectate {
    height: 40px;
    width: 100%;
    padding: 0 14px;
    background: transparent;
    color: var(--ink-soft);
    border: 1px solid var(--line-2);
    border-radius: 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all .2s ease;
}
.btn-spectate:hover {
    color: var(--bg);
    background: var(--ink);
    border-color: var(--ink);
}
.btn-spectate[disabled] { opacity: 0.4; cursor: not-allowed; }

/* btn-needs-server: dim until a server has been selected.
   The original JS strips this class on setserver(). */
.btn-needs-server {
    opacity: 0.5;
    pointer-events: none;
}

/* ----- collapsibles ----- */
.settings-collapse,
.instructions-collapse {
    margin-top: 10px;
    border-top: 1px solid var(--line);
}
.settings-collapse summary,
.instructions-collapse summary {
    list-style: none;
    cursor: pointer;
    padding: 12px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-dim);
    transition: color .2s ease;
}
.settings-collapse summary::-webkit-details-marker,
.instructions-collapse summary::-webkit-details-marker { display: none; }
.settings-collapse summary:hover,
.instructions-collapse summary:hover { color: var(--ink); }
.settings-collapse[open] summary,
.instructions-collapse[open] summary { color: var(--accent); }
.settings-collapse[open] summary svg,
.instructions-collapse[open] summary svg { transform: rotate(180deg); }
.settings-collapse summary svg,
.instructions-collapse summary svg { transition: transform .2s ease; }

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 14px;
    padding-bottom: 10px;
}
.settings-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--ink-soft);
    cursor: pointer;
    user-select: none;
    transition: color .15s ease;
}
.settings-grid label:hover { color: var(--ink); }
.settings-grid input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border: 1px solid var(--line-2);
    background: transparent;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all .15s ease;
}
.settings-grid input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}
.settings-grid input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    top: 1px; left: 4px;
    width: 4px; height: 8px;
    border: solid var(--bg);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.ctl-list {
    list-style: none;
    padding: 0 0 10px;
    margin: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}
.ctl-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: var(--ink-soft);
}
.ctl-list kbd {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 500;
    padding: 3px 7px;
    background: var(--bg);
    border: 1px solid var(--line-2);
    color: var(--ink);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    min-width: 64px;
    text-align: center;
}

/* ----- footer ----- */
.meta {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-dim);
}
.meta .sep { opacity: 0.4; }
.meta a { color: var(--ink-soft); }
.meta a:hover { color: var(--accent); }

/* ============================================================
   connecting state
   ============================================================ */
#connecting {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(10, 10, 13, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.connecting-card {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: min(360px, calc(100vw - 32px));
    padding: 28px 24px;
    background: var(--bg-2);
    border: 1px solid var(--line-2);
    text-align: center;
}
.connecting-card h2 {
    font-family: 'Bungee', sans-serif;
    font-size: 22px;
    margin: 16px 0 8px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.connecting-card p {
    font-size: 11px;
    color: var(--ink-dim);
    line-height: 1.7;
    margin: 0;
}
.connecting-pulse {
    width: 28px; height: 28px;
    margin: 0 auto;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 0 var(--accent);
    animation: pulse 1.4s ease-out infinite;
}
@keyframes pulse {
    0%   { transform: scale(0.8); opacity: 1; box-shadow: 0 0 0 0 rgba(199,255,53,0.5); }
    70%  { transform: scale(1.1); opacity: 0.7; box-shadow: 0 0 0 16px rgba(199,255,53,0); }
    100% { transform: scale(0.8); opacity: 1; box-shadow: 0 0 0 0 rgba(199,255,53,0); }
}

/* ============================================================
   responsive
   ============================================================ */
@media (max-width: 540px) {
    #helloDialog { padding: 28px 22px 22px; }
    .title { font-size: 64px; }
    .settings-grid { grid-template-columns: 1fr; }
    .bg-cells .c1 { width: 160px; height: 160px; }
    .bg-cells .c3 { width: 220px; height: 220px; }
    .bg-cells .c8 { width: 180px; height: 180px; }
    #chat_textbox { width: calc(100vw - 32px); }
}

/* ============================================================
   reduce-motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* legacy modal stub (skin gallery is disabled on the server) */
#inPageModal, .modal { display: none !important; }
