:root {
  color-scheme: light;
  --paper: #f5f2e9;
  --ink: #202026;
  --muted: #6e706f;
  --line: rgba(32, 32, 38, .14);
  --accent: #ff6b56;
  --accent-2: #55d5c7;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; scrollbar-gutter: stable; background: var(--paper); }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--paper);
  font-family: ui-rounded, "SF Pro Rounded", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button, a { color: inherit; font: inherit; }
button { border: 0; }
a { text-decoration: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.rw-page {
  position: relative;
  width: min(1480px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 0 42px;
}

.rw-page::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: .12;
  background-image: url("/games/_shared/real-world-equipment.svg");
  background-size: 720px auto;
  pointer-events: none;
}

.rw-nav {
  height: 58px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 14px;
}

.rw-icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .78);
  box-shadow: 0 8px 24px rgba(32, 32, 38, .08);
  cursor: pointer;
  font-weight: 900;
}

.rw-icon-button:disabled { cursor: default; opacity: .38; }
.rw-back { font-size: 22px; }

.rw-brand {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font: 800 11px/1 ui-monospace, monospace;
}

.rw-brand b { color: var(--muted); }
.rw-brand-mark {
  width: 23px;
  height: 23px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
}
.rw-brand-mark i { border-radius: 50%; background: var(--ink); }
.rw-brand-mark i:first-child { background: var(--accent); }
.rw-brand-mark i:last-child { background: var(--accent-2); }

.rw-header {
  min-height: 164px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 480px);
  align-items: end;
  gap: 42px;
  padding: 34px 6px 26px;
}

.rw-eyebrow,
.rw-english,
.rw-section-label,
.rw-overlay-kicker {
  font-family: ui-monospace, "SFMono-Regular", monospace;
  letter-spacing: 0;
  text-transform: uppercase;
}

.rw-eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 10px; font-weight: 900; }
.rw-header h1 { margin: 0; font-size: clamp(36px, 5vw, 68px); line-height: .94; letter-spacing: 0; }
.rw-english { margin: 8px 0 0; color: var(--muted); font-size: 11px; }
.rw-summary { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.75; }

.rw-game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(245px, 320px);
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  box-shadow: 10px 10px 0 var(--ink), 0 24px 70px rgba(32, 32, 38, .14);
}

