:root {
  --background: #fdf9ed;
  --surface: #fffdf6;
  --surface-low: #f3eee2;
  --surface-high: #e6e2d6;
  --surface-ink: #1a1a1a;
  --text: #1d1c15;
  --muted: #68685f;
  --outline: #76786e;
  --outline-soft: #c6c7bc;
  --primary: #5f6b4e;
  --primary-deep: #3f4a30;
  --secondary: #9a5632;
  --secondary-soft: #ffdcbd;
  --danger: #ba1a1a;
  --success: #3f7d48;
  --warning: #f0bd8b;
  --accent: #5f6b4e;
  --line-color: #9a5632;
  --music-pulse: 1;
  --music-beat: 0;
  --pin-size-scale: 0.8;
  --shadow-sm: 4px 4px 0 var(--surface-ink);
  --shadow: 6px 6px 0 var(--surface-ink);
  --shadow-lg: 10px 10px 0 var(--surface-ink);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  max-width: 100vw;
  color: var(--text);
  font-family: 'Space Grotesk', Inter, Arial, sans-serif;
  background-color: var(--background);
  background-image: radial-gradient(var(--outline-soft) 1px, transparent 1px);
  background-size: 18px 18px;
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

body.streak-low {
  box-shadow: inset 0 0 0 8px rgba(95, 107, 78, 0.12);
}

body.streak-mid {
  box-shadow: inset 0 0 0 10px rgba(154, 86, 50, 0.18);
}

body.streak-high {
  box-shadow: inset 0 0 0 12px rgba(186, 26, 26, 0.18);
}

.app-shell {
  min-height: 100vh;
  display: flex;
}

.mobile-header {
  display: none;
}

.side-nav {
  width: 288px;
  height: 100vh;
  flex: 0 0 288px;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-right: 4px solid var(--surface-ink);
  box-shadow: 6px 0 0 var(--surface-ink);
  z-index: 1200;
}

.sidebar-menu {
  padding: 16px;
  background: #ffffff;
  border-bottom: 4px solid var(--surface-ink);
}

.sidebar-menu-toggle {
  width: 100%;
  min-height: 54px;
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface-low);
  border: 3px solid var(--surface-ink);
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.sidebar-menu-toggle:hover {
  background: var(--surface);
}

.sidebar-menu-label {
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.sidebar-menu-hint {
  min-width: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.1;
  text-align: right;
  text-transform: uppercase;
}

.sidebar-menu-caret {
  transition: transform 120ms ease;
}

.sidebar-menu-toggle[aria-expanded="true"] .sidebar-menu-caret {
  transform: rotate(180deg);
}

.sidebar-menu-panel {
  display: grid;
  gap: 14px;
  padding-top: 14px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-8px);
  transform-origin: top;
  transition: max-height 190ms ease, opacity 160ms ease, transform 190ms ease, padding-top 190ms ease;
  will-change: max-height, opacity, transform;
}

.sidebar-menu-panel[hidden] {
  display: none;
}

.sidebar-menu.is-open .sidebar-menu-panel {
  max-height: min(78vh, 760px);
  opacity: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateY(0);
}

.sidebar-menu-panel .app-panel,
.target-list-context,
.sidebar-menu-panel .progress-panel,
.sidebar-menu-panel .mode-menu,
.sidebar-menu-panel .mistakes-panel,
.sidebar-menu-panel .gameplay-settings-panel,
.sidebar-menu-panel .sidebar-bottom {
  padding: 12px;
  background: #ffffff;
  border: 3px solid var(--surface-ink);
  box-shadow: var(--shadow-sm);
}

.sidebar-menu-panel .app-panel {
  border-bottom: 3px solid var(--surface-ink);
}

.sidebar-menu-panel .mode-menu {
  border-bottom: 3px solid var(--surface-ink);
}

.sidebar-menu-panel .progress-panel {
  border-bottom: 3px solid var(--surface-ink);
}

.sidebar-menu-panel .mistakes-panel {
  border-bottom: 3px solid var(--surface-ink);
}

.sidebar-menu-panel .sidebar-bottom {
  margin-top: 0;
}

.app-panel {
  padding: 24px 20px 18px;
  border-bottom: 4px solid var(--surface-ink);
}

.app-panel h1 {
  margin: 0 0 14px;
  font-size: 22px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: 0;
}

.mode-menu,
.sidebar-bottom {
  padding: 18px 16px;
}

.app-panel p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
  font-weight: 800;
  text-transform: uppercase;
}

.best-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-low);
  border: 3px solid var(--surface-ink);
  box-shadow: var(--shadow-sm);
}

.best-score span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.best-score b {
  color: var(--primary);
  font-size: 22px;
  line-height: 1;
}

.mode-menu {
  display: grid;
  gap: 12px;
  border-bottom: 4px solid var(--surface-ink);
}

.mode-btn,
.nav-item,
.btn {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  color: var(--text);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.mode-btn,
.nav-item {
  justify-content: flex-start;
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  border: 2px solid transparent;
}

.mode-btn:hover,
.nav-item:hover {
  background: var(--surface-low);
  border-color: var(--surface-ink);
}

.mode-btn.active {
  background: var(--primary);
  color: #ffffff;
  border: 2px solid var(--surface-ink);
  box-shadow: var(--shadow-sm);
}

.btn {
  padding: 14px 18px;
  border: 4px solid var(--surface-ink);
  box-shadow: var(--shadow);
  background: var(--surface);
  text-align: center;
  text-transform: uppercase;
}

.btn:hover,
.mode-btn.active:hover {
  transform: translate(4px, 4px);
  box-shadow: none;
}

.answer-panel {
  min-height: 0;
  flex: 1;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  border-bottom: 4px solid var(--surface-ink);
}

.target-sheet-toggle {
  display: none;
}

.target-sheet-body {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: max-height 190ms ease, opacity 160ms ease, transform 190ms ease, padding 190ms ease, border-width 190ms ease;
  will-change: max-height, opacity, transform;
}

.target-count {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-align: right;
  text-transform: uppercase;
}

.target-sheet-caret {
  transition: transform 120ms ease;
}

.target-sheet.is-open .target-sheet-caret {
  transform: rotate(180deg);
}

.target-list-context h2,
.mistakes-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.target-list-context p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  font-weight: 700;
}

.question-mode-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.question-mode-btn {
  min-height: 36px;
  padding: 7px 8px;
  color: var(--text);
  background: var(--surface-low);
  border: 2px solid var(--surface-ink);
  box-shadow: 3px 3px 0 var(--surface-ink);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.question-mode-btn:hover,
.question-mode-btn.active {
  color: #ffffff;
  background: var(--primary);
}

.question-mode-btn:hover {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--surface-ink);
}

