/* Gothic custom font */
@font-face {
    font-family: 'WhoAsksSatan';
    src: url('./assets/who asks satan.ttf') format('truetype');
    font-display: swap
}

html,
body {
    margin: 0;
    height: 100%;
    background: #000;
    overflow: hidden;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none
}

[hidden] {
    display: none !important
}


.tv-frame {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  /* Inset shadow creates the "border" effect without adding width to the element */
  box-shadow: inset 0 0 150px 50px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  /* Essential so you can still click buttons underneath */
  z-index: 999;
}

.tv-static {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('./assets/backcable2.gif');
  opacity: 12%;
  /* 100% - 89% = 11% visible grain for a subtle look */
  pointer-events: none;
  z-index: 998;
  mix-blend-mode: screen;
  /* Blends the static naturally with your site content */
}

/* Three.js menu background canvas — sits behind everything */
#menu-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    display: block;
    opacity: .2;
    filter: saturate(.7) contrast(1.15)
}

canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block
}

#hud {
    position: fixed;
    left: 14px;
    bottom: 12px;
    right: 14px;
    display: flex;
    justify-content: space-between;
    font: 12px/1.3 ui-monospace, Menlo, Consolas, monospace;
    color: #efe9b0;
    opacity: .72;
    text-shadow: 0 0 6px #000, 0 0 2px #000;
    pointer-events: none;
    letter-spacing: .09em;
    text-transform: uppercase
}

#hud b {
    color: #ff5a4a;
    font-weight: normal;
    animation: bl 1.4s steps(2) infinite
}

#fl-status {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    left: 12px;
    z-index: 19;
    padding: 7px 9px;
    border: 1px solid rgba(255, 210, 150, .3);
    border-radius: 8px;
    background: rgba(10, 9, 4, .68);
    color: #f1c98c;
    font: 10px ui-monospace, Menlo, Consolas, monospace;
    letter-spacing: .08em;
    text-shadow: 0 0 5px #000;
    pointer-events: none;
    display: none
}

#fl-status.on {
    display: block
}

#online {
    position: fixed;
    top: calc(max(12px, env(safe-area-inset-top)) + 44px);
    left: 12px;
    z-index: 18;
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-width: min(190px, 55vw);
    pointer-events: none
}

#net-tags {
    position: fixed;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    overflow: hidden
}

#mic-toggle {
    position: fixed;
    top: calc(max(12px, env(safe-area-inset-top)) + 104px);
    right: 12px;
    z-index: 20;
    padding: 9px 10px;
    border: 1px solid rgba(255, 250, 200, .35);
    border-radius: 9px;
    background: rgba(10, 9, 4, .72);
    color: #efe9b0;
    font: 10px ui-monospace, Menlo, Consolas, monospace;
    letter-spacing: .1em;
    cursor: pointer
}

#mic-toggle[hidden] {
    display: none
}

#mic-status {
    position: fixed;
    top: calc(max(12px, env(safe-area-inset-top)) + 143px);
    right: 12px;
    z-index: 19;
    color: rgba(239, 233, 176, .72);
    font: 9px ui-monospace, Menlo, Consolas, monospace;
    letter-spacing: .06em;
    text-shadow: 0 1px 4px #000;
    pointer-events: none
}

#mic-status:empty {
    display: none
}

#mic-toggle.on {
    border-color: rgba(255, 110, 80, .72);
    background: rgba(88, 22, 14, .78);
    color: #ffd1b7;
    box-shadow: 0 0 12px rgba(255, 75, 45, .2)
}

#mic-toggle:disabled {
    opacity: .55;
    cursor: wait
}

#chat-toggle {
    position: fixed;
    right: 14px;
    bottom: 34px;
    z-index: 25;
    padding: 9px 12px;
    border: 1px solid rgba(255, 250, 200, .35);
    border-radius: 9px;
    background: rgba(10, 9, 4, .78);
    color: #efe9b0;
    font: 10px ui-monospace, Menlo, Consolas, monospace;
    letter-spacing: .12em;
    cursor: pointer
}

