:root {
  --bg-night: #0c0d1b;
  --bg-panel: #191d33;
  --bg-panel-alt: #232844;
  --border-dark: #090a14;
  --border-mid: #3a4366;
  --border-light: #56628c;
  --text-cream: #f4ebd9;
  --text-muted: #b6bfd6;
  --camp-orange: #ee7530;
  --camp-orange-hi: #ff9f52;
  --camp-orange-lo: #a94318;
  --camp-gold: #f6c25b;
  --camp-teal: #3f8f7c;
  --camp-teal-hi: #5cb39c;
  --font-ui: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg-night);
  background-image:
    radial-gradient(circle at 50% 0%, #241f49 0%, #111224 58%, #090a14 100%);
  color: var(--text-cream);
  font-family: var(--font-ui);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.camp-shell {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 12px 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Header */
.camp-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 9px 12px;
  background-color: var(--bg-panel);
  border: 2px solid var(--border-mid);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.08),
    inset 0 -2px 0 rgba(0, 0, 0, 0.35),
    0 4px 0 var(--border-dark);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  background-color: var(--camp-orange);
  border: 2px solid #2b1314;
  box-shadow:
    inset 3px 3px 0 var(--camp-orange-hi),
    inset -3px -3px 0 var(--camp-orange-lo),
    0 2px 0 var(--border-dark);
  position: relative;
}

.brand-icon::before,
.brand-icon::after {
  content: "";
  position: absolute;
  background-color: #2b1314;
}

.brand-icon::before {
  left: 11px;
  top: 0;
  bottom: 0;
  width: 2px;
}

.brand-icon::after {
  top: 11px;
  left: 0;
  right: 0;
  height: 2px;
}

.brand-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-zh {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text-cream);
  line-height: 1.15;
}

.brand-en {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--camp-gold);
  line-height: 1.2;
}

.header-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.mode-switch,
.utility-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pixel-btn {
  appearance: none;
  border: 2px solid var(--border-light);
  background-color: var(--bg-panel-alt);
  color: var(--text-cream);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 11px;
  min-height: 36px;
  cursor: pointer;
  letter-spacing: 0.03em;
  white-space: nowrap;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.12),
    inset 0 -2px 0 rgba(0, 0, 0, 0.35),
    0 2px 0 var(--border-dark);
  transition: transform 0.06s steps(2), background-color 0.1s ease;
}

.pixel-btn:hover {
  background-color: #2f365a;
}

.pixel-btn:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 2px 0 rgba(0, 0, 0, 0.3),
    0 0 0 var(--border-dark);
}

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

.mode-btn.is-active {
  background-color: var(--camp-teal);
  border-color: var(--camp-teal-hi);
  color: #ffffff;
}

.btn-accent {
  background-color: var(--camp-orange);
  border-color: var(--camp-orange-hi);
  color: #fffaf0;
}

.btn-accent:hover {
  background-color: #f68440;
}

.util-btn.is-muted {
  color: var(--text-muted);
  border-color: var(--border-mid);
  background-color: #16192c;
}

/* Scoreboard */
.scoreboard-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stat-cell {
  background-color: var(--bg-panel);
  border: 2px solid var(--border-mid);
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.06),
    0 3px 0 var(--border-dark);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.stat-value {
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text-cream);
  line-height: 1.2;
}

.stat-streak {
  color: var(--camp-orange-hi);
}

.stat-best {
  color: var(--camp-gold);
}

.stat-cell.is-urgent {
  border-color: #e45d4a;
  background-color: #2c1726;
}

.stat-cell.is-urgent .stat-value {
  color: #ff8e72;
}

/* Game Stage */
.stage-frame {
  position: relative;
  width: 100%;
  background-color: #101028;
  border: 3px solid var(--border-mid);
  box-shadow:
    inset 0 0 0 2px var(--border-dark),
    0 6px 0 var(--border-dark);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 400 / 240;
  image-rendering: -moz-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}

#game-canvas.is-mobile-ratio {
  aspect-ratio: 260 / 300;
}

/* Round Summary Modal */
.round-modal {
  position: absolute;
  inset: 0;
  background-color: rgba(11, 12, 26, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 5;
}

.round-modal[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 340px;
  background-color: var(--bg-panel);
  border: 3px solid var(--camp-gold);
  padding: 14px 16px;
  text-align: center;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.12),
    0 6px 0 var(--border-dark);
}

.modal-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #1a1210;
  background-color: var(--camp-gold);
  padding: 2px 8px;
  margin-bottom: 6px;
}

.modal-title {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 800;
  color: var(--text-cream);
}

.modal-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.modal-stat {
  background-color: var(--bg-panel-alt);
  border: 2px solid var(--border-mid);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-stat-k {
  font-size: 11px;
  color: var(--text-muted);
}

.modal-stat-v {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-cream);
  font-variant-numeric: tabular-nums;
}

.modal-record {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 800;
  color: var(--camp-gold);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.modal-actions .pixel-btn {
  flex: 1 1 120px;
}

/* Guide strip */
.guide-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  background-color: var(--bg-panel);
  border: 2px solid var(--border-mid);
  padding: 9px 12px;
  box-shadow: 0 4px 0 var(--border-dark);
}

.guide-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.guide-tag {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 6px;
  background-color: var(--camp-teal);
  color: #ffffff;
  border: 1px solid var(--camp-teal-hi);
  margin-top: 1px;
}

.guide-tag-gold {
  background-color: var(--camp-orange);
  border-color: var(--camp-orange-hi);
}

.guide-text {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

.guide-text strong {
  color: var(--text-cream);
}

/* Mobile 390px and narrow screens */
@media (max-width: 599px) {
  .camp-shell {
    padding: 8px 8px 14px;
    gap: 8px;
  }

  .camp-header {
    padding: 8px 10px;
    gap: 8px;
  }

  .brand-zh {
    font-size: 15px;
  }

  .brand-en {
    font-size: 10px;
  }

  .header-controls {
    width: 100%;
    justify-content: space-between;
    gap: 6px;
  }

  .pixel-btn {
    font-size: 12px;
    padding: 6px 9px;
    min-height: 36px;
  }

  .scoreboard-bar {
    gap: 5px;
  }

  .stat-cell {
    padding: 5px 4px;
  }

  .stat-label {
    font-size: 10px;
  }

  .stat-value {
    font-size: 17px;
  }

  .guide-panel {
    grid-template-columns: 1fr;
    padding: 8px 10px;
    gap: 6px;
  }
}

@media (max-width: 370px) {
  .pixel-btn {
    padding: 5px 7px;
    font-size: 12px;
  }

  .header-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .mode-switch,
  .utility-btns {
    width: 100%;
  }

  .mode-switch .pixel-btn,
  .utility-btns .pixel-btn {
    flex: 1;
    text-align: center;
  }
}