.rw-stage-panel { min-width: 0; padding: clamp(12px, 2vw, 22px); background: #eeece4; }
.rw-hud { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.rw-stat {
  min-width: 0;
  min-height: 68px;
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 6px;
  color: #fff;
  background: #20242b;
}
.rw-stat span { overflow: hidden; color: rgba(255,255,255,.58); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.rw-stat strong { overflow: hidden; font: 800 clamp(16px, 2vw, 25px)/1 ui-monospace, monospace; text-overflow: ellipsis; white-space: nowrap; }

.rw-canvas-wrap {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 3 / 2;
  border: 2px solid #17191e;
  border-radius: 6px;
  background: #15262b;
  isolation: isolate;
}

#game-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }

.rw-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(13, 18, 21, .78);
  backdrop-filter: blur(9px);
  transition: opacity 180ms ease, visibility 180ms ease;
}
.rw-overlay.hidden { visibility: hidden; opacity: 0; pointer-events: none; }
.rw-overlay-content { width: min(460px, 100%); color: #fff; text-align: center; }
.rw-overlay-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255,255,255,.86);
  border-radius: 50%;
  color: #15191c;
  background: var(--accent);
  box-shadow: 0 0 0 8px rgba(255,255,255,.08);
  font-size: 27px;
  font-weight: 950;
}
.rw-overlay-kicker { margin: 0 0 8px; color: var(--accent-2); font-size: 10px; font-weight: 900; }
.rw-overlay h2 { margin: 0; font-size: clamp(28px, 6vw, 48px); line-height: 1.05; letter-spacing: 0; }
.rw-overlay p:not(.rw-overlay-kicker) { margin: 16px auto 22px; color: rgba(255,255,255,.72); font-size: 13px; line-height: 1.7; }

.rw-primary,
.rw-secondary {
  min-height: 46px;
  padding: 0 20px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  font-weight: 900;
  cursor: pointer;
}
.rw-primary { min-width: 150px; background: var(--accent); box-shadow: 4px 4px 0 #fff; }
.rw-secondary { width: 100%; background: #fff; box-shadow: 3px 3px 0 var(--ink); }
.rw-primary:active, .rw-secondary:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 currentColor; }

.rw-toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 3;
  max-width: calc(100% - 30px);
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,.38);
  border-radius: 6px;
  color: #fff;
  background: rgba(21, 25, 29, .9);
  box-shadow: 0 8px 28px rgba(0,0,0,.2);
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 150ms ease, transform 150ms ease;
  pointer-events: none;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.rw-toast.visible { opacity: 1; transform: translate(-50%, 0); }
.rw-toast[data-tone="good"],
.rw-toast[data-tone="success"] { color: #18241c; background: #b9f5a6; }
.rw-toast[data-tone="warn"] { color: #30250a; background: #ffd76d; }
.rw-toast[data-tone="bad"],
.rw-toast[data-tone="danger"] { background: #b83346; }

.rw-side-panel {
  min-width: 0;
  padding: clamp(20px, 3vw, 30px);
  display: flex;
  flex-direction: column;
  border-left: 2px solid var(--ink);
  background: #fff;
}
.rw-rule-block + .rw-rule-block { margin-top: 28px; }
.rw-section-label { display: block; margin-bottom: 9px; color: var(--accent); font-size: 9px; font-weight: 950; }
.rw-rule-block p, .rw-rule-block ol { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.rw-rule-block ol { padding-left: 18px; }
.rw-rule-block li + li { margin-top: 7px; }
.rw-control-strip { display: flex; flex-wrap: wrap; gap: 7px; margin: 26px 0; }
.rw-control-strip span { padding: 7px 9px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: #f3f2ed; font-size: 10px; font-weight: 800; }
.rw-side-actions { margin-top: auto; padding-top: 18px; }

.rw-missing { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 16px; }
.rw-missing a { padding: 12px 16px; border: 2px solid currentColor; border-radius: 6px; }

@media (max-width: 880px) {
  .rw-page { width: min(100% - 24px, 760px); padding-top: 10px; }
  .rw-header { min-height: 0; display: block; padding: 26px 2px 20px; }
  .rw-summary { margin-top: 16px; }
  .rw-game-shell { grid-template-columns: 1fr; box-shadow: 6px 6px 0 var(--ink); }
  .rw-side-panel { border-top: 2px solid var(--ink); border-left: 0; }
  .rw-side-actions { margin-top: 0; }
}

@media (max-width: 560px) {
  .rw-brand { justify-self: center; }
  .rw-brand > span:last-child { display: none; }
  .rw-header h1 { font-size: 38px; }
  .rw-summary { font-size: 12px; }
  .rw-stage-panel { padding: 8px; }
  .rw-hud { gap: 5px; margin-bottom: 7px; }
  .rw-stat { min-height: 57px; padding: 8px 7px; }
  .rw-stat strong {
    overflow-wrap: anywhere;
    font-size: clamp(12px, 3.7vw, 17px);
    line-height: 1.05;
    text-overflow: clip;
    white-space: normal;
  }
  .rw-stat strong[data-compact="true"] {
    font-size: 12px;
    white-space: nowrap;
  }
  .rw-canvas-wrap { border-width: 1px; }
  .rw-overlay { padding: 14px; }
  .rw-overlay-mark { width: 52px; height: 52px; margin-bottom: 12px; }
  .rw-side-panel { padding: 22px 18px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .rw-page { width: calc(100% - 20px); padding: 6px 0 14px; }
  .rw-nav { height: 44px; }
  .rw-icon-button { width: 38px; height: 38px; }
  .rw-header { min-height: 0; grid-template-columns: 1fr 1fr; padding: 8px 2px 12px; }
  .rw-header h1 { font-size: 30px; }
  .rw-english, .rw-eyebrow { margin-top: 3px; margin-bottom: 3px; }
  .rw-summary { font-size: 11px; line-height: 1.45; }
  .rw-game-shell { grid-template-columns: minmax(0, 1fr) 220px; }
  .rw-stage-panel { padding: 7px; }
  .rw-hud { margin-bottom: 6px; }
  .rw-stat { min-height: 44px; padding: 6px 8px; }
  .rw-stat strong { font-size: 14px; }
  .rw-side-panel { padding: 14px; border-top: 0; border-left: 2px solid var(--ink); }
  .rw-rule-block + .rw-rule-block { margin-top: 12px; }
  .rw-rule-block ol { display: none; }
  .rw-control-strip { margin: 12px 0; }
  .rw-side-actions { padding-top: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