#hit-btn {
    position: fixed;
    right: 18px;
    bottom: max(88px, calc(env(safe-area-inset-bottom) + 76px));
    z-index: 24;
    width: 68px;
    height: 68px;
    border: 1px solid rgba(255, 190, 155, .55);
    border-radius: 50%;
    background: radial-gradient(circle at 38% 30%, rgba(120, 50, 35, .88), rgba(24, 12, 10, .9));
    box-shadow: 0 4px 18px rgba(0, 0, 0, .45), inset 0 0 16px rgba(255, 120, 80, .12);
    color: #ffe4c8;
    font: 11px ui-monospace, Menlo, Consolas, monospace;
    font-weight: bold;
    letter-spacing: .13em;
    cursor: pointer;
    touch-action: none;
    -webkit-tap-highlight-color: transparent
}

#hit-btn:active {
    transform: scale(.94);
    background: radial-gradient(circle at 38% 30%, rgba(170, 66, 43, .95), rgba(40, 15, 12, .94));
    box-shadow: 0 1px 8px rgba(0, 0, 0, .5), inset 0 0 18px rgba(255, 120, 80, .28)
}

#hit-btn[hidden] {
    display: none
}

#chat-toggle[hidden],
#chat-panel[hidden] {
    display: none
}

#chat-panel {
    position: fixed;
    right: 14px;
    bottom: 78px;
    z-index: 26;
    width: min(330px, calc(100vw - 28px));
    height: min(360px, calc(100vh - 130px));
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 250, 200, .28);
    border-radius: 11px;
    background: rgba(9, 8, 5, .95);
    color: #efe9b0;
    box-shadow: 0 14px 45px rgba(0, 0, 0, .55);
    font: 11px ui-monospace, Menlo, Consolas, monospace;
    letter-spacing: .04em
}

#chat-panel header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 11px;
    border-bottom: 1px solid rgba(255, 250, 200, .14);
    letter-spacing: .12em
}

#chat-status {
    margin-left: auto;
    color: rgba(239, 233, 176, .5);
    font-size: 9px;
    letter-spacing: .06em
}

#chat-close {
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #efe9b0;
    font-size: 19px;
    cursor: pointer
}

#chat-messages {
    flex: 1;
    overflow: auto;
    padding: 8px;
    overscroll-behavior: contain
}

.chat-line {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    padding: 6px 2px;
    border-bottom: 1px solid rgba(255, 250, 200, .07);
    line-height: 1.4;
    overflow-wrap: anywhere
}

.chat-avatar {
    width: 20px;
    height: 20px;
    flex: none;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(255, 250, 200, .12)
}

.chat-copy {
    min-width: 0
}

.chat-user {
    display: block;
    margin-bottom: 2px;
    color: #d7c88e;
    font-size: 9px;
    text-decoration: none
}

.chat-text {
    color: #f4f0dc;
    letter-spacing: 0
}

#chat-form {
    display: flex;
    gap: 6px;
    padding: 8px;
    border-top: 1px solid rgba(255, 250, 200, .14)
}

#chat-input {
    flex: 1;
    min-width: 0;
    padding: 9px;
    border: 1px solid rgba(255, 250, 200, .2);
    border-radius: 7px;
    background: rgba(255, 250, 200, .06);
    color: #fff7db;
    font: 11px ui-monospace, Menlo, Consolas, monospace;
    letter-spacing: 0;
    outline: none
}

#chat-form button,
#mode-choice button {
    padding: 9px 11px;
    border: 1px solid rgba(209,201,184,.28);
    border-radius: 7px;
    background: rgba(209,201,184,.06);
    color: #d1c9b8;
    font: 10px ui-monospace, Menlo, Consolas, monospace;
    letter-spacing: .1em;
    cursor: pointer
}

#chat-form button:disabled,
#mode-choice button:disabled {
    opacity: .45;
    cursor: wait
}

#mode-choice {
    display: flex;
    gap: 10px;
    margin-top: 24px
}

#mode-choice[hidden] {
    display: none
}

#mode-choice button {
    padding: 13px 16px;
    background: rgba(209,201,184,.05)
}

#mode-choice button:hover {
    background: rgba(209,201,184,.14);
    border-color: rgba(209,201,184,.5)
}

