:root{
  --bg: #008080;
  --text: #000;
  --muted: #1f2937;

  --panel1: #c0c0c0;
  --panel2: #c0c0c0;
  --border: #000;

  --stateFill: #d6d6d6;
  --stateStroke: #000;
  --stateHover: #ffffff;
  --stateActive: #b0b0b0;

  --good: #00a000;
  --bad: #a00000;
  --accent: #0000aa;
  --gold: #aa5500;

  --overlayBg: #c0c0c0;
  --overlayBorder: #000;

  --zoomBtnBg: #ffffff;
  --zoomBtnBorder: #000;

  --overlayHeight: 64px;
  --overlayGap: 12px;
  --mapTopPad: calc(var(--overlayHeight) + var(--overlayGap));
}

*{box-sizing:border-box}

body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
  overflow-x:hidden;
  font-family: "MS Sans Serif", Tahoma, Verdana, Arial, sans-serif;
}

.page{
  width:min(1400px, 100%);
  display:flex;
  flex-direction:column;
  gap:14px;
}

/* Game layout */
.app{
  width:100%;
  display:grid;
  grid-template-columns: 320px 1fr;
  gap:14px;
}
@media (max-width: 980px){
  .app{grid-template-columns:1fr;}
}

.panel{
  background: var(--panel1);
  border: 2px solid var(--border);
  border-radius: 0;
  box-shadow: none;
  overflow:hidden;
  position:relative;
}

/* Sidebar */
.sidebar{
  padding:16px;
  display:flex;
  flex-direction:column;
  gap:12px;
}