.question-mode-btn.active {
  box-shadow: none;
  transform: translate(3px, 3px);
}

.name-pool {
  min-height: 0;
  overflow-y: auto;
  padding: 4px 6px 10px 0;
}

.name-item {
  width: 100%;
  min-height: 46px;
  margin: 0 0 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text);
  background: #ffffff;
  border: 3px solid var(--surface-ink);
  box-shadow: var(--shadow-sm);
  text-align: left;
  font-weight: 800;
  line-height: 1.18;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.name-item:hover {
  transform: translate(3px, 3px);
  box-shadow: none;
}

.name-item.selected {
  color: #ffffff;
  background: var(--primary);
}

.name-item.matched {
  opacity: 0.45;
  pointer-events: none;
  text-decoration: line-through;
  background: var(--surface-high);
  box-shadow: none;
}

.name-item small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: right;
  overflow-wrap: anywhere;
}

.name-item.selected small {
  color: #ffffff;
}

.mistakes-panel {
  display: none;
  padding: 14px 16px;
  background: #fff0ee;
  border-bottom: 4px solid var(--surface-ink);
}

.mistakes-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mistake-tag {
  padding: 5px 7px;
  color: #ffffff;
  background: var(--danger);
  border: 2px solid var(--surface-ink);
  font-size: 11px;
  font-weight: 800;
}

.progress-panel {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  background: #ffffff;
  border-bottom: 4px solid var(--surface-ink);
}