#death-panel {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 24;
    width: min(360px, calc(100vw - 32px));
    max-height: 70vh;
    overflow: auto;
    padding: 15px;
    border: 1px solid rgba(255, 230, 170, .3);
    border-radius: 12px;
    background: rgba(9, 8, 5, .94);
    color: #efe9b0;
    box-shadow: 0 18px 60px rgba(0, 0, 0, .65);
    font: 11px ui-monospace, Menlo, Consolas, monospace;
    letter-spacing: .08em
}

#death-panel[hidden] {
    display: none
}

.death-title {
    margin: 1px 0 12px;
    color: #ffb8a0;
    font-size: 12px;
    letter-spacing: .16em
}

.death-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 7px;
    padding: 7px 0;
    border-top: 1px solid rgba(255, 250, 200, .12)
}

.death-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

.death-row button {
    padding: 7px 9px;
    border: 1px solid rgba(255, 250, 200, .25);
    border-radius: 7px;
    background: rgba(255, 250, 200, .08);
    color: #efe9b0;
    font: inherit;
    letter-spacing: .05em;
    cursor: pointer
}

.death-row button:disabled {
    opacity: .35;
    cursor: default
}

.death-empty {
    padding: 8px 0;
    color: rgba(239, 233, 176, .62)
}

.net-tag {
    position: absolute;
    transform: translate(-50%, -100%);
    padding: 4px 7px;
    border: 1px solid rgba(255, 235, 175, .35);
    border-radius: 6px;
    background: rgba(10, 9, 4, .72);
    color: #fff0c0;
    font: 10px ui-monospace, Menlo, Consolas, monospace;
    letter-spacing: .04em;
    text-shadow: 0 1px 4px #000;
    white-space: nowrap;
    pointer-events: auto;
    cursor: pointer
}

.net-tag:hover,
.net-tag:focus-visible {
    outline: 1px solid #fff0c0;
    background: rgba(70, 58, 27, .9)
}

.online-player.can-teleport {
    pointer-events: auto;
    cursor: pointer
}

.online-player.can-teleport:hover,
.online-player.can-teleport:focus-visible {
    outline: 1px solid rgba(255, 240, 176, .65);
    background: rgba(90, 74, 34, .8)
}

.online-player {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 8px;
    border: 1px solid rgba(255, 250, 200, .2);
    border-radius: 8px;
    background: rgba(10, 9, 4, .65);
    color: #efe9b0;
    font: 10px ui-monospace, Menlo, Consolas, monospace;
    letter-spacing: .04em;
    text-shadow: 0 0 4px #000
}

.online-player img,
.online-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(255, 250, 200, .15);
    display: grid;
    place-items: center;
    font-size: 9px
}

@keyframes bl {
    50% {
        opacity: 0
    }
}

#load {
    position: fixed;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(5, 4, 2, .88), rgba(5, 4, 2, .52) 48%, rgba(5, 4, 2, .86)),
        linear-gradient(0deg, rgba(4, 3, 2, .82), transparent 42%, rgba(4, 3, 2, .42)),
        url('./assets/background.gif') center / cover no-repeat;
    color: #d1c9b8;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    flex-direction: column;
    font: 14px ui-monospace, Menlo, Consolas, monospace;
    letter-spacing: .14em;
    transition: opacity 1.6s;
    text-align: left;
    padding: clamp(56px, 10vh, 104px) clamp(24px, 7vw, 96px);
    z-index: 50
}

#load small {
    opacity: .55;
    margin-top: 10px;
    letter-spacing: .06em
}

#stk {
    position: fixed;
    width: 112px;
    height: 112px;
    border: 2px solid rgba(255, 252, 220, .32);
    border-radius: 50%;
    display: none;
    pointer-events: none;
    background: rgba(255, 250, 200, .05)
}

#knob {
    position: absolute;
    left: 32px;
    top: 32px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 250, 210, .3)
}

#load.ready {
    cursor: pointer
}

#load b {
    font-weight: normal;
    font-size: 28px;
    letter-spacing: .3em;
    color: #d1c9b8;
    font-family: 'WhoAsksSatan', serif;
    text-shadow: 0 0 18px rgba(0,0,0,.9), 0 2px 6px rgba(0,0,0,.7)
}

