:root {
  --cream: #f3e8c8;
  --sand: #d9b879;
  --sand-dark: #a47a3d;
  --ink: #101914;
  --olive: #304a38;
  --acid: #e7ff63;
  --red: #ff5c52;
  --panel: rgba(15, 25, 19, .92);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  color: var(--cream);
  background:
    radial-gradient(circle at 20% -10%, #536d45 0, transparent 35%),
    linear-gradient(145deg, #17251c, #08110c 76%);
  font-family: "Arial Narrow", "Roboto Condensed", Impact, system-ui, sans-serif;
  user-select: none;
}

button, input { font: inherit; }
button { color: inherit; }

.portal-home {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 44px;
  height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 999px;
  color: #fff;
  background: rgba(15, 25, 19, .86);
  box-shadow: 0 5px 18px rgba(0,0,0,.35);
  backdrop-filter: blur(7px);
  font: 800 13px/1 system-ui, sans-serif;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s, background .12s;
}
.portal-home span { font-size: 20px; line-height: 1; }
.portal-home:hover { background: rgba(48, 74, 56, .98); }
.portal-home:active { transform: scale(.94); }
.portal-home:focus-visible { outline: 3px solid var(--acid); outline-offset: 2px; }

.screen { display: none; min-height: 100dvh; }
.screen.active { display: flex; }

@media (max-width: 560px) {
  .portal-home { width: 44px; padding: 0; }
  .portal-home b {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

#home {
  position: relative;
  overflow: hidden;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 38px 18px;
  background:
    linear-gradient(180deg, rgba(7, 14, 10, .15), rgba(7, 14, 10, .94)),
    repeating-linear-gradient(115deg, transparent 0 52px, rgba(255,255,255,.018) 53px 55px),
    radial-gradient(circle at 50% 30%, #42593d, #142219 62%);
}

#home::before, #home::after {
  content: "";
  position: absolute;
  width: 42vw;
  height: 42vw;
  min-width: 390px;
  min-height: 390px;
  border: 2px solid rgba(231,255,99,.08);
  transform: rotate(45deg);
}

#home::before { left: -27vw; top: -20vw; }
#home::after { right: -28vw; bottom: -22vw; }

.sun {
  position: absolute;
  width: 460px;
  height: 460px;
  top: -280px;
  border-radius: 50%;
  background: rgba(231, 255, 99, .08);
  box-shadow: 0 0 120px rgba(231, 255, 99, .08);
}

.brand-mark {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 2px solid var(--acid);
  color: var(--acid);
  font-size: 26px;
  font-weight: 900;
  transform: rotate(-4deg);
}

.eyebrow {
  position: relative;
  z-index: 1;
  margin: 16px 0 2px;
  color: var(--acid);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .24em;
}

h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: clamp(54px, 8vw, 92px);
  font-weight: 1000;
  letter-spacing: -.045em;
  line-height: .92;
  text-align: center;
  text-shadow: 0 7px 0 rgba(0,0,0,.25);
}

h1 span {
  color: var(--acid);
  -webkit-text-stroke: 1px rgba(0,0,0,.25);
}

.lead {
  position: relative;
  z-index: 1;
  margin: 14px 0 22px;
  color: #d6ddcf;
  font-family: system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  text-align: center;
}

.lobby-card {
  position: relative;
  z-index: 2;
  width: min(430px, 100%);
  padding: 22px;
  border: 1px solid rgba(231,255,99,.22);
  background: rgba(7, 16, 10, .8);
  box-shadow: 0 24px 80px rgba(0,0,0,.48);
  backdrop-filter: blur(12px);
}

label {
  display: block;
  margin: 0 0 7px;
  color: #aebaa9;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .18em;
}

input {
  width: 100%;
  height: 48px;
  border: 1px solid #46544a;
  border-radius: 0;
  outline: none;
  padding: 0 14px;
  color: white;
  background: #152019;
  font-family: system-ui, sans-serif;
  font-size: 16px;
}

input:focus { border-color: var(--acid); box-shadow: 0 0 0 2px rgba(231,255,99,.12); }

.primary {
  display: flex;
  width: 100%;
  margin-top: 13px;
  border: 0;
  padding: 13px 16px;
  align-items: center;
  gap: 14px;
  color: #131b10;
  background: var(--acid);
  cursor: pointer;
  text-align: left;
  box-shadow: 5px 5px 0 #76902d;
}

.primary:hover { transform: translate(-1px, -1px); box-shadow: 7px 7px 0 #76902d; }
.primary:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 #76902d; }
.primary:disabled { opacity: .55; cursor: progress; }
.button-icon { font-size: 30px; line-height: 1; }
.primary b { display: block; font-size: 17px; letter-spacing: .06em; }
.primary small { display: block; font: 11px system-ui, sans-serif; opacity: .68; }

.error { min-height: 16px; margin: 10px 0 -6px; color: #ff8580; font: 12px system-ui, sans-serif; text-align: center; }

.feature-row {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 26px;
  margin-top: 22px;
  color: #879287;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
}

#gameScreen {
  min-height: 100dvh;
  flex-direction: column;
  background: #0b120e;
}

.game-header {
  height: 62px;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid #2c3a30;
  background: #111b15;
}

.mini-brand {
  color: var(--cream);
  font-size: 15px;
  font-weight: 1000;
  letter-spacing: .08em;
  text-decoration: none;
}

.mini-brand span {
  display: inline-grid;
  width: 30px;
  height: 30px;
  margin-right: 8px;
  place-items: center;
  border: 1px solid var(--acid);
  color: var(--acid);
}

.room-pill {
  display: flex;
  height: 37px;
  padding-left: 14px;
  align-items: center;
  gap: 9px;
  border: 1px solid #46574a;
  color: #7f9082;
  font-size: 10px;
  letter-spacing: .12em;
}

.room-pill strong { color: var(--acid); font-size: 13px; letter-spacing: .16em; }

.leave {
  justify-self: end;
  border: 1px solid #63433f;
  padding: 9px 13px;
  color: #ff8f87;
  background: transparent;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
  cursor: pointer;
}

.game-layout {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
}

.scoreboard {
  padding: 18px 14px;
  border-right: 1px solid #2c3a30;
  background: #101913;
}

.panel-label {
  margin: 0 4px 12px;
  color: #6e7e71;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .18em;
}

.player-card {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
  padding: 10px;
  border: 1px solid #304036;
  background: #18241c;
}

.player-card.me { border-color: var(--acid); }
.player-card.dead { opacity: .45; }
.player-color { width: 9px; height: 32px; }
.player-name { min-width: 0; overflow: hidden; font: 700 12px system-ui, sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.player-hp { margin-top: 4px; color: #ff6a61; font-size: 9px; letter-spacing: 2px; }
.player-wins { color: var(--acid); font-size: 16px; font-weight: 900; }

.rules {
  position: relative;
  display: grid;
  margin-top: 24px;
  padding: 16px;
  place-items: center;
  overflow: hidden;
  border: 1px dashed #435347;
  color: #7e8d80;
}

.rules::after { content: "★"; position: absolute; right: -9px; bottom: -17px; color: rgba(231,255,99,.05); font-size: 90px; }
.rules p, .rules span { margin: 0; font-size: 9px; letter-spacing: .15em; }
.rules strong { color: var(--acid); font-size: 46px; line-height: .95; }

.arena-shell {
  position: relative;
  min-width: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 14px;
  background:
    radial-gradient(circle at center, #223328, #0b130e 75%);
}

#arena {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 110px);
  aspect-ratio: 16 / 9;
  border: 2px solid #6d8c65;
  background: var(--sand);
  box-shadow: 0 20px 80px #000;
  touch-action: none;
}

.status-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  min-width: min(390px, 80%);
  padding: 16px 22px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(231,255,99,.55);
  color: white;
  background: rgba(8, 15, 10, .88);
  text-align: center;
  box-shadow: 8px 8px 0 rgba(0,0,0,.3);
  pointer-events: none;
}

.status-banner.hidden { display: none; }
.status-banner strong { display: block; color: var(--acid); font-size: 22px; letter-spacing: .08em; }
.status-banner span { display: block; margin-top: 5px; color: #bdc7bc; font: 12px system-ui, sans-serif; }

.connection-badge {
  position: absolute;
  top: 24px;
  right: 24px;
  padding: 7px 9px;
  color: #ffb3ae;
  background: #321d1b;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .08em;
}

.connection-badge.online { color: #bdf58d; background: #203419; }

.controls-hint {
  height: 48px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  border-top: 1px solid #2c3a30;
  color: #718074;
  background: #111b15;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .1em;
}

kbd { margin-right: 5px; border: 1px solid #425046; padding: 4px 6px; color: #ced7ce; background: #1d2820; font-family: inherit; }
#soundToggle { border: 0; background: transparent; cursor: pointer; }
.touch-controls { display: none; }

@media (pointer: coarse), (max-width: 800px) {
  .feature-row { gap: 10px; font-size: 8px; }
  .game-header { height: 54px; grid-template-columns: 1fr auto; padding: 0 10px; }
  .mini-brand { font-size: 0; }
  .mini-brand span { margin: 0; font-size: 16px; }
  .room-pill { justify-self: end; }
  .leave { display: none; }
  .game-layout { display: block; }
  .scoreboard { display: none; }
  .arena-shell { height: calc(100dvh - 54px); padding: 0; }
  #arena { width: 100%; max-height: 100%; border: 0; }
  .controls-hint { display: none; }
  .touch-controls { position: absolute; inset: 0; display: block; pointer-events: none; }
  .stick-zone { position: absolute; bottom: max(18px, env(safe-area-inset-bottom)); width: 118px; height: 118px; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; pointer-events: auto; touch-action: none; }
  .stick-zone::before, .stick-zone::after { content: ""; position: absolute; background: rgba(255,255,255,.12); }
  .stick-zone::before { left: 15px; right: 15px; top: 50%; height: 1px; }
  .stick-zone::after { top: 15px; bottom: 15px; left: 50%; width: 1px; }
  .move-zone { left: 22px; }
  .aim-zone { right: 22px; }
  .stick { position: absolute; inset: 28px; border-radius: 50%; background: rgba(231,255,99,.2); border: 2px solid rgba(231,255,99,.65); }
  .stick i { position: absolute; inset: 12px; border-radius: 50%; background: var(--acid); opacity: .7; }
  .stick-zone span { position: absolute; width: 130px; left: -6px; bottom: -17px; color: rgba(255,255,255,.55); font-size: 8px; font-weight: 900; letter-spacing: .1em; text-align: center; }
  .status-banner { top: 22%; }
  .connection-badge { top: 10px; right: 10px; }
}

@media (max-height: 680px) and (orientation: landscape) {
  #home { justify-content: flex-start; overflow-y: auto; padding-top: 20px; }
  h1 { font-size: 50px; }
  .lead { display: none; }
  .lobby-card { margin-top: 12px; }
}
