/* SHADOWFALL - shared look for the game shell and its menus. */
:root {
  --bg: #0b0c0f;
  --ink: #ded8c2;
  --dim: #8b8778;
  --accent: #c8502f;
  --accent-2: #d8b250;
  --panel: rgba(12, 13, 17, 0.93);
  --edge: rgba(180, 160, 110, 0.22);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Courier New", ui-monospace, monospace;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#view, #hud {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}
#view {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
}
#hud { pointer-events: none; }

/* ------------------------------------------------------------- panels */
.panel {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(60, 24, 14, 0.5), transparent 62%),
    var(--panel);
  z-index: 20;
  overflow-y: auto;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + var(--safe-b));
}
.panel.visible { display: flex; }

.panel-inner {
  width: min(430px, 100%);
  text-align: center;
  padding: 8px 4px;
}
.panel-inner.wide { width: min(760px, 100%); }

.logo {
  font-size: clamp(34px, 9vw, 62px);
  letter-spacing: 0.1em;
  margin: 0 0 6px;
  font-weight: 700;
  color: var(--ink);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.55);
}
.logo span { color: var(--accent); }

h2 {
  font-size: clamp(19px, 4.6vw, 27px);
  letter-spacing: 0.14em;
  margin: 0 0 18px;
  color: var(--accent-2);
}
h3 {
  font-size: 14px;
  letter-spacing: 0.1em;
  color: var(--accent-2);
  margin: 0 0 10px;
}
.tagline { color: var(--dim); margin: 0 0 24px; font-size: clamp(11px, 2.8vw, 13px); letter-spacing: 0.05em; }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.foot { margin-top: 26px; font-size: 11px; letter-spacing: 0.06em; }

/* -------------------------------------------------------------- buttons */
.menu-list { display: flex; flex-direction: column; gap: 10px; }