#boot {
    position: fixed;
    left: 50%;
    bottom: 0;
    width: 190px;
    margin-left: -95px;
    z-index: 6;
    pointer-events: none;
    display: none;
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .7))
}

#fs {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
    z-index: 20;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid rgba(255, 250, 200, .35);
    background: rgba(10, 9, 4, .45);
    color: #efe9b0;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent
}

#biome-toggle {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    right: 62px;
    z-index: 20;
    height: 42px;
    padding: 0 11px;
    border-radius: 10px;
    border: 1px solid rgba(255, 250, 200, .35);
    background: rgba(10, 9, 4, .45);
    color: #efe9b0;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font: 10px ui-monospace, Menlo, Consolas, monospace;
    letter-spacing: .1em;
    -webkit-tap-highlight-color: transparent
}

#biome-panel {
    position: fixed;
    top: calc(max(12px, env(safe-area-inset-top)) + 50px);
    right: 62px;
    z-index: 22;
    width: min(280px, calc(100vw - 24px));
    max-height: min(68vh, 520px);
    overflow: hidden;
    border: 1px solid rgba(255, 250, 200, .3);
    border-radius: 12px;
    background: rgba(10, 9, 4, .94);
    color: #efe9b0;
    box-shadow: 0 12px 36px rgba(0, 0, 0, .5);
    font: 11px ui-monospace, Menlo, Consolas, monospace;
    letter-spacing: .08em
}

#biome-panel[hidden] {
    display: none
}

.biome-head {
    padding: 12px 14px 9px;
    color: rgba(239, 233, 176, .55);
    border-bottom: 1px solid rgba(255, 250, 200, .13);
    font-size: 10px
}

#biome-list {
    max-height: min(55vh, 420px);
    overflow: auto;
    padding: 5px;
    overscroll-behavior: contain
}

#biome-list button {
    display: block;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #efe9b0;
    text-align: left;
    font: inherit;
    letter-spacing: .04em;
    cursor: pointer
}

#biome-list button:hover,
#biome-list button:focus-visible {
    outline: none;
    background: rgba(255, 250, 200, .12)
}

#biome-list button.active {
    color: #fff4b0;
    background: rgba(255, 240, 170, .16)
}

#biome-status {
    min-height: 14px;
    padding: 0 14px 10px;
    color: rgba(239, 233, 176, .55);
    font-size: 9px
}

#fs svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round
}

#fb {
    position: fixed;
    top: calc(max(12px, env(safe-area-inset-top)) + 52px);
    right: 12px;
    z-index: 20;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid rgba(255, 250, 200, .35);
    background: rgba(10, 9, 4, .45);
    color: #efe9b0;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent
}

#fb.on {
    background: rgba(255, 240, 170, .35);
    box-shadow: 0 0 12px rgba(255, 235, 160, .5)
}

#fb:disabled {
    opacity: .4;
    cursor: not-allowed
}

#fb svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round
}

/* =====================================================================
   Gothic menu — auth, room management, menu title
   ===================================================================== */

#load-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    width: min(390px, 100%);
    padding: 0;
    box-sizing: border-box;
    border: 0;
    background: transparent
}

#menu-brand {
    margin-bottom: clamp(28px, 6vh, 58px);
    color: #d1c9b8;
    font: clamp(2.2rem, 6vw, 4rem)/1 'WhoAsksSatan', serif;
    letter-spacing: .08em;
    text-shadow: 0 0 18px rgba(0, 0, 0, .95), 0 3px 8px rgba(0, 0, 0, .8)
}

#lt {
    order: 2;
    width: 100%;
    color: rgba(209, 201, 184, .72);
    font-size: 11px;
    letter-spacing: .14em;
    text-shadow: 0 0 8px rgba(0, 0, 0, .9)
}

#lt b {
    display: block;
    font-size: 2.2rem;
    margin-bottom: 4px
}

#ls {
    order: 3;
    min-height: 16px;
    color: rgba(209,201,184,.62);
    font-size: 11px;
    letter-spacing: .06em
}

/* ---- Google sign-in ---- */
#auth-section {
    order: 4;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    width: 100%;
    margin-top: 4px
}

#auth-user {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 1px solid rgba(209,201,184,.2);
    border-radius: 9px;
    background: rgba(20,16,10,.7);
    box-shadow: inset 0 1px 0 rgba(255, 247, 210, .05)
}