.progress-panel-header,
.progress-profile,
.progress-xp,
.progress-cta-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.progress-panel h2,
.progress-panel h3 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.progress-level-pill {
  padding: 5px 8px;
  color: #ffffff;
  background: var(--primary);
  border: 2px solid var(--surface-ink);
  box-shadow: 2px 2px 0 var(--surface-ink);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.progress-profile {
  justify-content: flex-start;
  padding: 8px;
  color: var(--muted);
  background: var(--surface-low);
  border: 2px solid var(--surface-ink);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.progress-avatar-img,
.leaderboard-avatar,
.avatar-option img {
  width: 32px;
  height: 32px;
  display: block;
  object-fit: cover;
  background: var(--surface);
  border: 2px solid var(--surface-ink);
}

.progress-xp {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
}

.progress-xp span {
  color: var(--text);
}

.progress-level-track,
.progress-cta-track {
  height: 14px;
  overflow: hidden;
  background: var(--surface-low);
  border: 2px solid var(--surface-ink);
}

.progress-level-fill,
.progress-cta-fill {
  width: 0%;
  height: 100%;
  display: block;
  background: var(--success);
  transition: width 220ms ease;
}

.progress-stats {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.progress-stat {
  min-width: 0;
  padding: 8px;
  background: var(--surface-low);
  border: 2px solid var(--surface-ink);
}

.progress-stat dt {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
}

.progress-stat dd {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.progress-weak-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  list-style: none;
}

.progress-weak-list li {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  color: var(--text);
  background: #fff0ee;
  border: 2px solid var(--surface-ink);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.15;
}

.progress-weak-list span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.progress-weak-list b {
  color: var(--danger);
  font-size: 10px;
  white-space: nowrap;
}

.progress-goal {
  margin: 0;
  padding: 8px;
  color: var(--muted);
  background: var(--surface-low);
  border: 2px dashed var(--outline);
  font-size: 11px;
  font-weight: 800;
}

.sidebar-bottom {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.pin-settings-panel {
  display: grid;
  gap: 9px;
  padding: 10px;
  background: var(--surface-low);
  border: 3px solid var(--surface-ink);
  box-shadow: var(--shadow-sm);
}

.gameplay-settings-panel {
  display: grid;
  gap: 9px;
  padding: 10px;
  background: var(--surface-low);
  border: 3px solid var(--surface-ink);
  box-shadow: var(--shadow-sm);
}

.settings-title {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.settings-row-checkbox {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.settings-row select {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 5px 7px;
  color: var(--text);
  background: #ffffff;
  border: 2px solid var(--surface-ink);
  font: inherit;
  font-size: 11px;
  font-weight: 800;
}

.settings-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--primary);
}

.pin-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pin-size-label,
.pin-size-value {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.pin-size-value {
  color: var(--text);
}

.pin-size-slider {
  width: 100%;
  min-width: 0;
  accent-color: var(--primary);
}

.music-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px;
  background: var(--surface-low);
  border: 3px solid var(--surface-ink);
  box-shadow: var(--shadow-sm);
}

.music-select-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.music-track-select {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 6px 8px;
  color: var(--text);
  background: #ffffff;
  border: 2px solid var(--surface-ink);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

.btn-music-toggle {
  min-height: 38px;
  padding: 8px 10px;
  border-width: 3px;
  box-shadow: 3px 3px 0 var(--surface-ink);
  font-size: 12px;
}

.music-panel-mobile {
  display: none;
}

.btn-side {
  min-height: 44px;
  justify-content: flex-start;
  padding: 10px 14px;
  background: var(--surface);
  border-width: 2px;
  box-shadow: var(--shadow-sm);
  text-transform: none;
}

.ownership-mark {
  padding-top: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.ownership-mark a {
  color: var(--primary);
  font-weight: 900;
}

.game-main {
  min-width: 0;
  height: 100vh;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
}

.objective-bar {
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  background-color: var(--surface);
  background-image:
    linear-gradient(45deg, rgba(198, 199, 188, 0.5) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(198, 199, 188, 0.5) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(198, 199, 188, 0.5) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(198, 199, 188, 0.5) 75%);
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
  background-size: 8px 8px;
  border: 4px solid var(--surface-ink);
  box-shadow: var(--shadow);
}

.target-card {
  min-width: min(100%, 330px);
  max-width: 680px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  background: #ffffff;
  border: 4px solid var(--surface-ink);
  box-shadow: var(--shadow-sm);
}

.target-label {
  color: var(--primary-deep);
  font-size: 18px;
  font-weight: 800;
}

.target-card strong {
  flex: 1;
  min-width: 0;
  color: var(--surface-ink);
  font-size: clamp(20px, 3vw, 32px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.1;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.target-card .icon-symbol,
.target-card .material-symbols-outlined {
  color: #b89483;
  font-size: 38px;
}

.hud-stats {
  display: flex;
  align-items: stretch;
  gap: 12px;
}

.hud-card {
  min-width: 88px;
  padding: 11px 13px;
  display: grid;
  place-items: center;
  background: var(--surface-low);
  border: 3px solid var(--surface-ink);
  box-shadow: var(--shadow-sm);
}

.hud-card span:first-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.hud-card strong {
  color: var(--text);
  font-size: 21px;
  line-height: 1;
}

.hud-card-life {
  background: var(--secondary-soft);
}

.heart-row {
  display: flex;
  gap: 4px;
}

.heart {
  color: var(--danger);
  font-size: 25px;
  line-height: 1;
  font-weight: 900;
}

.heart:not(.filled) {
  color: var(--primary-deep);
}

.map-stage {
  position: relative;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  background: var(--surface-low);
  border: 4px solid var(--surface-ink);
  box-shadow: var(--shadow);
}

.map-stage-texture {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.18;
  background-image: repeating-linear-gradient(45deg, var(--surface-ink) 0, var(--surface-ink) 2px, transparent 2px, transparent 10px);
  mix-blend-mode: multiply;
}

#map {
  position: absolute;
  inset: 16px;
  z-index: 1;
  width: auto;
  height: auto;
  background: #f7f1df;
  border: 4px solid var(--surface-ink);
  box-shadow: var(--shadow-sm);
}

.map-controls {
  position: absolute;
  top: 28px;
  left: 28px;
  right: 28px;
  z-index: 1200;
  height: 44px;
  pointer-events: none;
}

.map-control-btn {
  position: absolute;
  top: 0;
  width: 44px;
  height: 44px;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--text);
  background: #ffffff;
  border: 3px solid var(--surface-ink);
  box-shadow: 3px 3px 0 var(--surface-ink);
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
}

.map-zoom-in {
  left: 0;
}

.map-zoom-out {
  left: 54px;
}

.map-focus-toggle {
  right: 0;
}

.map-hint-toggle {
  left: 108px;
  width: auto;
  min-width: 132px;
  grid-template-columns: auto 1fr;
  gap: 6px;
  padding: 0 10px;
}

.map-hint-toggle[hidden] {
  display: none;
}

.map-control-label {
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.map-control-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--surface-ink);
}

.map-control-btn .icon-symbol {
  font-size: 19px;
}

.leaflet-container {
  font-family: 'Space Grotesk', Inter, Arial, sans-serif;
  background: #f7f1df;
}

.leaflet-tile-pane {
  filter: saturate(0.45) sepia(0.18) contrast(1.05) brightness(1.12);
}

.leaflet-interactive {
  outline: none;
}

.pin {
  --pin-visual-size: 28px;
  position: absolute;
  background: transparent;
  border: 0;
  box-shadow: none;
  transform: none;
}

.pin::after {
  content: "";
  position: absolute;
  width: calc(var(--pin-visual-size) * var(--pin-size-scale));
  height: calc(var(--pin-visual-size) * var(--pin-size-scale));
  left: 50%;
  top: 50%;
  background: #fffdf6;
  border: 4px solid var(--surface-ink);
  box-shadow: 4px 4px 0 rgba(26, 26, 26, 0.92);
  transform: translate(-50%, -50%) rotate(2deg) scale(var(--music-pulse));
  transition: box-shadow 80ms linear, transform 80ms linear;
}

.pin::before {
  content: "";
  position: absolute;
  width: calc(8px * var(--pin-size-scale));
  height: calc(8px * var(--pin-size-scale));
  left: 50%;
  top: 50%;
  z-index: 1;
  background: var(--primary);
  border: 2px solid var(--primary-deep);
  transform: translate(-50%, -50%) rotate(2deg) scale(calc(1 + (var(--music-beat) * 0.32)));
}

.pin.matched {
  background: transparent;
}

.pin.matched::after {
  background: #ffffff;
  border-color: var(--success);
}

.pin.matched::before {
  background: var(--success);
}

.city-label {
  border: 0;
  background: transparent;
}

.city-label span {
  display: inline-block;
  padding: 2px 5px;
  color: rgba(26, 26, 26, 0.55);
  background: rgba(253, 249, 237, 0.52);
  border: 1px solid rgba(26, 26, 26, 0.12);
  font-size: 11px;
  line-height: 1;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.feature-label {
  max-width: 180px;
  padding: 6px 8px;
  color: #ffffff;
  background: var(--surface-ink);
  border: 3px solid #ffffff;
  box-shadow: var(--shadow-sm);
  white-space: normal;
  line-height: 1.2;
  font-size: 11px;
  font-weight: 900;
}

.feature-label.correct {
  color: #ffffff;
  background: var(--success);
}

.feature-label.incorrect {
  color: #ffffff;
  background: var(--danger);
}

#svg-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 900;
}

.connection-line {
  stroke: var(--line-color);
  stroke-width: 4;
  stroke-dasharray: 10;
  fill: none;
  animation: dash 1s linear infinite;
}

@media (pointer: coarse), (max-width: 640px), (max-width: 1280px) and (orientation: landscape) and (max-height: 700px) {
  .connection-line {
    display: none !important;
  }
}

.leaflet-tile,
.leaflet-zoom-animated,
.leaflet-marker-icon,
.pin {
  backface-visibility: hidden;
  transform: translateZ(0);
  will-change: transform;
}

@keyframes dash {
  to {
    stroke-dashoffset: -20;
  }
}

.pixi-effects-layer,
.dom-effects-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1002;
}

.pixi-runtime-status {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 1005;
  display: none;
  padding: 6px 8px;
  color: var(--primary);
  background: var(--surface);
  border: 2px solid var(--surface-ink);
  box-shadow: 3px 3px 0 var(--surface-ink);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  pointer-events: none;
}

body.kpss-debug .pixi-runtime-status {
  display: block;
}

.pixi-runtime-status.fallback {
  color: var(--secondary);
}

.pixi-runtime-status.off {
  color: var(--muted);
}

.map-effect-stamp {
  position: absolute;
  transform: translate(-50%, -50%) scale(0.7);
  padding: 10px 14px;
  border: 4px solid #ffffff;
  color: #ffffff;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: var(--shadow);
  animation: stamp-pop 900ms ease-out forwards;
  white-space: nowrap;
}

.map-effect-stamp.success {
  background: var(--success);
}

.map-effect-stamp.danger {
  background: var(--danger);
}

@keyframes stamp-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.35) rotate(-8deg);
  }

  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15) rotate(3deg);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -90%) scale(0.9) rotate(0deg);
  }
}

.footer-actions {
  min-height: 78px;
  display: grid;
  grid-template-columns: 1fr 2fr 1fr 1fr;
  gap: 20px;
}

.footer-actions.answer-reveal-disabled {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.btn-reset {
  background: var(--surface-low);
}

.btn-reveal {
  color: #ffffff;
  background: var(--primary);
}

.btn-home {
  color: #ffffff;
  background: var(--secondary);
}

.pixi-prototype-body {
  min-height: 100vh;
  overflow: hidden;
}

.pixi-prototype-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  overflow: hidden;
}

.pixi-prototype-panel {
  height: 100vh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px 20px;
  background: #ffffff;
  border-right: 4px solid var(--surface-ink);
  box-shadow: 6px 0 0 var(--surface-ink);
  z-index: 2;
}