.title{
  font-size: 18px;
  font-weight: 900;
  margin:0;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.modeInline{
  padding: 10px;
  border: 2px solid #000;
  background: #fff;
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 #808080;
}

.modeLabel{
  font-size: 12px;
  margin-bottom: 6px;
}

.modeSelect{
  width: 100%;
  border: 2px solid #000;
  background: #fff;
  color: #000;
  padding: 8px 8px;
  font-family: "MS Sans Serif", Tahoma, Verdana, Arial, sans-serif;
  font-size: 12px;
  font-weight: 700;
  outline: none;
}

.sub{
  margin:0;
  color:#000;
  font-size: 13px;
  line-height: 1.35;
}

.card{
  background:#c0c0c0;
  border-radius:0;
  border:2px solid #000;
  padding: 12px;
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 #808080;
}

.grid2{ display:grid; grid-template-columns: 1fr 1fr; gap:10px; }
.label{ font-size: 12px; color: #000; margin-bottom: 6px; }

.target{
  font-size: 22px;
  font-weight: 900;
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}

.pill{
  font-size: 11px;
  padding: 2px 8px;
  border-radius:0;
  display:none;
  align-items:center;
  user-select:none;
  border:2px solid #000;
  background:#fff;
  color:#000;
}
.pill.show{display:inline-flex;}

.statBig{ font-weight: 900; font-size: 20px; }
.statSmall{ color: #000; font-size: 12px; margin-top: 2px; }

.meterWrap{
  height: 10px;
  border-radius:0;
  border:2px solid #000;
  background:#fff;
  overflow:hidden;
}
.meter{
  height:100%;
  width:0%;
  background:#0000aa;
  transition: width 320ms ease;
}

/* Buttons */
.btnRow{display:flex; gap:8px; flex-wrap:wrap; align-items:center;}
button{
  appearance:none;
  border-radius:0;
  background:#c0c0c0;
  color:#000;
  border:2px solid #000;
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 #808080;
  padding: 10px 12px;
  cursor:pointer;
  font-weight:900;
  font-size: 13px;
}
button:active{
  box-shadow: inset -2px -2px 0 #fff, inset 2px 2px 0 #808080;
}
button.primary{ background:#ffffcc; }

/* Toggles */
.toggleRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding: 8px 10px;
  border-radius:0;
  border:2px solid #000;
  background:#c0c0c0;
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 #808080;
}

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

.toggleRow .tlabel{
  font-weight:900;
  font-size: 13px;
  display:flex;
  align-items:center;
  gap:8px;
}

.switch{
  border-radius:0;
  border:2px solid #000;
  background:#fff;
  width: 52px;
  height: 24px;
  position:relative;
  cursor:pointer;
  user-select:none;
  box-shadow:none;
}
.switch::after{
  content:"";
  border-radius:0;
  width: 18px;
  height: 18px;
  top: 2px;
  left: 2px;
  position:absolute;
  background:#0000aa;
  box-shadow:none;
  transition: transform 180ms ease, background 180ms ease;
}
.switch.on::after{
  transform: translateX(28px);
  background:#00a000;
}

/* Map */
.mapPanel{ position:relative; padding: 10px; display:flex; flex-direction:column; }

.mapHeader{
  padding: 10px 10px 0 10px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
}

.mapTitle{
  font-size: 18px;
  font-weight: 900;
  margin:0;
}

.hint{ color:#000; font-size:12px; }

.mapWrap{
  position:relative;
  width:100%;
  height: calc(100% - 10px);
  min-height: 540px;
  padding: 10px;
  overflow: hidden;
}

/* HUD bar */
.overlayBar{
  position:absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 6;
  display:flex;
  align-items:center;
  gap:10px;
  padding: 8px 10px;
  border-radius:0;
  background: var(--overlayBg);
  border: 2px solid var(--overlayBorder);
  pointer-events:none;
  flex-wrap: nowrap;
  overflow: hidden;
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 #808080;
}
.overlayBar *{ pointer-events:auto; }

.overlayBar .spacer{
  flex: 1 1 auto;
  min-width: 6px;
}

/* Make the Find box bigger and its text bigger */
.findMini{
  padding: 10px 14px;
  max-width: 420px;
  min-width: 320px;
}
.findMini .k{
  font-size: 13px;
  font-weight: 900;
}
.findMini .v{
  font-size: 16px;
  font-weight: 950;
}

/* Play button */
.playBtn{
  display:inline-flex;
  align-items:center;
  gap:10px;
  padding: 8px 10px;
  border-radius:0;
  border: 2px solid #000;
  background:#c0c0c0;
  cursor:pointer;
  font-weight: 950;
  user-select:none;
  white-space:nowrap;
  flex: 0 0 auto;
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 #808080;
}
.playBtn:active{
  box-shadow: inset -2px -2px 0 #fff, inset 2px 2px 0 #808080;
}

.playIcon{
  width: 0; height: 0;
  border-left: 10px solid #000;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  transform: translateX(1px);
}

.pauseIcon{
  width: 12px;
  height: 14px;
  display:none;
  gap:4px;
}
.pauseIcon::before,.pauseIcon::after{
  content:"";
  display:block;
  width: 4px;
  height: 14px;
  background:#000;
  border-radius:0;
}

.playBtn.running .playIcon{ display:none; }
.playBtn.running .pauseIcon{ display:flex; }

.mini{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 6px 10px;
  border-radius:0;
  border: 2px solid #000;
  background:#fff;
  white-space:nowrap;
  flex: 0 0 auto;
  max-width: 260px;
  overflow:hidden;
  text-overflow:ellipsis;
  font-size: 12px;
}
.mini .k{ color:#000; font-weight: 800; font-size: 11px; }
.mini .v{ font-weight: 950; font-size: 12px; }
.mini b{ color:#0000aa; }

/* Correct-name overlay (neon / 90s font) */
.correctNameOverlay{
  position:absolute;
  left: 50%;
  top: 110px;
  transform: translateX(-50%);
  z-index: 8;
  pointer-events:none;

  padding: 10px 14px;
  border: 2px solid #000;
  background: rgba(255,255,255,0.92);
  box-shadow: 3px 3px 0 #000;

  font-family: "Press Start 2P", "MS Sans Serif", Tahoma, Verdana, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: 0.5px;

  opacity:0;
  filter: saturate(140%);
  text-transform: uppercase;

  transition: opacity 220ms ease, transform 220ms ease;
}

.correctNameOverlay.show{
  opacity:1;
  transform: translateX(-50%) translateY(-2px);
  animation: neonShift 900ms linear infinite;
}

.correctNameOverlay.fade{
  opacity:0;
  transform: translateX(-50%) translateY(-8px);
}

@keyframes neonShift{
  0%   { color:#ff00ff; text-shadow: 0 0 6px #ff00ff, 0 0 14px #00ffff; }
  33%  { color:#00ffff; text-shadow: 0 0 6px #00ffff, 0 0 14px #ffff00; }
  66%  { color:#ffff00; text-shadow: 0 0 6px #ffff00, 0 0 14px #ff00ff; }
  100% { color:#ff00ff; text-shadow: 0 0 6px #ff00ff, 0 0 14px #00ffff; }
}

/* Confetti canvas */
#confetti{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  pointer-events:none;
  z-index: 4;
}

/* Map stage */
.mapStage{
  position:absolute;
  inset: 10px;
  padding-top: var(--mapTopPad);
  z-index: 3;
  overflow:hidden;
}
.mapViewport{
  width:100%;
  height:100%;
  transform-origin: 0 0;
  transition: transform 70ms ease;
  cursor: grab;
}
.mapViewport.dragging{ cursor: grabbing; }

svg#map{ width:100%; height:100%; display:block; }

.state{
  fill: var(--stateFill);
  stroke: var(--stateStroke);
  stroke-width: 0.9;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill 120ms ease;
}
.state:hover{ fill: var(--stateHover); }
.state:active{ fill: var(--stateActive); }

/* Correct flash */
.state.correct{
  fill: rgba(0,160,0,0.45);
  stroke: #000;
}

/* Wrong: briefly turn red */
.state.wrong{
  fill: rgba(160,0,0,0.55);
  stroke:#000;
}

/* Zoom controls */
.zoomControls{
  position:absolute;
  left: 12px;
  bottom: 12px;
  z-index: 7;
  display:flex;
  flex-direction:column;
  gap:8px;
  pointer-events:none;
}
.zoomControls *{ pointer-events:auto; }

.zoomBtn{
  width: 44px;
  height: 40px;
  border-radius:0;
  background:#fff;
  color:#000;
  border:2px solid #000;
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 #808080;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  user-select:none;
  font-size: 16px;
}
.zoomBtn:active{
  box-shadow: inset -2px -2px 0 #fff, inset 2px 2px 0 #808080;
}

.zoomReadout{
  margin-top:2px;
  padding: 6px 10px;
  border-radius:0;
  border:2px solid #000;
  background:#fff;
  color:#000;
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 #808080;
  font-size: 12px;
  user-select:none;
  text-align:center;
}

/* Toast */
.toast{
  position:absolute;
  right: 14px;
  bottom: 14px;
  z-index: 7;
  background:#ffffcc;
  color:#000;
  border:2px solid #000;
  border-radius:0;
  padding: 10px 12px;
  font-size: 13px;
  opacity:0;
  transform: translateY(8px);
  transition: opacity 200ms ease, transform 200ms ease;
  max-width: 72%;
  pointer-events:none;
}
.toast.show{ opacity:1; transform: translateY(0); }

/* Leaderboards */
.leaderboards{
  width:100%;
  display:grid;
  grid-template-columns: 1fr;
  gap:14px;
}

.leaderboardPanel{ padding: 14px; }

.leaderboardHeader{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
  margin-bottom:10px;
}

.leaderboardTitle{
  font-weight: 950;
  font-size: 16px;
}

.leaderboardHint{
  font-size: 12px;
  color:#000;
  max-width: 820px;
}

.leaderboardBody{
  background:#c0c0c0;
  border-radius:0;
  border:2px solid #000;
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 #808080;
  overflow:hidden;
}

.leaderboardEmpty{
  padding: 12px;
  color:#000;
  font-size: 13px;
}

.lbRow{
  display:grid;
  grid-template-columns: 42px 1.2fr 0.8fr 0.8fr 1.2fr;
  gap:10px;
  padding: 10px 12px;
  border-top: 2px solid #000;
  align-items:center;
  font-size: 13px;
  background:#c0c0c0;
}
.lbRow:first-child{ border-top: none; }

.lbHead{
  font-size: 12px;
  font-weight: 900;
  color:#000;
  background:#fff;
}

.lbRank{
  font-weight: 950;
  text-align:center;
}

.lbName{
  font-weight: 950;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.lbMode{
  display:block;
  margin-top:4px;
  font-size:12px;
  font-weight:700;
}

/* Modal */
.modalBackdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display:none;
  align-items:center;
  justify-content:center;
  padding: 18px;
  z-index: 1000;
}
.modalBackdrop.show{ display:flex; }

.modalCard{
  width: min(560px, 100%);
  border-radius:0;
  border:2px solid #000;
  background:#c0c0c0;
  padding: 14px;
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 #808080;
}

.modalTitle{
  font-weight: 950;
  font-size: 18px;
  margin-bottom: 6px;
}

.modalSub{
  color:#000;
  font-size: 13px;
  line-height: 1.35;
  margin-bottom: 12px;
}

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

.modalLabel{
  font-size: 12px;
  font-weight: 900;
  color:#000;
}

.modalInput{
  width:100%;
  padding: 10px 10px;
  border-radius:0;
  border:2px solid #000;
  background:#fff;
  color:#000;
  outline:none;
  font-weight:700;
}

.modalSelected{
  margin-top: 12px;
  padding: 10px 10px;
  border-radius:0;
  border:2px solid #000;
  background:#fff;
  font-weight: 950;
}

.modalActions{
  margin-top: 12px;
  display:flex;
  gap:10px;
  justify-content:flex-end;
  flex-wrap:wrap;
}

.modalTiny{
  margin-top: 10px;
  font-size: 12px;
  color:#000;
  line-height: 1.35;
  word-break: break-word;
}