#auth-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover
}

#auth-name {
    font-size: 12px;
    color: #d1c9b8;
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

#sign-in-btn {
    width: min(320px, 100%);
    padding: 14px 22px;
    border: 1px solid rgba(209,201,184,.3);
    border-radius: 8px;
    background: rgba(30,24,14,.6);
    color: #d1c9b8;
    font-size: 12px;
    letter-spacing: .1em;
    cursor: pointer;
    transition: background .2s, border-color .2s, transform .2s
}

#sign-in-btn:hover {
    background: rgba(60,48,28,.7);
    border-color: rgba(209,201,184,.5);
    transform: translateY(-1px)
}

#sign-in-btn:disabled {
    opacity: .5;
    cursor: wait
}

#sign-out-btn {
    padding: 6px 10px;
    border: 1px solid rgba(209,201,184,.2);
    border-radius: 6px;
    background: transparent;
    color: rgba(209,201,184,.6);
    font: 9px ui-monospace, Menlo, Consolas, monospace;
    letter-spacing: .08em;
    cursor: pointer
}

#sign-out-btn:hover {
    color: #d1c9b8;
    border-color: rgba(209,201,184,.4)
}

/* ---- Room create / join ---- */
#room-section {
    order: 4;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    width: 100%;
    margin-top: 4px
}

#room-code-input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 1px solid rgba(209,201,184,.25);
    border-radius: 8px;
    background: rgba(20,16,10,.6);
    color: #d1c9b8;
    font: 16px ui-monospace, Menlo, Consolas, monospace;
    letter-spacing: .2em;
    text-align: center;
    text-transform: uppercase;
    outline: none;
    transition: border-color .2s
}

#room-code-input::placeholder {
    font-size: 10px;
    letter-spacing: .1em;
    color: rgba(209,201,184,.35);
    text-transform: none
}

#room-code-input:focus {
    border-color: rgba(209,201,184,.5)
}

#room-buttons {
    display: flex;
    gap: 8px;
    width: 100%;
    flex-wrap: wrap;
    justify-content: center
}

#room-buttons button {
    flex: 1 1 120px;
    padding: 11px 14px;
    border: 1px solid rgba(209,201,184,.25);
    border-radius: 7px;
    background: rgba(30,24,14,.5);
    color: #d1c9b8;
    font: 10px ui-monospace, Menlo, Consolas, monospace;
    letter-spacing: .1em;
    cursor: pointer;
    transition: background .2s, border-color .2s
}

#room-buttons #room-back-btn {
    flex: 0 1 90px;
    color: rgba(209,201,184,.72)
}

#room-buttons button:hover {
    background: rgba(60,48,28,.6);
    border-color: rgba(209,201,184,.45)
}

#room-buttons button:disabled {
    opacity: .45;
    cursor: wait
}

#room-status {
    font-size: 10px;
    color: rgba(209,201,184,.6);
    min-height: 14px;
    letter-spacing: .06em
}

#mode-choice {
    order: 4;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    width: 100%;
    margin-top: 2px
}

#mode-choice button {
    width: fit-content;
    min-width: 220px;
    padding: 8px 0;
    border: 0;
    border-left: 2px solid transparent;
    border-radius: 0;
    background: transparent;
    color: rgba(209, 201, 184, .7);
    text-align: left;
    font-size: 13px;
    letter-spacing: .08em;
    transition: color .2s, border-color .2s, padding-left .2s
}

#mode-choice button:hover {
    padding-left: 12px;
    border-left-color: #d1c9b8;
    background: transparent;
    color: #f0e5c4
}

@media (max-width: 600px) {
    #load {
        padding: 48px 28px
    }

    #menu-brand {
        margin-bottom: 34px
    }
}

@media (max-width: 420px) {
    #load {
        padding: 38px 22px
    }

    #menu-brand {
        font-size: clamp(2rem, 11vw, 3rem)
    }

    #mode-choice {
        gap: 2px
    }

    #mode-choice button {
        min-width: 190px
    }

    #room-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr
    }

    #room-buttons #room-back-btn {
        grid-column: 1 / -1;
        width: 100%
    }
}