.pixi-back-link,
.pixi-actions button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  background: var(--surface-low);
  border: 3px solid var(--surface-ink);
  box-shadow: var(--shadow-sm);
  font-weight: 900;
}

.pixi-kicker {
  margin: 0;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.pixi-prototype-panel h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1;
  font-weight: 900;
  text-transform: uppercase;
}

.pixi-copy {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 800;
}

.pixi-target-card,
.pixi-stats {
  padding: 12px;
  background: var(--surface-low);
  border: 3px solid var(--surface-ink);
  box-shadow: var(--shadow-sm);
}

.pixi-target-card span,
.pixi-stats span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.pixi-target-card strong {
  display: block;
  margin-top: 5px;
  font-size: 22px;
  line-height: 1.05;
}

.pixi-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.pixi-stats b {
  display: block;
  color: var(--primary);
  font-size: 24px;
}

.pixi-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.pixi-list {
  min-height: 0;
  overflow-y: auto;
  padding: 4px 6px 10px 0;
}

.pixi-list-item {
  width: 100%;
  min-height: 54px;
  margin: 0 0 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #ffffff;
  border: 3px solid var(--surface-ink);
  box-shadow: var(--shadow-sm);
  text-align: left;
  font-weight: 900;
}

.pixi-list-item span {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.pixi-list-item.active {
  color: #ffffff;
  background: var(--primary);
}

.pixi-list-item.active span {
  color: #ffffff;
}

.pixi-list-item:disabled {
  opacity: 0.48;
  text-decoration: line-through;
}

.pixi-stage-wrap {
  min-width: 0;
  height: 100vh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
}

.pixi-stage-toolbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  background: var(--surface);
  border: 4px solid var(--surface-ink);
  box-shadow: var(--shadow);
}

.pixi-stage-toolbar span {
  color: var(--primary);
  font-weight: 900;
  text-transform: uppercase;
}

.pixi-stage-toolbar strong {
  max-width: 62ch;
  line-height: 1.2;
  text-align: right;
}

.pixi-stage {
  position: relative;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  background-color: #f7f1df;
  background-image: repeating-linear-gradient(45deg, rgba(26, 26, 26, 0.12) 0, rgba(26, 26, 26, 0.12) 2px, transparent 2px, transparent 10px);
  border: 4px solid var(--surface-ink);
  box-shadow: var(--shadow);
}

.pixi-prototype-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 3000;
  max-width: min(420px, calc(100vw - 40px));
  padding: 14px 18px;
  color: var(--text);
  background: #ffffff;
  border: 4px solid var(--surface-ink);
  border-left-width: 12px;
  box-shadow: var(--shadow);
  font-weight: 800;
  animation: slideIn 180ms ease;
}

@keyframes slideIn {
  from {
    transform: translateX(110%);
  }

  to {
    transform: translateX(0);
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(26, 26, 26, 0.72);
}

.modal-content {
  width: min(420px, 100%);
  padding: 34px;
  color: var(--text);
  background: #ffffff;
  border: 4px solid var(--surface-ink);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.modal-content h1 {
  margin: 0 0 12px;
  color: var(--danger);
  font-size: 32px;
}

.modal-content p {
  margin: 0 0 16px;
  font-weight: 800;
}

#final-streak {
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 56px;
  line-height: 1;
  font-weight: 900;
}

.modal-content .btn {
  width: 100%;
  margin-top: 18px;
}

.mobile-icon-btn,
.leaderboard-close {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  color: var(--text);
  background: #ffffff;
  border: 3px solid var(--surface-ink);
  box-shadow: var(--shadow-sm);
}

.btn-leaderboard,
.btn-leaderboard-submit {
  background: var(--primary);
  color: #ffffff;
}

.leaderboard-panel {
  position: fixed;
  inset: 0;
  z-index: 3900;
  display: grid;
  justify-items: end;
  padding: 18px;
  background: rgba(26, 26, 26, 0.42);
}

.leaderboard-panel[hidden] {
  display: none;
}

.leaderboard-content {
  width: min(480px, 100%);
  height: min(720px, calc(100dvh - 36px));
  display: flex;
  flex-direction: column;
  padding: 22px;
  background: #ffffff;
  border: 4px solid var(--surface-ink);
  box-shadow: var(--shadow-lg);
}

.leaderboard-content header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.leaderboard-content h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1;
  text-transform: uppercase;
}

.leaderboard-content p {
  margin: 10px 0 16px;
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
}

.leaderboard-list {
  min-height: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  overflow-y: auto;
  list-style: none;
}

.leaderboard-row,
.leaderboard-empty {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  padding: 12px;
  background: var(--surface);
  border: 3px solid var(--surface-ink);
  box-shadow: var(--shadow-sm);
}

.leaderboard-row small,
.leaderboard-row em {
  grid-column: 3 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  font-style: normal;
}

.leaderboard-row em {
  width: fit-content;
  padding: 3px 7px;
  color: #ffffff;
  background: var(--secondary);
  border: 2px solid var(--surface-ink);
}

.leaderboard-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 900;
}

.leaderboard-score {
  color: var(--primary);
  font-size: 20px;
  font-weight: 900;
}

.leaderboard-submit-panel {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
  padding: 14px;
  background: var(--surface-low);
  border: 3px solid var(--surface-ink);
  text-align: left;
}

.leaderboard-submit-panel[hidden] {
  display: none;
}

.leaderboard-submit-panel h2 {
  margin: 0;
  font-size: 16px;
  text-transform: uppercase;
}

.leaderboard-submit-panel input {
  min-height: 44px;
  padding: 10px 12px;
  color: var(--text);
  background: #ffffff;
  border: 3px solid var(--surface-ink);
  font: inherit;
  font-weight: 800;
}

