:root {
  --paper: #FFFFFF;
  --cream: #FFF7D6;
  --yellow: #FFD43B;
  --ink: #211F17;
  --brown: #5C5133;
  --orange: #F28C28;
  --blue: #064F67;
  --focus: #004E89;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  touch-action: none;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.topbar {
  position: absolute;
  top: 14px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.wordmark {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
  background: var(--yellow);
  color: var(--ink);
  border: 2px solid var(--ink);
  padding: 5px 10px;
  text-decoration: none;
}

.zone-badge {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  background: var(--cream);
  color: var(--ink);
  border: 2px solid var(--ink);
  padding: 5px 10px;
}

.controls-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  pointer-events: auto;
}

.btn {
  appearance: none;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid transparent;
  padding: 5px 8px;
  cursor: pointer;
  line-height: 1.2;
}

.btn:hover {
  background: rgba(33, 31, 23, 0.08);
}

.btn.active {
  background: var(--yellow);
  border-color: var(--ink);
}

.btn.solid {
  background: var(--cream);
  border: 2px solid var(--ink);
  padding: 6px 10px;
}

.nav-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.btn.primary {
  background: var(--yellow);
  border: 2px solid var(--ink);
  padding: 10px 18px;
  font-size: 14px;
}

.btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Center crosshair reticle */
.reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: var(--ink);
  opacity: 0.55;
  transition: transform 0.12s ease, background-color 0.12s ease;
}

.reticle.focused {
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  background: transparent;
  border: 2px solid var(--ink);
  box-shadow: 0 0 0 2px var(--yellow);
  opacity: 1;
}

/* Interaction prompt */
.prompt {
  position: absolute;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--cream);
  color: var(--ink);
  border: 2px solid var(--ink);
  padding: 8px 14px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.prompt[hidden] {
  display: none;
}

.prompt-key {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  background: var(--yellow);
  border: 1.5px solid var(--ink);
  font-size: 12px;
}

/* Dialogue card */
.dialogue {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px));
  background: var(--cream);
  border: 2px solid var(--ink);
  padding: 16px 18px;
  pointer-events: auto;
}

.dialogue[hidden] {
  display: none;
}

.dialogue-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.dialogue-speaker {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  background: var(--yellow);
  border: 1.5px solid var(--ink);
  padding: 2px 8px;
}

.dialogue-step {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--brown);
}

.dialogue-text {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
}

.dialogue-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Welcome / pause overlay */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(255, 253, 246, 0.56);
  pointer-events: auto;
}

.overlay[hidden] {
  display: none;
}

.card {
  width: min(460px, 100%);
  background: var(--cream);
  border: 2px solid var(--ink);
  padding: 22px 24px;
}

.card h1 {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: clamp(22px, 4vw, 28px);
  line-height: 1.2;
}

.card p {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--brown);
}

.keys-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 18px;
  font-family: var(--mono);
  font-size: 12px;
}

.keys-grid div {
  background: var(--paper);
  border: 1.5px solid var(--ink);
  padding: 6px 8px;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.status-note {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--brown);
}

/* Status hint strip at bottom-left on desktop */
.hint-strip {
  position: absolute;
  left: 16px;
  bottom: 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--brown);
  background: rgba(255, 247, 214, 0.9);
  border: 1.5px solid var(--ink);
  padding: 4px 8px;
}

/* Mobile touch controls */
.touch-controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 12;
  display: none;
}

.touch-controls.active {
  display: block;
}

.joystick {
  position: absolute;
  left: 20px;
  bottom: 24px;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: rgba(255, 247, 214, 0.72);
  border: 2px solid var(--ink);
  pointer-events: auto;
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: var(--yellow);
  border: 2px solid var(--ink);
}

.touch-actions {
  position: absolute;
  right: 20px;
  bottom: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: auto;
}

.touch-btn {
  min-width: 64px;
  min-height: 48px;
  padding: 8px 14px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  background: var(--yellow);
  color: var(--ink);
  border: 2px solid var(--ink);
}

.touch-btn.secondary {
  background: var(--cream);
}

@media (max-width: 720px) {
  .topbar {
    top: 10px;
    left: 10px;
    right: 10px;
  }
  .btn {
    min-height: 36px;
  }
  .hint-strip {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reticle {
    transition: none;
  }
}
