:root {
  --bg-app: #252836;
  --bg-canvas: #2b3038;
  --floor-a: #f3e9dc;
  --floor-b: #e8ddd0;
  --floor-lobby: #c45c3e;
  --text-floor: #2d3142;
  --line-floor: #8a7f72;
  --shaft-line: #5c5348;
  --shaft-bg: #3d4450;
  --passenger-up: #2a9d8f;
  --passenger-down: #e76f51;
  --warn: #c0392b;
  --text: #f5ebe0;
  --text-muted: #c9bfb3;
  --panel-bg: #2d3142;
  --border: #4a5060;
  --accent: #2a9d8f;
  --touch-min: 44px;
  color-scheme: dark;
}

html.high-contrast {
  --line-floor: #fff;
  --text-muted: #fff;
}

html.reduced-motion * {
  animation: none !important;
  transition: none !important;
}

.screen-game {
  background: var(--bg-app);
}

.game-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}

.hud {
  flex: 0 0 auto;
  padding: env(safe-area-inset-top, 6px) 10px 8px;
  background: linear-gradient(180deg, #c24a2a 0%, #a83f24 100%);
  color: #fff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
}

.hud-top {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.hud-title-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.hud-building {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-time {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  opacity: 0.9;
}

.hud-stats {
  display: grid;
  gap: 2px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
}

.hud-stat .label {
  display: block;
  opacity: 0.75;
  font-size: 9px;
  letter-spacing: 0.06em;
}

.hud-gauge {
  position: relative;
  width: 52px;
  height: 52px;
  text-align: center;
}

.gauge-svg {
  width: 52px;
  height: 52px;
  transform: rotate(-90deg);
}

.gauge-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 4;
}

.gauge-fill {
  fill: none;
  stroke: #9ef0c5;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 0 113;
  transition: stroke-dasharray 0.4s ease;
}

.gauge-text {
  position: absolute;
  inset: 14px 0 auto;
  font-size: 11px;
  font-weight: 700;
}

.gauge-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  font-size: 8px;
  letter-spacing: 0.08em;
  opacity: 0.85;
}

.hud-stress .gauge-fill {
  stroke: #ffb4a2;
}

.hud-stress .hud-stat span:last-child {
  color: #ffd5cc;
}

.hud-rush {
  margin-top: 6px;
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.12em;
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
}

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

.controls {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0));
  background: #1f2230;
  border-top: 1px solid var(--border);
}

.ctrl-btn {
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #343848;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}

.ctrl-speed[aria-pressed='true'] {
  background: var(--accent);
  color: #102820;
  border-color: transparent;
}

.ctrl-muted {
  font-size: 10px;
  font-family: 'IBM Plex Mono', monospace;
  min-width: 38px;
}

.speed-group {
  display: flex;
  gap: 4px;
}

.day-timeline {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.tl-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  color: var(--text-muted);
}

.tl-track {
  height: 8px;
  border-radius: 999px;
  background: #343848;
  overflow: hidden;
}

.tl-track i {
  display: block;
  height: 100%;
  width: var(--day-progress, 0%);
  background: linear-gradient(90deg, #2a9d8f, #e9c46a);
  border-radius: inherit;
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 72%;
  overflow: auto;
  background: #f5ebe0;
  color: var(--brand-ink, #2d3142);
  border-radius: 16px 16px 0 0;
  padding: 14px 14px calc(16px + env(safe-area-inset-bottom, 0));
  z-index: 12;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
}

.sheet[hidden] {
  display: none !important;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.sheet-kicker {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: #7a6a62;
}

.sheet-header h2,
.sheet-header + h2 {
  margin: 4px 0 0;
  font-size: 18px;
}

.sheet-sub {
  margin: 12px 0 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5c6478;
}

.panel-close {
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  border: none;
  background: transparent;
  color: inherit;
  font-size: 28px;
  line-height: 1;
}

.floor-hero {
  text-align: center;
  padding: 8px 0;
}

.people-icons {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 8px;
}

.person-icon {
  width: 8px;
  height: 16px;
  border-radius: 3px 3px 1px 1px;
  background: #e76f51;
  display: inline-block;
}

.floor-dir {
  color: #5c6478;
  font-size: 13px;
}

.dest-list {
  display: grid;
  gap: 6px;
}

.dest-row {
  display: grid;
  grid-template-columns: 28px 1fr 24px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.dest-bar {
  height: 8px;
  background: #ddd3c8;
  border-radius: 999px;
  overflow: hidden;
}

.dest-bar i {
  display: block;
  height: 100%;
  background: #2a9d8f;
  border-radius: inherit;
}

.lift-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}

.lift-stats div {
  background: #fff;
  border: 1px solid #ddd3c8;
  border-radius: 8px;
  padding: 8px;
}

.lift-stats dt {
  font-size: 10px;
  color: #7a6a62;
  letter-spacing: 0.06em;
}

.lift-stats dd {
  margin: 4px 0 0;
  font-weight: 600;
}

.load-bar-wrap {
  margin-top: 10px;
  font-size: 12px;
}

.load-bar {
  margin-top: 4px;
  height: 10px;
  background: #ddd3c8;
  border-radius: 999px;
  overflow: hidden;
}

.load-bar i {
  display: block;
  height: 100%;
  background: #c24a2a;
}

.floor-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.floor-chip {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid #cbbfb3;
  background: #fff;
  font-weight: 600;
  cursor: pointer;
}

.floor-chip.is-on {
  background: #2a9d8f;
  color: #fff;
  border-color: #238276;
}

.btn-express {
  width: 100%;
  margin-top: 12px;
  min-height: var(--touch-min);
  border: none;
  border-radius: 8px;
  background: #343848;
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 16px;
}

.overlay:not([hidden]) {
  display: flex;
}

.overlay-pause {
  background: rgba(15, 17, 24, 0.82);
}

.overlay-results {
  background: rgba(15, 17, 24, 0.88);
}

.pause-card {
  width: min(100%, 320px);
  display: grid;
  gap: 10px;
}

.pause-card h2 {
  margin: 0 0 8px;
  text-align: center;
  color: #fff;
  letter-spacing: 0.12em;
}

.results-card-rich {
  background: #f5ebe0;
  color: #2d3142;
  border-radius: 14px;
  padding: 20px 16px;
  width: min(100%, 360px);
  text-align: center;
}

.results-kicker {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: #7a6a62;
}

.results-gauge-big {
  margin: 12px 0;
}

.results-pct {
  display: block;
  font-size: 42px;
  font-weight: 700;
  line-height: 1;
  color: #c24a2a;
}

.results-gauge-label {
  font-size: 11px;
  letter-spacing: 0.1em;
}

.results-stats {
  margin: 12px 0;
  display: grid;
  gap: 6px;
  text-align: left;
}

.results-stats div {
  display: flex;
  justify-content: space-between;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
}

.text-bad {
  color: #c0392b;
  font-weight: 700;
}

.results-stars {
  font-size: 26px;
  color: #2a9d8f;
  letter-spacing: 4px;
}

.muted {
  color: #7a6a62;
  font-size: 13px;
}