.mbtn {
  appearance: none;
  font: inherit;
  font-size: clamp(13px, 3.4vw, 15px);
  letter-spacing: 0.12em;
  padding: 14px 18px;
  color: var(--ink);
  background: rgba(30, 31, 38, 0.86);
  border: 1px solid var(--edge);
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, transform 0.06s;
  width: 100%;
  min-height: 48px;
}
.mbtn:hover, .mbtn:focus-visible { background: rgba(58, 42, 32, 0.95); outline: none; border-color: rgba(220, 180, 110, 0.5); }
.mbtn:active { transform: translateY(1px); }
.mbtn.primary { background: linear-gradient(180deg, #ab4328, #7d2d1a); border-color: rgba(230, 150, 100, 0.45); }
.mbtn.primary:hover { background: linear-gradient(180deg, #c44f2f, #8f3420); }
.mbtn.ghost { background: transparent; color: var(--dim); margin-top: 16px; }
.mbtn.ghost:hover { color: var(--ink); }
.mbtn[disabled] { opacity: 0.4; cursor: default; }
.mbtn .sub { display: block; font-size: 11px; color: var(--dim); letter-spacing: 0.04em; margin-top: 4px; }

/* -------------------------------------------------------------- loading */
.loadbar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 3px;
  overflow: hidden;
  margin: 24px 0 10px;
}
#loadfill { height: 100%; width: 0%; background: linear-gradient(90deg, #a8402a, #d8b250); transition: width 0.25s; }

/* -------------------------------------------------------------- pairing */
.pair-grid { display: flex; gap: 26px; align-items: center; justify-content: center; flex-wrap: wrap; text-align: left; }
.pair-qr { text-align: center; }
#qr { width: 230px; height: 230px; image-rendering: pixelated; border: 6px solid #e8e4d8; border-radius: 4px; background: #e8e4d8; }
.pair-info { max-width: 330px; font-size: 13px; line-height: 1.65; }
.pair-info p { margin: 0 0 10px; }
.url { color: var(--accent-2); word-break: break-all; font-size: 13px; }
.code {
  font-size: 38px;
  letter-spacing: 0.3em;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--edge);
  border-radius: 4px;
  padding: 8px 4px 8px 14px;
  text-align: center;
  margin: 0 0 10px;
}
#pair-urls { margin: 6px 0 0; padding-left: 18px; }
#pair-urls li { word-break: break-all; }

/* ------------------------------------------------------------- settings */
.settings-grid { display: flex; flex-direction: column; gap: 14px; text-align: left; font-size: 13px; }
.settings-grid label { display: flex; align-items: center; gap: 12px; letter-spacing: 0.05em; }
.settings-grid input[type="range"] { flex: 1; accent-color: var(--accent); min-width: 120px; }
.settings-grid select { font: inherit; background: #1b1d23; color: var(--ink); border: 1px solid var(--edge); padding: 7px; border-radius: 3px; }
.settings-grid output { width: 44px; text-align: right; color: var(--dim); }
.settings-grid input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }

/* ----------------------------------------------------------------- help */
.help-grid { display: flex; gap: 30px; justify-content: center; flex-wrap: wrap; text-align: left; }
.help-grid > div { min-width: 240px; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 12.5px; margin: 0; }
dt { color: var(--accent-2); white-space: nowrap; }
dd { margin: 0; color: var(--dim); }

/* --------------------------------------------------------------- scores */
.scores { width: 100%; border-collapse: collapse; margin: 0 0 22px; font-size: 14px; }
.scores td { padding: 9px 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.scores td:first-child { color: var(--dim); letter-spacing: 0.08em; text-align: left; }
.scores td:last-child { text-align: right; color: var(--accent-2); font-weight: 700; }

/* ------------------------------------------------------- touch controls */
.touch { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.touch.hidden { display: none; }
.touch-left { position: absolute; left: 0; top: 0; bottom: 0; width: 50%; }
.touch-right { position: absolute; right: 0; top: 0; bottom: 0; width: 50%; }

.tbtn {
  position: absolute;
  pointer-events: auto;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: rgba(236, 230, 210, 0.9);
  background: rgba(22, 24, 30, 0.42);
  border: 1.5px solid rgba(220, 200, 150, 0.3);
  border-radius: 50%;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.tbtn.held { background: rgba(170, 70, 40, 0.6); border-color: rgba(255, 190, 140, 0.6); }
.tbtn-fire { width: 96px; height: 96px; right: calc(22px + var(--safe-r)); bottom: calc(96px + var(--safe-b)); font-size: 14px; }
.tbtn-use  { width: 64px; height: 64px; right: calc(128px + var(--safe-r)); bottom: calc(112px + var(--safe-b)); }
.tbtn-next { width: 58px; height: 58px; right: calc(28px + var(--safe-r)); bottom: calc(208px + var(--safe-b)); }
.tbtn-map  { width: 52px; height: 52px; right: calc(104px + var(--safe-r)); bottom: calc(196px + var(--safe-b)); }
.tbtn-pause { width: 44px; height: 44px; right: calc(14px + var(--safe-r)); top: calc(14px + env(safe-area-inset-top, 0px)); font-size: 13px; }

/* the move stick is created on first touch */
.vstick {
  position: absolute;
  width: 148px; height: 148px;
  margin: -74px 0 0 -74px;
  border-radius: 50%;
  border: 1.5px solid rgba(220, 200, 150, 0.22);
  background: rgba(20, 22, 28, 0.3);
  display: none;
  pointer-events: none;
  z-index: 11;
}
.vstick-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 56px; height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: rgba(200, 80, 47, 0.45);
  border: 1.5px solid rgba(255, 190, 150, 0.45);
}

@media (max-width: 520px) {
  .pair-grid { gap: 16px; }
  #qr { width: 190px; height: 190px; }
  .code { font-size: 30px; }
}
@media (max-height: 460px) {
  .logo { font-size: clamp(26px, 7vw, 38px); }
  .tagline { margin-bottom: 12px; }
  .mbtn { padding: 10px 16px; min-height: 42px; }
  .menu-list { gap: 7px; }
}