.leaderboard-submit-status {
  margin: 0 !important;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.leaderboard-avatar {
  box-shadow: 2px 2px 0 var(--surface-ink);
}

.progress-cta-modal {
  position: fixed;
  inset: 0;
  z-index: 4200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 26px;
  background: rgba(26, 26, 26, 0.68);
  backdrop-filter: blur(9px);
}

.progress-cta-modal.is-open {
  display: flex;
}

.progress-cta-card {
  position: relative;
  width: min(840px, calc(100vw - 44px));
  color: var(--text);
  background: #fffafa;
  border: 4px solid var(--surface-ink);
  box-shadow: 16px 16px 0 var(--surface-ink);
}

.progress-cta-header {
  min-height: 110px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 28px 46px;
  color: #ffffff;
  background-color: #0648e8;
  background-image: radial-gradient(rgba(26, 26, 26, 0.42) 1px, transparent 1px);
  background-size: 12px 12px;
  border-bottom: 4px solid var(--surface-ink);
  font-size: 40px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.progress-cta-header-icon {
  width: 54px;
  height: 54px;
  display: inline-grid;
  place-items: center;
  color: #0648e8;
  background: #ffffff;
  border: 3px solid #ffffff;
  flex: 0 0 auto;
}

.progress-cta-header-icon .icon-symbol {
  font-size: 31px;
}

.progress-cta-badge {
  position: absolute;
  top: -36px;
  right: 22px;
  z-index: 2;
  min-width: 206px;
  min-height: 78px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 18px;
  color: var(--surface-ink);
  background: #82f5c1;
  border: 3px solid var(--surface-ink);
  box-shadow: 8px 8px 0 var(--surface-ink);
  transform: rotate(12deg);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.progress-cta-badge .icon-symbol {
  font-size: 31px;
}

.progress-cta-body {
  display: grid;
  gap: 24px;
  padding: 46px 50px 34px;
}

.progress-cta-body h2 {
  margin: 0;
  color: var(--surface-ink);
  font-size: 56px;
  font-weight: 900;
  line-height: 0.98;
}

.progress-cta-body p {
  margin: 0;
  max-width: 680px;
  color: #303243;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.35;
}

.progress-cta-track {
  height: 50px;
  border-width: 2px;
  background: #59a28a;
}

.progress-avatar-picker {
  display: grid;
  gap: 10px;
}

.progress-avatar-picker h3 {
  margin: 0;
  color: var(--surface-ink);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.avatar-options {
  display: grid;
  grid-template-columns: repeat(8, 32px);
  gap: 8px;
}

.avatar-option {
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.avatar-option img {
  border-width: 2px;
}

.avatar-option.is-selected img {
  outline: 4px solid #0648e8;
  outline-offset: 2px;
}

.progress-cta-fill {
  background: #007a4e;
}

.progress-cta-field {
  position: relative;
  display: grid;
  padding-top: 13px;
}

.progress-cta-field span {
  position: absolute;
  top: 0;
  left: 30px;
  padding: 0 6px;
  color: var(--surface-ink);
  background: #fffafa;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.progress-cta-field input {
  min-height: 78px;
  width: 100%;
  padding: 20px 28px;
  color: var(--text);
  background: #fffafa;
  border: 2px solid var(--surface-ink);
  font: inherit;
  font-size: 20px;
  font-weight: 900;
}

.progress-cta-field input::placeholder {
  color: #c8c8cf;
}

.progress-cta-submit {
  min-height: 80px;
  width: 100%;
  justify-content: center;
  padding: 18px 26px;
  color: #ffffff;
  background: #0648e8;
  border: 3px solid var(--surface-ink);
  box-shadow: 8px 8px 0 var(--surface-ink);
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.progress-cta-submit:hover {
  transform: translate(5px, 5px);
  box-shadow: 3px 3px 0 var(--surface-ink);
}

.progress-cta-submit .icon-symbol {
  order: 2;
  font-size: 32px;
}

.progress-cta-status {
  min-height: 18px;
  color: var(--success) !important;
  font-size: 12px !important;
  font-weight: 900 !important;
  text-transform: uppercase;
}

.progress-cta-footer {
  padding-top: 18px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
}

.progress-cta-footer span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.progress-cta-footer .icon-symbol {
  font-size: 17px;
}

.progress-cta-later {
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 2px solid currentColor;
  font: inherit;
  font-weight: 900;
  text-transform: uppercase;
}

.icon-symbol,
.material-symbols-outlined {
  width: 1em;
  height: 1em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.icon-symbol svg {
  width: 1em;
  height: 1em;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-symbol[data-icon="favorite"] svg,
.icon-symbol[data-icon="bolt"] svg {
  fill: currentColor;
}

::-webkit-scrollbar {
  width: 12px;
}

::-webkit-scrollbar-track {
  background: var(--surface-low);
  border-left: 3px solid var(--surface-ink);
}

::-webkit-scrollbar-thumb {
  background: var(--surface-ink);
  border: 2px solid var(--surface-low);
}

@media (max-width: 1100px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .mobile-header {
    position: sticky;
    top: 0;
    z-index: 1400;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    color: #ffffff;
    background: var(--primary);
    border-bottom: 4px solid var(--surface-ink);
    box-shadow: var(--shadow-sm);
  }

  .mobile-brand {
    font-size: 20px;
    font-weight: 900;
    font-style: italic;
    line-height: 1;
    white-space: nowrap;
  }

  .mobile-actions {
    display: flex;
    gap: 12px;
  }

  .app-shell {
    min-height: calc(100dvh - 58px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
  }

  .sidebar-menu,
  .objective-bar,
  .map-stage,
  .answer-panel,
  .footer-actions {
    width: calc(100vw - 24px);
    max-width: 100%;
    min-width: 0;
  }

  .side-nav,
  .game-main {
    display: contents;
  }

  .sidebar-menu {
    order: 1;
    padding: 0;
    border-bottom: 0;
    box-shadow: none;
    background: transparent;
  }

  .sidebar-menu-toggle {
    min-height: 48px;
    background: #ffffff;
  }

  .sidebar-menu.is-open .sidebar-menu-panel {
    max-height: min(70dvh, 620px);
    overflow-y: auto;
    padding: 10px;
    background: #ffffff;
    border: 3px solid var(--surface-ink);
    box-shadow: var(--shadow-sm);
  }

  .sidebar-menu-panel .app-panel,
  .target-list-context,
  .sidebar-menu-panel .mode-menu,
  .sidebar-menu-panel .mistakes-panel,
  .sidebar-menu-panel .gameplay-settings-panel,
  .sidebar-menu-panel .sidebar-bottom {
    box-shadow: none;
  }

  .mode-btn {
    width: 100%;
    justify-content: flex-start;
    min-height: 44px;
    padding: 10px 12px;
    background: #ffffff;
    border: 2px solid var(--surface-ink);
  }

  .answer-panel.target-sheet {
    order: 4;
    position: fixed;
    left: 12px;
    right: auto;
    bottom: calc(82px + env(safe-area-inset-bottom));
    z-index: 1295;
    width: min(62vw, 270px);
    max-width: none;
    min-height: 0;
    padding: 0;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    background: transparent;
    border: 0;
    box-shadow: none;
    pointer-events: none;
  }

  .answer-panel.target-sheet.is-open {
    right: auto;
    width: min(74vw, 620px);
    max-width: calc(100vw - 24px);
  }

  .target-sheet-toggle {
    min-height: 48px;
    width: 100%;
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 9px;
    padding: 10px 12px;
    color: var(--text);
    background: #ffffff;
    border: 3px solid var(--surface-ink);
    box-shadow: var(--shadow-sm);
    text-align: left;
    pointer-events: auto;
  }

  .target-sheet-label {
    min-width: 0;
    font-size: 14px;
    font-weight: 900;
    line-height: 1;
    text-transform: uppercase;
  }

  .target-sheet-body {
    max-height: calc(100dvh - 144px - env(safe-area-inset-bottom));
    display: block;
    overflow-y: auto;
    padding: 10px;
    background: #ffffff;
    border: 3px solid var(--surface-ink);
    box-shadow: var(--shadow-sm);
    pointer-events: auto;
  }

  .target-sheet:not(.is-open) .target-sheet-body {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
    border-top-width: 0;
    border-bottom-width: 0;
    pointer-events: none;
    transform: translateY(10px);
  }

  .question-mode-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .question-mode-btn {
    flex: 0 0 104px;
    min-height: 34px;
  }

  .question-mode-toggle::-webkit-scrollbar {
    display: none;
  }

  .target-sheet .name-pool {
    max-height: inherit;
    display: grid;
    gap: 8px;
    overflow-y: auto;
    padding: 2px 4px 8px 2px;
    scroll-snap-type: none;
  }

  .target-sheet .name-item {
    width: 100%;
    flex: none;
    min-height: 48px;
    margin-bottom: 0;
    scroll-snap-align: none;
  }

  .objective-bar {
    order: 2;
    min-height: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px;
    box-shadow: var(--shadow-sm);
  }

  .target-card {
    width: 100%;
    min-width: 0;
    padding: 12px 14px;
    gap: 9px;
  }

  .target-label {
    font-size: 14px;
  }

  .target-card strong {
    font-size: 20px;
  }

  .target-card .icon-symbol,
  .target-card .material-symbols-outlined {
    font-size: 28px;
  }

  .hud-stats {
    width: 100%;
    min-width: 0;
    display: flex;
    gap: 8px;
    overflow: hidden;
  }

  .hud-card {
    width: 100%;
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
    padding: 8px 6px;
    overflow: hidden;
  }

  .hud-card span:first-child {
    font-size: 10px;
  }

  .hud-card strong {
    font-size: 18px;
  }

  .heart {
    font-size: 20px;
  }

  .heart-row {
    min-width: 0;
    justify-content: center;
  }

  .map-stage {
    order: 3;
    flex: none;
    height: min(49dvh, 460px);
    min-height: 320px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
  }

  #map {
    inset: 8px;
    border-width: 3px;
    box-shadow: none;
  }

  .map-controls {
    top: 16px;
    left: 16px;
    right: 16px;
    height: 44px;
  }

  .map-control-btn {
    width: 44px;
    height: 44px;
    border-width: 2px;
    box-shadow: 2px 2px 0 var(--surface-ink);
  }

  .map-zoom-out {
    left: 52px;
  }

  .map-hint-toggle {
    left: 104px;
    min-width: 112px;
    padding: 0 8px;
  }

  .map-control-label {
    font-size: 9px;
  }

  .pin {
    --pin-visual-size: 19px;
  }

  .pin::after {
    border-width: 2px;
    box-shadow: 2px 2px 0 rgba(26, 26, 26, 0.92);
  }

  .pin::before {
    width: calc(5px * var(--pin-size-scale));
    height: calc(5px * var(--pin-size-scale));
    border-width: 1px;
  }

  .feature-label {
    max-width: 132px;
    padding: 4px 6px;
    border-width: 2px;
    font-size: 10px;
  }

  .footer-actions {
    order: 5;
    min-height: 0;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .footer-actions.answer-reveal-disabled {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .btn {
    min-height: 48px;
    padding: 9px 8px;
    border-width: 3px;
    box-shadow: var(--shadow-sm);
    font-size: 12px;
  }

  .footer-actions .btn {
    min-width: 0;
    flex-direction: column;
    gap: 5px;
    padding: 8px 6px;
  }

  .footer-actions .btn-label,
  .footer-actions .btn {
    overflow-wrap: anywhere;
  }

  .pixi-prototype-body {
    overflow: auto;
  }

  .pixi-prototype-shell {
    height: auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .pixi-prototype-panel {
    height: auto;
    display: block;
    padding: 16px;
    overflow: hidden;
    border-right: 0;
    border-bottom: 4px solid var(--surface-ink);
    box-shadow: 0 6px 0 var(--surface-ink);
  }

  .pixi-target-card,
  .pixi-stats,
  .pixi-actions,
  .pixi-list,
  .pixi-stage-wrap,
  .pixi-stage-toolbar,
  .pixi-stage {
    width: calc(100vw - 32px);
    max-width: 100%;
    min-width: 0;
  }

  .pixi-copy,
  .pixi-back-link {
    display: none;
  }

  .pixi-prototype-panel h1 {
    font-size: 24px;
  }

  .pixi-target-card,
  .pixi-stats,
  .pixi-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
  }

  .pixi-actions button {
    flex: 1 1 0;
    min-width: 0;
  }

  .pixi-list {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 4px 4px;
  }

  .pixi-list-item {
    width: 230px;
    flex: 0 0 230px;
    margin-bottom: 0;
  }

  .pixi-stage-wrap {
    min-height: 0;
    flex: none;
    padding: 12px;
  }

  .pixi-stage-toolbar {
    min-height: 0;
    display: block;
    padding: 12px;
    box-shadow: var(--shadow-sm);
  }

  .pixi-stage-toolbar strong {
    display: block;
    margin-top: 5px;
    text-align: left;
    overflow-wrap: anywhere;
  }

  .pixi-stage {
    height: 420px;
    flex: none;
  }
}

@media (max-width: 640px) {
  .progress-cta-modal {
    padding: 16px;
  }

  .progress-cta-card {
    width: min(100%, 420px);
    box-shadow: 9px 9px 0 var(--surface-ink);
  }

  .progress-cta-header {
    min-height: 78px;
    gap: 12px;
    padding: 18px 20px;
    font-size: 24px;
  }

  .progress-cta-header-icon {
    width: 42px;
    height: 42px;
  }

  .progress-cta-header-icon .icon-symbol {
    font-size: 24px;
  }

  .progress-cta-badge {
    top: -22px;
    right: 10px;
    min-width: 142px;
    min-height: 52px;
    gap: 6px;
    padding: 8px 10px;
    box-shadow: 5px 5px 0 var(--surface-ink);
    font-size: 10px;
  }

  .progress-cta-badge .icon-symbol {
    font-size: 21px;
  }

  .progress-cta-body {
    gap: 16px;
    padding: 28px 22px 22px;
  }

  .progress-cta-body h2 {
    font-size: 36px;
  }

  .progress-cta-body p {
    font-size: 16px;
  }

  .progress-cta-track {
    height: 34px;
  }

  .avatar-options {
    grid-template-columns: repeat(4, 32px);
    gap: 6px;
  }

  .progress-cta-field input {
    min-height: 58px;
    padding: 14px 16px;
    font-size: 16px;
  }

  .progress-cta-submit {
    min-height: 64px;
    padding: 14px 16px;
    font-size: 23px;
    text-align: center;
  }

  .progress-cta-submit .btn-label {
    overflow-wrap: anywhere;
  }

  .progress-cta-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    font-size: 12px;
  }

  .mobile-header {
    height: 50px;
    padding: 0 12px;
  }

  .mobile-brand {
    font-size: 18px;
  }

  .app-shell {
    min-height: calc(100dvh - 50px);
    gap: 8px;
    padding: 8px;
    padding-bottom: calc(104px + env(safe-area-inset-bottom));
  }

  .sidebar-menu,
  .objective-bar,
  .map-stage,
  .answer-panel,
  .footer-actions {
    width: calc(100vw - 20px);
  }

  .mobile-actions {
    display: none;
  }

  .sidebar-menu-toggle {
    min-height: 44px;
    grid-template-columns: auto 1fr auto;
    padding: 8px 10px;
  }

  .sidebar-menu-hint {
    display: none;
  }

  .sidebar-menu.is-open .sidebar-menu-panel {
    max-height: min(62dvh, 520px);
    padding: 8px;
  }

  .mode-btn {
    min-width: 106px;
    font-size: 13px;
  }

  .mode-btn .icon-symbol,
  .mode-btn .material-symbols-outlined {
    font-size: 21px;
  }

  .objective-bar {
    gap: 8px;
    padding: 8px;
  }

  .target-card {
    min-height: 52px;
    padding: 10px 12px;
    border-width: 3px;
  }

  .target-label {
    font-size: 13px;
  }

  .target-card strong {
    font-size: 18px;
  }

  .target-card .icon-symbol,
  .target-card .material-symbols-outlined {
    display: none;
  }

  .hud-stats {
    gap: 6px;
  }

  .hud-card {
    min-height: 54px;
    padding: 7px 5px;
  }

  .map-stage {
    height: min(56dvh, 470px);
    min-height: 340px;
  }

  .pin {
    --pin-visual-size: 16px;
  }

  .name-item {
    width: 224px;
    flex-basis: 224px;
  }

  .name-item small {
    max-width: 78px;
  }

  .answer-panel.target-sheet {
    left: 8px;
    right: auto;
    bottom: calc(96px + env(safe-area-inset-bottom));
    width: min(62vw, 252px);
  }

  .answer-panel.target-sheet.is-open {
    right: auto;
    width: min(74vw, 300px);
    max-width: calc(100vw - 16px);
  }

  .target-sheet-toggle {
    min-height: 44px;
    padding: 8px 10px;
  }

  .target-sheet-body {
    max-height: calc(100dvh - 204px - env(safe-area-inset-bottom));
    padding: 8px;
  }

  .footer-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1300;
    width: 100%;
    margin: 0;
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
    background: var(--background);
    border-top: 3px solid var(--surface-ink);
  }

  .footer-actions .btn {
    min-height: 50px;
    padding: 7px 5px;
  }

  .footer-actions .icon-symbol,
  .footer-actions .material-symbols-outlined {
    font-size: 20px;
  }

  .btn {
    font-size: 11px;
  }
}

@media (max-width: 1280px) and (orientation: landscape) and (max-height: 700px) {
  html,
  body {
    height: 100%;
    min-height: 100%;
    overflow: hidden;
  }

  .mobile-header {
    display: none;
  }

  .app-shell {
    height: 100dvh;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 26vw);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: 6px;
    padding: 6px;
    padding-bottom: 6px;
    overflow: hidden;
  }

  .side-nav,
  .game-main {
    display: contents;
  }

  .sidebar-menu,
  .objective-bar,
  .map-stage,
  .answer-panel,
  .footer-actions {
    width: auto;
    max-width: none;
  }

  .sidebar-menu {
    grid-column: 2;
    grid-row: 1;
    order: initial;
    min-width: 0;
    width: calc(50% - 3px);
    justify-self: start;
    z-index: 1400;
  }

  .sidebar-menu-toggle {
    min-height: 32px;
    grid-template-columns: auto 1fr auto;
    gap: 5px;
    padding: 4px 6px;
    border-width: 2px;
    box-shadow: 3px 3px 0 var(--surface-ink);
  }

  .sidebar-menu-toggle .icon-symbol,
  .target-sheet-toggle .icon-symbol {
    font-size: 17px;
  }

  .sidebar-menu-label {
    font-size: 11px;
  }

  .sidebar-menu-hint {
    display: none;
  }

  .sidebar-menu.is-open .sidebar-menu-panel {
    position: absolute;
    top: 40px;
    right: 6px;
    width: min(300px, calc(26vw + 80px), calc(100vw - 16px));
    max-height: calc(100dvh - 46px);
    z-index: 1400;
    gap: 6px;
    padding: 6px;
    overflow-y: auto;
  }

  .sidebar-menu-panel .app-panel,
  .target-list-context,
  .sidebar-menu-panel .mode-menu,
  .sidebar-menu-panel .mistakes-panel,
  .sidebar-menu-panel .gameplay-settings-panel,
  .sidebar-menu-panel .sidebar-bottom {
    padding: 7px;
    border-width: 2px;
    box-shadow: 3px 3px 0 var(--surface-ink);
  }

  .sidebar-menu-panel .app-panel h1 {
    margin-bottom: 5px;
    font-size: 17px;
  }

  .sidebar-menu-panel .app-panel p,
  .target-list-context p {
    display: none;
  }

  .sidebar-menu-panel .best-score {
    padding: 6px 8px;
    border-width: 2px;
    box-shadow: none;
  }

  .sidebar-menu-panel .best-score b {
    font-size: 17px;
  }

  .sidebar-menu-panel .mode-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .sidebar-menu-panel .mode-btn {
    min-height: 31px;
    justify-content: flex-start;
    gap: 6px;
    padding: 5px 7px;
    border-width: 2px;
    box-shadow: 3px 3px 0 var(--surface-ink);
    font-size: 10px;
  }

  .sidebar-menu-panel .mode-btn .icon-symbol {
    font-size: 16px;
  }

  .pin-settings-panel {
    gap: 5px;
    padding: 6px;
    border-width: 2px;
    box-shadow: none;
  }

  .pin-size-label,
  .pin-size-value {
    font-size: 9px;
  }

  .target-list-context h2,
  .mistakes-title {
    margin-bottom: 5px;
    font-size: 10px;
  }

  .question-mode-toggle {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin: 0;
    padding: 0;
    overflow: visible;
  }

  .question-mode-btn {
    min-width: 0;
    min-height: 30px;
    width: 100%;
    flex: none;
    padding: 5px 6px;
    font-size: 9px;
  }

  .mistakes-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }

  .mistake-tag {
    min-width: 0;
    padding: 4px 5px;
    overflow: hidden;
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .music-panel {
    gap: 5px;
    padding: 6px;
    border-width: 2px;
    box-shadow: none;
  }

  .music-track-select,
  .btn-music-toggle {
    min-height: 30px;
    font-size: 10px;
  }

  .sidebar-bottom .btn-side,
  .ownership-mark {
    display: none;
  }

  .objective-bar {
    grid-column: 2;
    grid-row: 2;
    order: initial;
    min-height: 0;
    padding: 4px;
    display: grid;
    gap: 3px;
    align-self: start;
    box-shadow: var(--shadow-sm);
  }

  .target-card {
    min-height: 32px;
    padding: 4px 6px;
    gap: 5px;
    border-width: 2px;
  }

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

  .target-card strong {
    font-size: 13px;
  }

  .target-card .icon-symbol,
  .target-card .material-symbols-outlined {
    display: none;
  }

  .hud-stats {
    gap: 4px;
  }

  .hud-card {
    min-height: 32px;
    padding: 4px 3px;
    border-width: 2px;
    box-shadow: 3px 3px 0 var(--surface-ink);
  }

  .hud-card span:first-child {
    font-size: 9px;
  }

  .hud-card strong {
    font-size: 13px;
  }

  .heart {
    font-size: 15px;
  }

  .map-stage {
    grid-column: 1;
    grid-row: 1 / 5;
    order: initial;
    height: auto;
    min-height: 0;
    align-self: stretch;
    box-shadow: var(--shadow-sm);
  }

  #map {
    inset: 6px;
    border-width: 3px;
  }

  .map-controls {
    top: 13px;
    left: 13px;
    right: 13px;
    height: 40px;
  }

  .map-control-btn {
    width: 40px;
    height: 40px;
    border-width: 2px;
    box-shadow: 2px 2px 0 var(--surface-ink);
  }

  .map-zoom-out {
    left: 48px;
  }

  .map-hint-toggle {
    left: 96px;
    min-width: 104px;
    padding: 0 7px;
  }

  .map-control-btn .icon-symbol {
    font-size: 16px;
  }

  .pin {
    --pin-visual-size: 15px;
  }

  .answer-panel.target-sheet {
    grid-column: 2;
    grid-row: 1 / 4;
    order: initial;
    position: static;
    min-height: 0;
    width: auto;
    padding: 0;
    display: grid;
    grid-template-rows: 32px minmax(0, 1fr);
    align-self: stretch;
    gap: 5px;
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
    pointer-events: none;
    z-index: 1350;
  }

  .answer-panel.target-sheet.is-open {
    align-self: stretch;
  }

  .target-sheet-toggle {
    display: grid;
    min-height: 32px;
    width: calc(50% - 3px);
    justify-self: end;
    gap: 5px;
    padding: 4px 6px;
    grid-template-columns: auto minmax(0, 1fr) auto;
    border-width: 2px;
    box-shadow: 3px 3px 0 var(--surface-ink);
    pointer-events: auto;
  }

  .target-sheet-label {
    overflow: hidden;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .target-count {
    display: none;
  }

  .target-sheet-body {
    grid-row: 2;
    width: 100%;
    min-height: 0;
    height: 100%;
    max-height: calc(100dvh - 92px);
    display: block;
    overflow-y: auto;
    padding: 6px;
    border-width: 2px;
    pointer-events: auto;
    opacity: 1;
    transform: translateY(0);
  }

  .target-sheet:not(.is-open) .target-sheet-body {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
    border-top-width: 0;
    border-bottom-width: 0;
    pointer-events: none;
    transform: translateY(-8px);
  }

  .target-sheet .name-pool {
    gap: 5px;
    padding: 2px 2px 5px;
  }

  .target-sheet .name-item {
    min-height: 34px;
    padding: 5px 7px;
    border-width: 2px;
    box-shadow: 3px 3px 0 var(--surface-ink);
    font-size: 11px;
  }

  .name-item small {
    max-width: 58px;
    font-size: 9px;
    line-height: 1.05;
  }

  .footer-actions {
    grid-column: 2;
    grid-row: 4;
    order: initial;
    position: static;
    z-index: auto;
    width: auto;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    margin: 0;
    padding: 0;
    background: transparent;
    border-top: 0;
  }

  .footer-actions.answer-reveal-disabled {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .footer-actions .btn {
    min-height: 32px;
    padding: 4px;
    border-width: 2px;
    box-shadow: 3px 3px 0 var(--surface-ink);
    font-size: 8px;
  }

  .footer-actions .icon-symbol,
  .footer-actions .material-symbols-outlined {
    font-size: 15px;
  }
}

body.kpss-map-focus {
  overflow: hidden;
  background: var(--surface-ink);
}

body.kpss-map-focus .mobile-header,
body.kpss-map-focus .sidebar-menu,
body.kpss-map-focus .objective-bar,
body.kpss-map-focus .footer-actions {
  display: none !important;
}

body.kpss-map-focus .app-shell {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: none;
  height: 100dvh;
  min-height: 0;
  display: block;
  padding: 0;
  overflow: hidden;
  background: var(--surface-ink);
}

body.kpss-map-focus .side-nav,
body.kpss-map-focus .game-main {
  display: contents;
}

body.kpss-map-focus .map-stage {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100vw !important;
  max-width: none;
  height: 100dvh !important;
  min-height: 0;
  border: 0;
  box-shadow: none;
}

body.kpss-map-focus #map {
  inset: 0;
  border: 0;
  box-shadow: none;
}

body.kpss-map-focus .map-stage-texture {
  display: none;
}

body.kpss-map-focus .map-controls {
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 1510;
}

body.kpss-map-focus .answer-panel.target-sheet {
  position: fixed;
  left: 8px;
  right: auto;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 1500;
  width: min(62vw, 252px);
  min-height: 0;
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}

body.kpss-map-focus .answer-panel.target-sheet.is-open {
  right: auto;
  width: min(74vw, 620px);
  max-width: calc(100vw - 16px);
}

body.kpss-map-focus .target-sheet-toggle {
  min-height: 40px;
  pointer-events: auto;
}

body.kpss-map-focus .target-sheet-body {
  width: 100%;
  max-height: calc(100dvh - 58px - env(safe-area-inset-bottom));
  height: auto;
  pointer-events: auto;
}

@media (orientation: landscape) and (max-height: 700px) {
  body.kpss-map-focus .answer-panel.target-sheet.is-open {
    width: min(28vw, 520px);
    min-width: min(300px, calc(100vw - 16px));
  }
}
