:root {
  --background: #0c1009;
  --panel: #171d12;
  --panel-strong: #202818;
  --line: #4e5938;
  --text: #f1e9ce;
  --muted: #a5a68c;
  --gold: #d6b95f;
  --green: #77db73;
  --red: #df6e61;
}

* { box-sizing: border-box; }
html, body, #app { width: 100%; min-height: 100%; margin: 0; }
body { background: var(--background); color: var(--text); font-family: "Space Grotesk", sans-serif; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.brand { font: 700 20px "Cinzel"; letter-spacing: .04em; }
.brand span { color: var(--gold); }
.brand i { margin-left: 7px; color: var(--green); font: 500 9px "DM Mono"; }
.brand.large { font-size: clamp(28px, 4vw, 48px); }
.primary, .quiet-button, .danger-button {
  border: 1px solid var(--line);
  padding: 11px 16px;
  color: var(--text);
  background: var(--panel-strong);
  font: 700 10px "DM Mono";
  letter-spacing: .08em;
}
.primary { border-color: #77914a; background: #33451f; color: #e8f2c8; }
.primary[href] { display: inline-block; text-decoration: none; }
.primary:hover { background: #415a26; }
.primary.small, .danger-button.small { padding: 8px 10px; }
.quiet-button:hover { border-color: var(--gold); }
.danger-button { border-color: #8f443c; background: #47251f; color: #ffd2cb; }
.success { color: var(--green) !important; }
.danger { color: var(--red) !important; }

.menu-screen { position: relative; min-height: 100vh; overflow: hidden; isolation: isolate; }
.menu-background {
  position: fixed; inset: 0; z-index: -2;
  background: linear-gradient(90deg, #081007e8, #08100799 55%, #081007e8), url("reference/3.png") center/cover no-repeat;
  filter: saturate(.72) contrast(1.1);
}
.menu-background::after { content: ""; position: absolute; inset: 0; background: linear-gradient(#02050255, #050805e8); }
.menu-header {
  min-height: 76px; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between;
  background: #0c100bea; border-bottom: 1px solid #5a603e;
}
.account-box { display: flex; align-items: center; gap: 9px; }
.account-box > span { color: var(--gold); font: 11px "DM Mono"; }
.season-menu { width: min(1280px, calc(100% - 40px)); margin: 0 auto; padding: 64px 0 100px; }
.menu-intro { max-width: 770px; margin-bottom: 38px; }
.menu-intro small, .identity-card > small, .modal-box > small { color: var(--gold); font: 700 10px "DM Mono"; letter-spacing: .16em; }
.menu-intro h1 { margin: 12px 0; font: 700 clamp(30px, 5vw, 60px)/1.04 "Cinzel"; }
.menu-intro p { max-width: 650px; color: #c1c0a7; font-size: 17px; }
.season-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; }
.season-card, .empty-card {
  padding: 20px; background: #11170eef; border: 1px solid var(--line); box-shadow: 8px 8px #03050388;
}
.season-card.registration_open { border-color: #61a858; box-shadow: 0 0 24px #55c75024, 8px 8px #03050388; }
.season-card.results, .season-card.finished { border-color: #967f42; }
.status-line { display: flex; justify-content: space-between; color: var(--green); font: 700 9px "DM Mono"; text-transform: uppercase; }
.status-line i { color: var(--muted); font-style: normal; }
.season-card h2 { min-height: 56px; margin: 15px 0 7px; font: 700 21px "Cinzel"; }
.season-card p { min-height: 58px; color: var(--muted); }
.season-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.season-card dl div { padding: 9px; background: #0b0f09; border: 1px solid #343d29; }
.season-card dt { color: #7f866d; font: 8px "DM Mono"; text-transform: uppercase; }
.season-card dd { margin: 4px 0 0; font: 600 12px "DM Mono"; }
.season-card > button { width: 100%; margin-top: 12px; }
.winner { margin-top: 10px; padding: 10px; background: #302b16; border: 1px solid #8c773b; color: #f1d374; text-align: center; font: 700 11px "Cinzel"; }
.large-winner { font-size: 17px; }
.menu-footer {
  position: absolute; bottom: 0; width: 100%; display: flex; justify-content: center; gap: 30px;
  padding: 15px; background: #090d08e8; border-top: 1px solid #3d4630; color: #92977e; font: 9px "DM Mono";
}

.prereg-screen { position: relative; min-height: 100vh; isolation: isolate; overflow: hidden; }
.prereg-background { filter: saturate(.55) brightness(.55) contrast(1.15); }
.prereg-header { position: relative; z-index: 5; }
.prereg-main { width: min(1180px, calc(100% - 30px)); margin: 0 auto; padding: 64px 0 100px; }
.prereg-intro { max-width: 850px; }
.prereg-intro small {
  color: var(--gold); font: 700 10px "DM Mono"; letter-spacing: .17em;
}
.prereg-intro h1 {
  margin: 14px 0 18px; font: 700 clamp(42px, 7vw, 78px)/.98 "Cinzel";
  text-shadow: 0 3px #020402;
}
.prereg-intro p {
  max-width: 760px; color: #c5c3a7; font-size: 17px; line-height: 1.6;
}
.prereg-countdown {
  width: min(620px, 100%); margin: 42px auto 12px; padding: 15px 24px;
  display: grid; place-items: center; gap: 7px;
  border: 1px solid #89753c; background: #0b1009e8;
  box-shadow: 0 0 25px #b79b3a18, inset 0 0 20px #9d803511;
}
.prereg-countdown small { color: #889077; font: 700 8px "DM Mono"; letter-spacing: .18em; }
.prereg-countdown strong {
  color: #ead075; font: 700 clamp(23px, 4vw, 38px) "Cinzel";
  letter-spacing: .09em; text-shadow: 0 0 18px #d8b85155;
}
.prereg-closed main {
  min-height: calc(100vh - 76px); padding: 30px; display: grid; place-content: center;
  justify-items: center; gap: 18px; text-align: center;
}
.prereg-closed main small { color: var(--gold); font: 700 10px "DM Mono"; letter-spacing: .16em; }
.prereg-closed main h1 {
  max-width: 900px; margin: 0; font: 700 clamp(38px, 7vw, 78px)/1.05 "Cinzel";
}
.prereg-seasons {
  margin: 44px 0 20px; padding: 18px; border: 1px solid #4c5738; background: #0c120adc;
}
.prereg-seasons > header { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 13px; }
.prereg-seasons > header b { color: var(--gold); font: 700 11px "Cinzel"; }
.prereg-seasons > header span { color: #838a73; font: 9px "DM Mono"; }
.prereg-seasons > div { display: grid; grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); gap: 10px; }
.prereg-season-card { padding: 13px; border: 1px solid #35402c; background: #11170eef; }
.prereg-season-card.registration_open { border-color: #5c8a4e; }
.prereg-season-card h3 { margin: 12px 0 6px; color: #eadfb9; font: 700 15px "Cinzel"; }
.prereg-season-card p { min-height: 40px; margin: 0 0 12px; color: #939981; font-size: 12px; }
.prereg-season-card > small { color: #7f866d; font: 8px "DM Mono"; }
.prereg-game-shell {
  margin: 24px auto 0; padding: 18px; border: 1px solid #7f6c35;
  background: linear-gradient(#10170dea, #080c07f2); box-shadow: 12px 14px #030503aa;
}
.prereg-game-shell > header {
  display: grid; grid-template-columns: 1fr minmax(260px, 1fr) auto;
  align-items: center; gap: 20px; padding: 5px 5px 17px;
}
.prereg-game-shell > header small { color: #7fa66c; font: 700 8px "DM Mono"; letter-spacing: .12em; }
.prereg-game-shell > header h2 { margin: 5px 0 0; color: #e2cb82; font: 700 25px "Cinzel"; }
.prereg-game-shell > header p { margin: 0; color: #9ba087; font: 10px/1.5 "DM Mono"; }
.prereg-game-shell > header > span { color: #d5bc68; font: 700 10px "DM Mono"; white-space: nowrap; }
.prereg-bridge {
  position: relative; width: min(640px, 100%); height: 720px; margin: 0 auto;
  overflow: hidden; border: 7px solid #34352b; box-shadow: inset 0 0 0 2px #11150d, 0 0 28px #020402;
  background:
    linear-gradient(90deg, #302f29 0 12%, transparent 12% 88%, #302f29 88%),
    repeating-linear-gradient(0deg, transparent 0 31px, #181c19 32px 33px),
    repeating-linear-gradient(90deg, #2e3029 0 31px, #151a16 32px 33px);
}
.prereg-water {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 35% 18%, #6fb6cc45 0 2px, transparent 3px),
    radial-gradient(ellipse at 65% 68%, #7bc5d74d 0 2px, transparent 3px),
    repeating-linear-gradient(174deg, #1e7892 0 3px, #185f7b 4px 8px, #287f9a 9px 11px);
  background-size: 33px 27px, 41px 35px, 100% 17px;
  filter: saturate(.8) brightness(.78);
  animation: prereg-water-flow 4s linear infinite;
}
.prereg-platform {
  position: absolute; z-index: 2; left: 12%; right: 12%; height: 68px;
  display: grid; place-items: center;
  border: 2px solid #1c211b; color: #bca862;
  background:
    repeating-linear-gradient(0deg, transparent 0 21px, #191b17 22px 23px),
    repeating-linear-gradient(90deg, #414139 0 30px, #262a24 31px 33px);
  font: 700 9px "DM Mono"; letter-spacing: .12em;
}
.prereg-platform.top { top: 0; border-top: 0; }
.prereg-platform.bottom { bottom: 0; border-bottom: 0; }
.prereg-panels {
  position: absolute; z-index: 3; left: 50%; top: 73px; bottom: 73px;
  width: 156px; transform: translateX(-50%);
  display: grid; grid-template-rows: repeat(10, 1fr); gap: 5px;
}
.prereg-bridge-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; min-height: 0; }
.prereg-panel {
  position: relative; min-height: 0; padding: 0;
  border: 2px solid #b9ecf6; background: #72bfd04d;
  box-shadow: inset 0 0 9px #c9f7ff55, 0 0 5px #55bedb66;
  transition: transform .16s, filter .16s, background .16s;
}
.prereg-panel::before, .prereg-panel::after {
  content: ""; position: absolute; inset: 5px; border: 1px solid #d9fbff4f;
}
.prereg-panel::after { inset: 0; border: 0; background: linear-gradient(135deg, transparent 48%, #e9ffff34 49% 51%, transparent 52%); }
.prereg-panel.current { cursor: pointer; animation: prereg-panel-pulse 1.4s ease-in-out infinite; }
.prereg-panel.current:hover { transform: translateY(-3px); background: #8ee2ef8a; filter: brightness(1.25); }
.prereg-panel.locked { opacity: .72; }
.prereg-panel.crossed { border-color: #86d071; background: #609c5c75; box-shadow: inset 0 0 10px #b5f3a566; }
.prereg-panel.broken {
  opacity: .76; border-color: #73584b; background:
    linear-gradient(32deg, transparent 35%, #0a0d0b 36% 45%, transparent 46%),
    linear-gradient(142deg, transparent 42%, #080a08 43% 52%, transparent 53%),
    #283e446e;
  box-shadow: inset 0 0 18px #080a08;
}
.prereg-panel.broken::before { inset: 18px 25px; transform: rotate(28deg); border-color: #090b09; }
.prereg-runner {
  position: absolute; z-index: 5; left: calc(50% - 24px);
  bottom: 9%;
  width: 48px; height: 62px; object-fit: contain; object-position: center;
  filter: drop-shadow(0 4px 2px #030503aa);
  pointer-events: none; transition: bottom .28s ease-out;
}
.prereg-message {
  width: min(640px, 100%); min-height: 35px; margin: 12px auto 0; padding: 10px;
  border: 1px solid #3f4d31; background: #0c1109; color: #9fb98b; text-align: center;
  font: 9px "DM Mono";
}
.prereg-reopen { display: block; width: min(300px, 100%); margin: 10px auto 0; }
.prereg-submitted-badge {
  width: min(640px, 100%); margin: 10px auto 0; padding: 11px;
  border: 1px solid #617f45; background: #172313; color: #a9ce83; text-align: center;
  font: 700 9px "DM Mono"; letter-spacing: .08em;
}
.prereg-bridge.impact { animation: prereg-impact .42s ease; }
.prereg-email-layer {
  position: fixed; z-index: 90; inset: 0; display: grid; place-items: center; padding: 20px;
  background: #020402c7; backdrop-filter: blur(3px);
}
.prereg-dialog {
  position: relative; width: min(480px, 100%); min-height: 360px; padding: 82px 54px 48px;
  display: grid; align-content: center; gap: 12px;
  background: url("assets/ui/npc-dialog-frame.png") center/100% 100% no-repeat;
  color: #d1b86d; filter: drop-shadow(10px 12px 7px #010201);
}
.prereg-dialog-title {
  position: absolute; top: 28px; left: 55px; right: 55px; text-align: center;
  color: #d7b85e; font: 700 19px "Cinzel";
}
.prereg-overlay-close {
  position: absolute; z-index: 3; top: 24px; right: 35px; width: 31px; height: 31px;
  display: grid; place-items: center; padding: 0;
  border: 1px solid #75652f; background: #11150ce8; color: #c6a853;
  font: 700 22px/1 "Cinzel";
}
.prereg-overlay-close:hover { border-color: #d9bc63; color: #f3d77e; background: #1c2513; }
.prereg-dialog-copy small { color: #79a76a; font: 700 8px "DM Mono"; letter-spacing: .13em; }
.prereg-dialog-copy h2 { margin: 8px 0; color: #ddc579; font: 700 23px/1.1 "Cinzel"; }
.prereg-dialog-copy p { margin: 0 0 8px; color: #bdad78; font: 11px/1.55 "DM Mono"; }
.prereg-dialog input {
  width: 100%; padding: 13px; outline: 0; border: 1px solid #67592e;
  background: #0b1009e8; color: #ede4c4; font: 11px "DM Mono";
}
.prereg-dialog input:focus { border-color: #a98e43; box-shadow: 0 0 10px #8d74342f; }
.prereg-dialog .primary { width: 100%; }
.prereg-success { min-height: 310px; }
@keyframes prereg-water-flow { to { background-position: 33px 27px, -41px 35px, 0 17px; } }
@keyframes prereg-panel-pulse { 50% { box-shadow: inset 0 0 14px #d7fbff8c, 0 0 11px #73d9ef99; } }
@keyframes prereg-impact {
  20% { transform: translateX(-6px); filter: saturate(.4); }
  45% { transform: translateX(6px); }
  70% { transform: translateX(-3px); }
}

.admin-portal {
  position: relative; min-height: 100vh; padding: 24px;
  display: grid; place-items: center; isolation: isolate;
}
.admin-portal-card {
  width: min(650px, 100%); padding: clamp(28px, 6vw, 58px);
  display: grid; justify-items: start; gap: 15px;
  border: 1px solid #78854c; background: #11170ef2;
  box-shadow: 14px 14px #03050399;
}
.admin-portal-card > small { color: var(--gold); font: 700 9px "DM Mono"; letter-spacing: .16em; }
.admin-portal-card h1 { margin: 12px 0 0; font: 700 clamp(28px, 5vw, 48px) "Cinzel"; }
.admin-portal-card p { margin: 0 0 8px; color: var(--muted); line-height: 1.6; }
.admin-portal-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.identity-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle, #26351b, #090d07 65%); }
.identity-card { width: min(520px, 100%); padding: 35px; background: var(--panel); border: 1px solid #78854c; box-shadow: 12px 12px #050704; }
.identity-card h1 { font-family: "Cinzel"; }
.identity-card p { color: var(--muted); line-height: 1.6; }
.identity-card code { color: var(--gold); }
.identity-card input, .admin-form input, .admin-form textarea {
  width: 100%; padding: 13px; background: #0c1109; border: 1px solid var(--line); color: var(--text); outline: none;
}
.identity-card input:focus, .admin-form input:focus { border-color: var(--green); }
.identity-card .primary { width: 100%; margin-top: 10px; }
.form-error { min-height: 22px; margin-top: 10px; color: var(--red); font: 10px "DM Mono"; }

.game-screen { height: 100vh; display: grid; grid-template-rows: 68px minmax(0, 1fr); }
.game-header {
  position: relative; z-index: 4; overflow: visible;
  display: grid; grid-template-columns: 1.1fr .55fr 100px 1fr .7fr auto; align-items: center; gap: 12px;
  padding: 7px 16px; background: #0d120bea; border-bottom: 1px solid #667143;
}
.game-header > div:not(.brand) { display: grid; gap: 3px; }
.game-header small { color: #777e67; font: 8px "DM Mono"; }
.game-header b { overflow: hidden; color: #e6dcb9; font: 600 11px "DM Mono"; text-overflow: ellipsis; white-space: nowrap; }
.game-header > div.header-actions { display: flex; justify-content: flex-end; gap: 7px; }
.crystal-counter {
  min-width: 58px; height: 34px; padding: 0 11px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid rgba(224, 190, 82, .48);
  background: linear-gradient(180deg, rgba(63, 51, 16, .78), rgba(13, 23, 11, .94));
  color: #f5d76e; box-shadow: inset 0 0 13px rgba(238, 194, 56, .08);
  font: 12px "DM Mono";
}
.crystal-counter b { color: #fff2ae; font-size: 13px; }
.currency-icon {
  width: 22px; height: 22px; object-fit: contain;
  filter: drop-shadow(0 0 4px rgba(255, 210, 71, .55));
}
.crystal-counter small {
  padding-left: 6px; border-left: 1px solid rgba(224, 190, 82, .28);
  color: #aeb58f; font: 8px "DM Mono"; white-space: nowrap;
}
.admin-header-button {
  border: 1px solid #9b7d2f; padding: 11px 13px; color: #fff2aa;
  background: linear-gradient(#385322, #1b2d13);
  box-shadow: inset 0 0 0 1px #72984a, 0 0 10px #6ed75024;
  font: 700 10px "DM Mono"; letter-spacing: .08em;
}
.admin-header-button:hover { border-color: #e4bd4f; background: #415f28; }
.coin-chest {
  position: relative; width: 94px; height: 54px; place-self: center; display: block !important;
  filter: drop-shadow(0 4px 2px #020300aa);
}
.chest-body, .chest-lid {
  position: absolute; left: 18px; width: 58px; border: 2px solid #261408;
  background:
    linear-gradient(90deg, transparent 46%, #251307 47% 53%, transparent 54%),
    repeating-linear-gradient(0deg, #6f3518 0 7px, #8c4a20 8px 13px);
  box-shadow: inset 0 0 0 2px #bd8737, inset 0 -6px #3c1d0d;
}
.chest-body { bottom: 2px; height: 29px; border-radius: 2px 2px 6px 6px; }
.chest-body::before, .chest-body::after {
  content: ""; position: absolute; top: 2px; bottom: 2px; width: 4px; background: #d1a34a;
  box-shadow: inset 0 0 0 1px #604016;
}
.chest-body::before { left: 6px; }
.chest-body::after { right: 6px; }
.chest-body span {
  position: absolute; z-index: 2; left: 50%; top: 6px; width: 12px; height: 14px;
  transform: translateX(-50%); border: 2px solid #5f3a10; border-radius: 2px;
  background: linear-gradient(#ffd86c, #b9751d);
}
.chest-lid {
  z-index: 3; bottom: 29px; height: 19px; transform-origin: 50% 100%; border-radius: 15px 15px 2px 2px;
  animation: chest-lid-loop 3.4s ease-in-out infinite;
}
.chest-lid::after {
  content: ""; position: absolute; left: 5px; right: 5px; bottom: 2px; height: 3px;
  border: 1px solid #704817; background: #d3a045;
}
.coin-rain { position: absolute; z-index: 2; inset: -4px 0 -12px; pointer-events: none; }
.coin-rain i {
  position: absolute; top: 13px; left: 44px; width: 8px; height: 8px; opacity: 0;
  border: 1px solid #714812; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3a1 0 16%, #f3c645 20% 55%, #a96813 72%);
  box-shadow: 0 0 7px #ffc83d;
  animation: chest-coin-loop 3.4s ease-in infinite;
}
.coin-rain i:nth-child(2) { --coin-x: -25px; animation-delay: .12s; }
.coin-rain i:nth-child(3) { --coin-x: 24px; animation-delay: .24s; }
.coin-rain i:nth-child(4) { --coin-x: -12px; animation-delay: .36s; }
.coin-rain i:nth-child(5) { --coin-x: 13px; animation-delay: .48s; }
.coin-rain i:first-child { --coin-x: 2px; }
@keyframes chest-lid-loop {
  0%, 16%, 84%, 100% { transform: translateY(0) rotateX(0); filter: brightness(.9); }
  28%, 68% { transform: translateY(-7px) rotateX(-32deg); filter: brightness(1.2); }
}
@keyframes chest-coin-loop {
  0%, 25% { opacity: 0; transform: translate(0, 10px) rotateY(0); }
  34% { opacity: 1; transform: translate(calc(var(--coin-x) * .35), -15px) rotateY(160deg); }
  64% { opacity: 1; transform: translate(var(--coin-x), 31px) rotateY(520deg); }
  74%, 100% { opacity: 0; transform: translate(var(--coin-x), 47px) rotateY(700deg); }
}
.world-shell { position: relative; min-height: 0; overflow: hidden; background: #26351e; }
#worldCanvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.ghost-realm #worldCanvas { filter: grayscale(.72) sepia(.18) contrast(1.08); }
.world-hud, .phase-card, .controls {
  position: absolute; z-index: 2; background: #10150ded; border: 1px solid #81713e; box-shadow: 5px 5px #05070499;
  font: 10px/1.55 "DM Mono";
}
.world-hud { left: 15px; top: 15px; display: grid; padding: 12px; color: var(--muted); }
.world-hud b { color: var(--gold); font-family: "Cinzel"; }
.world-hud i { color: var(--text); font-style: normal; }
.phase-card { right: 15px; top: 15px; display: grid; max-width: 330px; padding: 12px; }
.phase-card b { color: var(--green); }
.phase-card span { color: var(--muted); }
.ghost-realm .phase-card b { color: var(--red); }
.bridge-hud {
  position: absolute; z-index: 3; left: 15px; top: 122px;
  display: grid; gap: 5px; max-width: 270px; padding: 12px 14px;
  border: 1px solid #77b9bd;
  background: linear-gradient(135deg, #0b1716ed, #10150ded);
  box-shadow: 0 0 18px #67dce02b, 5px 5px #05070499;
  font-family: "DM Mono", monospace;
}
.bridge-hud b { color: #9be5dd; font: 700 11px "Cinzel", serif; }
.bridge-hud span { color: #ead584; font-size: 9px; }
.bridge-hud small { color: #769693; font-size: 7px; }
.controls { bottom: 14px; left: 50%; transform: translateX(-50%); padding: 8px 12px; color: #d8c989; white-space: nowrap; }
.game-chat {
  position: absolute; z-index: 3; right: 15px; bottom: 15px;
  width: min(360px, calc(100% - 30px)); height: 310px;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto;
  background: #0c1109ef; border: 1px solid #777044; box-shadow: 6px 6px #030503aa;
}
.game-chat > header {
  display: flex; justify-content: space-between; padding: 9px 10px;
  border-bottom: 1px solid #3d4630; background: #151d11;
}
.game-chat > header b { color: var(--gold); font: 700 10px "Cinzel"; }
.game-chat > header span { color: #747c66; font: 8px "DM Mono"; }
.chat-messages { overflow-y: auto; padding: 7px 9px; scrollbar-color: #596044 #11170e; }
.chat-message { padding: 7px 2px; border-bottom: 1px solid #303828; }
.chat-message > div { display: flex; align-items: center; gap: 6px; }
.chat-message b { overflow: hidden; color: #eadcae; font: 700 9px "DM Mono"; text-overflow: ellipsis; white-space: nowrap; }
.chat-message i {
  padding: 2px 4px; border: 1px solid currentColor; font: 700 7px "DM Mono"; font-style: normal;
}
.chat-message i.alive { color: var(--green); }
.chat-message i.dead { color: var(--red); }
.chat-message time { margin-left: auto; color: #6f7663; font: 7px "DM Mono"; }
.chat-message p { margin: 5px 0 0; color: #c9c4a5; font: 10px/1.35 "Space Grotesk"; overflow-wrap: anywhere; }
.game-chat form { display: grid; grid-template-columns: minmax(0, 1fr) auto; border-top: 1px solid #3d4630; }
.game-chat input {
  min-width: 0; padding: 10px; border: 0; outline: 0; background: #090d07; color: var(--text);
  font: 10px "DM Mono";
}
.game-chat form button {
  border: 0; border-left: 1px solid #657045; padding: 0 12px;
  background: #2d421e; color: #e5f4bd; font: 700 8px "DM Mono";
}
.game-chat > small { min-height: 0; padding: 0 9px; color: var(--red); font: 8px "DM Mono"; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: #020402dc; }
.modal-box { width: min(680px, 100%); max-height: 88vh; overflow: auto; padding: 24px; background: var(--panel); border: 1px solid #8a7840; box-shadow: 12px 12px #030403; }
.modal-close { float: right; border: 0; background: none; color: var(--text); font-size: 25px; }
.modal-box h2 { font-family: "Cinzel"; }
.modal-content { color: #c5c2a6; }
.wallet-list { display: grid; gap: 8px; }
.wallet-list button { display: flex; justify-content: space-between; padding: 13px; background: #10160d; border: 1px solid var(--line); color: var(--text); }
.wallet-list span { color: var(--muted); }
.stats-table { width: 100%; margin-top: 15px; border-collapse: collapse; }
.stats-table th, .stats-table td { padding: 9px; border: 1px solid #3e4830; text-align: left; font: 10px "DM Mono"; }
.phase-history { color: var(--muted); font: 10px/1.8 "DM Mono"; }

.npc-dialog-layer {
  position: absolute; inset: 0; z-index: 5; overflow: hidden; pointer-events: none;
}
.npc-dialog {
  position: absolute; isolation: isolate; pointer-events: auto;
  width: min(470px, calc(100% - 24px)); height: min(520px, calc(100% - 24px));
  display: grid; grid-template-rows: 88px auto minmax(0, 1fr);
  padding: 0 28px 28px 40px;
  color: #d5bd73;
  filter: drop-shadow(7px 9px 5px #020402b8);
  font-family: "Cinzel", Georgia, serif;
}
.npc-dialog::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: url("assets/ui/npc-dialog-frame.png") center/100% 100% no-repeat;
  transform-origin: center;
}
.npc-dialog.points-right::before { transform: scaleX(-1); }
.npc-dialog-close {
  position: absolute; z-index: 3; right: 20px; top: 14px;
  width: 31px; height: 31px; padding: 0;
  display: grid; place-items: center;
  border: 1px solid #75652f; background: #11150cdd; color: #b99a4e;
  box-shadow: inset 0 0 0 2px #252614;
  font: 700 22px/1 "Cinzel", serif;
}
.npc-dialog-close:hover { border-color: #d9bc63; color: #f3d77e; background: #1c2513; }
.npc-dialog-header { display: grid; place-items: center; padding: 7px 42px 0 12px; }
.npc-dialog-header h2 {
  margin: 0; color: #d5b45b; text-align: center;
  text-shadow: 1px 2px #080a05;
  font: 700 19px/1 "Cinzel", Georgia, serif; letter-spacing: .035em;
}
.npc-dialog-copy {
  display: grid; align-content: start; gap: 6px; min-height: 58px; padding: 3px 8px 8px;
}
.npc-dialog-copy b {
  color: #c8ad5e; font: 700 10px/1.3 "Cinzel", Georgia, serif; letter-spacing: .025em;
}
.npc-dialog-copy span {
  color: #cbb574; font: 500 10px/1.45 "DM Mono", monospace;
}
.npc-dialog-copy em {
  color: #e58369; font: 700 9px/1.35 "DM Mono", monospace; font-style: normal;
}
.npc-dialog-result {
  align-self: start; margin: 18px 14px; padding: 18px;
  border: 1px solid #6d5c2e; background: #0c1009c9; color: #d9c27e;
  font: 600 13px/1.65 "Cinzel", Georgia, serif; text-align: center;
}
.npc-dialog-message { height: min(350px, calc(100% - 24px)); grid-template-rows: 62px 1fr; }
.npc-dialog-message.is-error .npc-dialog-result { border-color: #814e36; color: #e9a079; }
.daily-challenge-board {
  position: relative; min-height: 0; overflow: hidden;
  margin: 0 4px 4px; border: 0; background: transparent;
}
.daily-answer {
  position: absolute; z-index: 1; min-width: 112px; max-width: 158px; padding: 9px 12px 9px 27px;
  transform: translate(-50%, -50%);
  border: 1px solid #665a2d; background: #11170ed9; color: #d9bd70;
  box-shadow: inset 0 0 0 1px #202815, 2px 3px #0507048f;
  font: 600 9px/1.25 "Cinzel", Georgia, serif; letter-spacing: .015em; white-space: nowrap;
  animation: daily-button-drift var(--drift-duration, 2.8s) ease-in-out infinite alternate;
}
.daily-answer::before {
  content: ""; position: absolute; left: 11px; top: 50%; width: 8px; height: 8px;
  transform: translateY(-50%) rotate(45deg);
  border: 1px solid #b49441; box-shadow: inset 0 0 0 2px #11170e;
}
.daily-answer:hover {
  z-index: 4; border-color: #c5aa55; background: #172012e8; color: #73b85c;
  animation-play-state: paused;
}
.daily-answer:hover::before { border-color: #7db765; }
.daily-answer:disabled { pointer-events: none; opacity: .45; }
@keyframes daily-button-drift {
  from { transform: translate(-50%, -50%) translate(0, 0); }
  to { transform: translate(-50%, -50%) translate(var(--drift-x, 12px), var(--drift-y, 8px)); }
}
.admin-form { display: grid; gap: 10px; }
.admin-form label { display: grid; gap: 5px; color: var(--muted); font: 9px "DM Mono"; }
.admin-form textarea { min-height: 90px; resize: vertical; }
.admin-form hr { width: 100%; border: 0; border-top: 1px solid var(--line); }
.admin-form > span { color: var(--muted); }
.admin-checkbox {
  grid-template-columns: auto 1fr !important;
  align-items: center; justify-content: start;
}
.admin-checkbox input { width: auto; margin: 0; accent-color: var(--green); }
.admin-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.admin-section { display: grid; gap: 10px; padding: 14px; border: 1px solid #414b32; background: #10150d; }
.admin-section > b { color: var(--gold); font: 700 11px "Cinzel"; }
.admin-section > span { color: var(--muted); font: 9px "DM Mono"; }
.admin-inline { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.admin-inline button { white-space: nowrap; }
.admin-players { margin-top: 0; }
.admin-players td:first-child { display: grid; gap: 3px; }
.admin-players td small { color: #7f866d; font-size: 8px; }
.fatal-error { min-height: 100vh; display: grid; place-content: center; text-align: center; }

@media (max-width: 850px) {
  .game-header { grid-template-columns: 1fr 1fr auto; }
  .game-header > div:nth-child(2), .game-header > div:nth-child(4), .game-header > div:nth-child(5) { display: none; }
  .menu-header { align-items: flex-start; gap: 15px; }
  .account-box { flex-wrap: wrap; justify-content: flex-end; }
}

@media (max-width: 600px) {
  .menu-header { padding: 12px; }
  .brand.large { font-size: 25px; }
  .season-menu { width: calc(100% - 20px); padding-top: 38px; }
  .menu-intro h1 { font-size: 32px; }
  .prereg-main { width: calc(100% - 16px); padding-top: 34px; }
  .prereg-intro h1 { font-size: 41px; }
  .prereg-intro p { font-size: 14px; }
  .prereg-seasons { padding: 12px; }
  .prereg-seasons > header { display: grid; }
  .prereg-game-shell { padding: 8px; }
  .prereg-game-shell > header { grid-template-columns: 1fr auto; gap: 8px; }
  .prereg-game-shell > header p { grid-column: 1 / -1; grid-row: 2; }
  .prereg-bridge { height: 620px; }
  .prereg-panels { width: 132px; }
  .prereg-runner { width: 42px; height: 55px; }
  .prereg-dialog { min-height: 340px; padding: 75px 40px 42px; }
  .prereg-dialog-title { left: 42px; right: 42px; font-size: 16px; }
  .menu-footer { display: none; }
  .season-card dl { grid-template-columns: 1fr; }
  .game-header { grid-template-columns: 1fr .7fr auto; }
  .phase-card { display: none; }
  .bridge-hud { left: 8px; top: 8px; max-width: 220px; }
  .coin-chest { transform: scale(.85); }
  .admin-inline { grid-template-columns: 1fr; }
  .controls { display: none; }
  .game-chat { right: 8px; bottom: 8px; width: calc(100% - 16px); height: 230px; }
  .npc-dialog {
    width: calc(100% - 16px); height: min(470px, calc(100% - 16px));
    grid-template-rows: 78px auto minmax(0, 1fr);
    padding: 0 18px 20px 28px;
  }
  .npc-dialog-header h2 { font-size: 16px; }
  .npc-dialog-copy span { font-size: 9px; }
  .daily-answer { min-width: 96px; max-width: 128px; padding: 8px 8px 8px 23px; font-size: 8px; }
  .daily-answer::before { left: 9px; width: 7px; height: 7px; }
}
