* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: #0a0a0a;
  color: #f3f0e5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.shell { width: min(1180px, 96vw); margin: 0 auto; padding: 28px 0 60px; }
.site-header {
  display: grid;
  grid-template-columns: minmax(110px, 180px) minmax(0, 1fr) minmax(110px, 180px);
  align-items: center;
  gap: 24px;
  margin-bottom: 24px;
  border-bottom: 1px solid #444;
  padding-bottom: 18px;
}
.header-copy { min-width: 0; }
.header-dragon {
  display: block;
  width: 100%;
  max-height: 150px;
  object-fit: contain;
  image-rendering: pixelated;
  user-select: none;
  pointer-events: none;
}
.header-dragon-left { justify-self: start; }
.header-dragon-right { justify-self: end; }
.eyebrow { color: #d74c42; letter-spacing: .18em; font-size: 12px; }
h1 { margin: 7px 0 4px; font-size: clamp(30px, 5vw, 64px); letter-spacing: -.04em; }
.site-title-link { color: inherit; text-decoration: none; }
.site-title-link:hover { color: #fff; }
.site-header p { margin: 0; color: #aaa; }
.layout {
  display: grid;
  grid-template-columns: minmax(320px, 3fr) minmax(280px, 1fr);
  gap: 24px;
  align-items: start;
}
.game-column {
  min-width: 0;
  display: grid;
  gap: 24px;
  align-content: start;
}
.cabinet {
  background: #000;
  border: 12px solid #292929;
  box-shadow: 0 0 0 2px #555, 0 18px 50px #000;
  aspect-ratio: 3 / 4;
  max-height: 78vh;
  margin: 0 auto;
}
.game-stage { position: relative; isolation: isolate; width: 100%; height: 100%; overflow: hidden; background: #000; }
#game { position: relative; z-index: 1; width: 100%; height: 100%; image-rendering: pixelated; background: #000; }
.ejs_menu_bar { display: none !important; pointer-events: none !important; }
.game-splash {
  position: absolute;
  inset: 0;
  z-index: 20;
  overflow: hidden;
  background: #000;
  opacity: 1;
  visibility: visible;
  transition: opacity .18s ease, visibility .18s ease;
  pointer-events: none;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.game-splash img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center center; }
.game-splash.is-hidden { opacity: 0; visibility: hidden; }
.player-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  width: min(100%, calc(78vh * 3 / 4));
  justify-self: center;
  padding: 12px 14px;
  border: 1px solid #3a3a3a;
  background: #111;
}
.volume-control {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr);
  align-items: center;
  gap: 12px;
  margin: 0;
  color: #bbb;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.volume-control input[type="range"] {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: #d74c42;
}
.fullscreen-control {
  width: auto;
  min-width: 140px;
  justify-self: end;
  margin: 0;
  padding: 8px 12px;
  font-size: 11px;
}
.fight-controls-card {
  overflow: hidden;
  border: 1px solid #4a3333;
  background: #111;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .28);
}
.fight-controls-card img {
  display: block;
  width: 100%;
  height: auto;
}
.network-card {
  padding: 24px;
  border: 1px solid #663034;
  border-top: 4px solid #d74c42;
  background: linear-gradient(180deg, #241113 0%, #121212 100%);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .34);
}
.network-kicker {
  margin-bottom: 8px;
  color: #17eb4d;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
}
.network-card h2 {
  margin: 0 0 14px;
  color: #fff;
  font-size: clamp(22px, 2.7vw, 34px);
  letter-spacing: -.025em;
}
.network-card p {
  margin: 0 0 13px;
  color: #c6c6c6;
  line-height: 1.68;
}
.network-card strong { color: #fff; }
.network-card .network-lead {
  padding: 13px 15px;
  border-left: 3px solid #17eb4d;
  background: #0d160f;
  color: #e9ffed;
  font-size: 15px;
  line-height: 1.6;
}
.network-card .network-tagline {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid #4a3333;
  color: #fff3d8;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.history-card {
  padding: 22px;
  border: 1px solid #4a3333;
  border-top: 3px solid #d74c42;
  background: linear-gradient(180deg, #1a1010 0%, #111 100%);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .28);
}
.history-kicker {
  margin-bottom: 8px;
  color: #d9a34a;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
}
.history-card h2 {
  margin: 0 0 12px;
  color: #fff3d8;
  font-size: clamp(20px, 2.4vw, 30px);
  letter-spacing: -.02em;
}
.history-card p {
  margin: 0 0 12px;
  color: #bbb;
  line-height: 1.65;
}
.history-card strong { color: #f3f0e5; }
.history-card em { color: #e7d3ae; }
.history-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 11px 14px;
  border: 1px solid #d74c42;
  background: #321416;
  color: #fff;
  text-decoration: none;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}
.history-link:hover { background: #4a1a1d; }
.panel {
  display: flex;
  flex-direction: column;
  border: 1px solid #444;
  padding: 18px;
  background: #151515;
}
.panel [hidden] { display: none !important; }
.panel > * { order: 2; }
.panel > #panel-title { order: 0; }
.panel > .status { order: 1; margin-bottom: 18px; }
.panel h2 { margin-top: 0; }
label { display: grid; gap: 6px; margin: 13px 0; color: #bbb; font-size: 12px; text-transform: uppercase; }
input, button { font: inherit; }
input { width: 100%; border: 1px solid #555; background: #050505; color: #fff; padding: 10px; text-transform: none; }
button, .button-link { width: 100%; padding: 11px 12px; border: 1px solid #777; background: #2d2d2d; color: #fff; cursor: pointer; text-transform: uppercase; font-weight: 700; }
button:hover:not(:disabled), .button-link:hover { background: #444; }
button:disabled { opacity: .45; cursor: default; }
.button-link { display: block; text-align: center; text-decoration: none; }
#copy-invite.is-copied { color: #17eb4d; }
.mode-select { display: grid; gap: 12px; margin-bottom: 18px; }
.mode-card { display: grid; gap: 7px; text-align: left; text-transform: none; padding: 16px; background: #0d0d0d; border-color: #555; }
.mode-card strong { font-size: 16px; text-transform: uppercase; }
.mode-card span { color: #888; font-size: 11px; font-weight: 400; line-height: 1.5; }
.mode-card-primary { border-color: #d74c42; background: #241113; }
.mode-card-primary:hover:not(:disabled) { background: #341518; }
.match-card { margin: 0 0 18px; padding: 14px; border: 1px solid #444; background: #0d0d0d; }
.match-card h3 { margin: 0 0 6px; }
.match-card label { margin-bottom: 8px; }
.match-card input { font-size: 11px; }
.connection-card { border-color: #55784e; background: #101a10; box-shadow: inset 0 0 0 1px rgba(143, 218, 120, .08); }
.connection-card .small { color: #9bb497; }
.connection-heading { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; }
.connection-heading h3 { margin: 0; color: #d9f1d2; }
.connection-light { width: 12px; height: 12px; flex: 0 0 12px; border-radius: 50%; background: #8fda78; border: 1px solid #b9f6a8; box-shadow: 0 0 10px rgba(143, 218, 120, .45); }
.connection-card.is-waiting { border-color: #8a7429; background: #1b180b; box-shadow: inset 0 0 0 1px rgba(245, 205, 75, .08); }
.connection-card.is-waiting .small { color: #c7b66d; }
.connection-card.is-waiting .connection-heading h3 { color: #f3dc73; }
.connection-card.is-waiting .connection-light { background: #f1c94b; border-color: #ffe68a; box-shadow: 0 0 10px rgba(241, 201, 75, .5); }
.error-card { border-color: #8d171b; }
.ready-board { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 18px 0 10px; }
.ready-player { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid #3a3a3a; background: #0d0d0d; }
.ready-player div { display: grid; gap: 2px; }
.ready-player strong { font-size: 12px; text-transform: uppercase; }
.ready-player span:not(.ready-light) { font-size: 11px; color: #888; }
.ready-light { width: 14px; height: 14px; flex: 0 0 14px; border-radius: 50%; border: 1px solid #666; background: #272727; box-shadow: inset 0 0 0 2px #111; }
.ready-light.is-ready { background: #8fda78; border-color: #b9f6a8; box-shadow: 0 0 12px rgba(143, 218, 120, .65); }
.ready { margin-top: 8px; background: #8d171b; border-color: #d74c42; font-size: 18px; }
.ready-help { margin: 7px 0 0; text-align: center; }
.advanced-controls { margin-top: 18px; padding-top: 12px; border-top: 1px solid #333; }
.advanced-controls summary { color: #777; cursor: pointer; font-size: 11px; text-transform: uppercase; }
.advanced-controls[open] summary { margin-bottom: 10px; }
.button-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.button-grid button { padding: 8px 6px; font-size: 11px; }
.telemetry { margin: 20px 0; border-top: 1px solid #333; }
.telemetry div { display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid #333; padding: 8px 0; }
dt { color: #888; }
dd { margin: 0; text-align: right; }
#active-room.is-copyable { cursor: pointer; }
#active-room.is-copied { color: #17eb4d; }
#sync[data-ok="1"] { color: #8fda78; }
#sync[data-ok="0"] { color: #ff5959; }
.status {
  min-height: 62px;
  padding: 12px;
  background: #050505;
  border-left: 3px solid #17eb4d;
  line-height: 1.45;
}
.small { font-size: 11px; color: #777; line-height: 1.45; }
.site-footer {
  width: min(1180px, 96vw);
  margin: -36px auto 0;
  padding: 10px 0 14px;
  border-top: 1px solid #222;
  color: #666;
  font-size: 10px;
  line-height: 1.2;
  text-align: left;
}
.site-footer a {
  color: #d74c42;
  text-decoration: none;
}
.site-footer a:hover { text-decoration: underline; }
@media (max-width: 900px) {
  .site-header {
    grid-template-columns: 90px minmax(0, 1fr) 90px;
    gap: 14px;
  }
  .header-dragon { max-height: 105px; }
}
@media (max-width: 820px) {
  .site-header { display: block; }
  .header-dragon { display: none; }
  .layout { grid-template-columns: 1fr; }
  .game-column { display: contents; }
  .cabinet { order: 1; width: min(100%, 560px); max-height: none; }
  .player-tools { order: 2; width: min(100%, 560px); }
  .panel { order: 3; margin-top: 0; }
  .fight-controls-card { order: 4; }
  .network-card { order: 5; }
  .history-card { order: 6; }
  .network-card, .history-card { padding: 18px; }
}
@media (max-width: 520px) {
  .shell { width: min(94vw, 460px); padding-top: 18px; }
  .site-header { margin-bottom: 16px; padding-bottom: 14px; }
  .eyebrow { font-size: 10px; letter-spacing: .12em; }
  .layout { gap: 18px; }
  .cabinet { border-width: 8px; }
  .player-tools { grid-template-columns: 1fr; gap: 10px; }
  .volume-control { grid-template-columns: 1fr; gap: 7px; }
  .fullscreen-control { width: 100%; justify-self: stretch; }
  .network-card, .history-card { padding: 16px; }
  .network-card p, .history-card p { font-size: 12px; }
  .network-card .network-lead { font-size: 13px; }
  .history-link { width: 100%; justify-content: center; text-align: center; }
  .ready-board { grid-template-columns: 1fr; }
  .site-footer { width: min(94vw, 460px); margin-top: -42px; }
}

/* Runtime-shell alignment polish without changing mobile intrinsic sizing. */
.runtime-frame {
  width: 100%;
  max-width: 760px;
  min-width: 0;
  margin: 0 auto;
}
.runtime-frame .cabinet {
  width: min(100%, calc(78vh * 3 / 4));
  max-width: 100%;
  min-width: 0;
  margin-left: auto !important;
  margin-right: auto !important;
}
.runtime-frame .player-tools {
  margin-left: auto;
  margin-right: auto;
  max-width: 100%;
  min-width: 0;
}

@media (max-width: 820px) {
  .runtime-frame {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
  }
  .runtime-frame .cabinet {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-height: none;
  }
  .runtime-frame .player-tools {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-left: 0;
    margin-right: 0;
  }
  .runtime-frame .player-tools:not(.touch-controls-active) {
    display: none !important;
  }
  .runtime-frame .player-tools .volume-control,
  .runtime-frame .player-tools .fullscreen-control {
    display: none !important;
  }
}
