:root {
  --bg: #0d0a12;
  --panel: #1a1424;
  --panel-2: #241c32;
  --ink: #f2e8d5;
  --muted: #9a8fb0;
  --accent: #ff6b4a;
  --accent-2: #ffd166;
  --good: #5dde8a;
  --bad: #ff4d6d;
  --pixel: 4px;
  --font: "Courier New", "Lucida Console", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  image-rendering: pixelated;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at 50% 20%, #183848 0%, transparent 55%),
    radial-gradient(ellipse at 80% 90%, #1a3040 0%, transparent 40%),
    linear-gradient(180deg, #0e1a24 0%, #0a1218 100%);
}

#scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.12) 2px,
    rgba(0, 0, 0, 0.12) 4px
  );
  mix-blend-mode: multiply;
}

#crt-glow {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 49;
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.55);
}

.screen {
  display: none;
  width: min(920px, 96vw);
  max-height: 96vh;
  overflow: auto;
  z-index: 1;
}

.screen.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.pixel-frame {
  background: var(--panel);
  border: 4px solid #3d2f52;
  box-shadow:
    0 0 0 4px #0a0610,
    8px 8px 0 #050308,
    inset 0 0 0 2px #5a4878;
  padding: 24px 28px;
  position: relative;
}

.title-frame {
  text-align: center;
  padding-top: 28px;
  padding-bottom: 20px;
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.25em;
  margin-bottom: 10px;
}

.logo {
  line-height: 0.95;
  margin-bottom: 8px;
}

.logo-shark {
  display: block;
  font-size: clamp(42px, 9vw, 72px);
  color: #4ecdc4;
  text-shadow:
    4px 0 0 #1a6a66,
    0 4px 0 #1a6a66,
    4px 4px 0 #0a3030;
  letter-spacing: 0.06em;
}

.logo-dentist {
  display: block;
  font-size: clamp(28px, 6vw, 44px);
  color: var(--accent-2);
  text-shadow:
    3px 0 0 #8a6a20,
    0 3px 0 #8a6a20;
  letter-spacing: 0.18em;
}

.tagline {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.12em;
  margin: 10px 0 6px;
}

#title-anim {
  display: block;
  margin: 8px auto 16px;
  width: 320px;
  max-width: 100%;
  image-rendering: pixelated;
  background: #120e1a;
  border: 3px solid #3d2f52;
}

.menu-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 280px;
  margin: 0 auto;
}

.btn {
  font-family: var(--font);
  font-size: 14px;
  letter-spacing: 0.08em;
  padding: 12px 16px;
  background: var(--panel-2);
  color: var(--ink);
  border: 3px solid #5a4878;
  cursor: pointer;
  text-transform: uppercase;
  transition: transform 0.05s, background 0.1s;
}

.btn:hover:not(:disabled) {
  background: #322644;
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.btn:active:not(:disabled) {
  transform: translate(2px, 2px);
}

.btn.primary {
  background: #3a2218;
  border-color: var(--accent);
  color: var(--accent);
}

.btn.primary:hover:not(:disabled) {
  background: #4a2c20;
  color: #fff;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.version {
  margin-top: 16px;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.15em;
}

.panel h2, .map-frame h2 {
  text-align: center;
  color: var(--accent-2);
  letter-spacing: 0.15em;
  margin-bottom: 8px;
  font-size: 22px;
}

.sub {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 16px;
}

.how-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0 24px;
  text-align: left;
}

.how-grid h3 {
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.12em;
  margin-bottom: 6px;
}

.how-grid p {
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink);
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 2px solid #5a4878;
  background: #120e1a;
  font-size: 11px;
}

.credits-block {
  text-align: center;
  line-height: 1.8;
  font-size: 13px;
  letter-spacing: 0.06em;
  margin: 20px 0 28px;
  color: var(--ink);
}

.hud-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 3px solid #3d2f52;
}

.hud-bar .label {
  color: var(--muted);
  margin-right: 4px;
}

.level-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  max-height: 52vh;
  overflow: auto;
  padding-right: 4px;
  margin-bottom: 16px;
}

.level-card {
  text-align: left;
  background: var(--panel-2);
  border: 3px solid #3d2f52;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.1s;
}

.level-card:hover:not(.locked) {
  border-color: var(--accent-2);
}

.level-card.locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.level-card.cleared {
  border-color: #2a5a3a;
}

.level-card .diff {
  font-size: 10px;
  letter-spacing: 0.14em;
  margin-bottom: 4px;
}

.level-card .diff.easy { color: var(--good); }
.level-card .diff.medium { color: var(--accent-2); }
.level-card .diff.hard { color: var(--accent); }
.level-card .diff.nightmare { color: var(--bad); }

.level-card .name {
  font-size: 14px;
  margin-bottom: 4px;
}

.level-card .meta {
  font-size: 11px;
  color: var(--muted);
}

.map-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.shop-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 55vh;
  overflow: auto;
  margin-bottom: 16px;
}

.shop-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  background: var(--panel-2);
  border: 3px solid #3d2f52;
  padding: 12px;
  text-align: left;
}

.shop-item.owned {
  border-color: #2a5a3a;
}

.shop-item .name {
  color: var(--accent-2);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.shop-item .desc {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}

.shop-item .buy {
  white-space: nowrap;
}

.game-wrap {
  position: relative;
  background: var(--panel);
  border: 4px solid #3d2f52;
  box-shadow: 0 0 0 4px #0a0610, 8px 8px 0 #050308;
  padding: 10px;
}

#game {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  background: #1a1020;
  cursor: crosshair;
  image-rendering: pixelated;
  outline: none;
  border: 3px solid #2a1e38;
  margin: 0 auto;
}

.game-hud {
  margin-bottom: 8px;
  border-bottom: none;
  padding-bottom: 0;
}

.bar {
  display: inline-block;
  vertical-align: middle;
  width: 72px;
  height: 10px;
  background: #120e1a;
  border: 2px solid #5a4878;
  position: relative;
}

.bar i {
  display: block;
  height: 100%;
  background: var(--good);
  width: 100%;
}

.bar.stress i {
  background: var(--bad);
}

.tool-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 8px;
}

.tool-slot {
  min-width: 72px;
  padding: 6px 8px;
  background: #120e1a;
  border: 3px solid #3d2f52;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
}

.tool-slot .key {
  display: block;
  color: var(--accent-2);
  font-size: 11px;
  margin-bottom: 2px;
}

.tool-slot.active {
  border-color: var(--accent);
  color: var(--ink);
  background: #2a1818;
}

.tool-slot.disabled {
  opacity: 0.3;
  pointer-events: none;
}

.grip-meter {
  position: absolute;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%);
  width: min(360px, 90%);
  background: rgba(18, 14, 26, 0.92);
  border: 3px solid var(--accent-2);
  padding: 8px 12px;
  z-index: 5;
}

.grip-meter.hidden { display: none; }

.grip-label {
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--accent-2);
  margin-bottom: 4px;
}

.grip-track {
  position: relative;
  height: 16px;
  background: #2a1e38;
  border: 2px solid #5a4878;
  overflow: hidden;
}

.grip-sweet {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(93, 222, 138, 0.45);
  border-left: 2px solid var(--good);
  border-right: 2px solid var(--good);
}

.grip-needle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent);
  left: 0%;
  box-shadow: 0 0 6px var(--accent);
}

.grip-hint {
  text-align: center;
  font-size: 9px;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: 0.1em;
}

.toast {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 14, 26, 0.95);
  border: 3px solid var(--accent);
  padding: 8px 16px;
  font-size: 12px;
  letter-spacing: 0.1em;
  z-index: 6;
  white-space: nowrap;
  pointer-events: none;
}

.toast.good { border-color: var(--good); color: var(--good); }
.toast.bad { border-color: var(--bad); color: var(--bad); }
.toast.hidden { display: none; }

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 4, 12, 0.78);
  display: grid;
  place-items: center;
  z-index: 10;
}

.overlay.hidden { display: none; }

.mini {
  text-align: center;
  min-width: 220px;
}

.mini h2 {
  margin-bottom: 16px;
  color: var(--accent-2);
  letter-spacing: 0.15em;
}

.mini .btn {
  display: block;
  width: 100%;
  margin-bottom: 8px;
}

.results-body {
  text-align: center;
  font-size: 13px;
  line-height: 1.9;
  letter-spacing: 0.06em;
  margin: 16px 0 24px;
}

@media (max-width: 640px) {
  .how-grid {
    grid-template-columns: 1fr;
  }
  .pixel-frame {
    padding: 16px;
  }
  .level-list {
    max-height: 40vh;
  }
  .grip-meter {
    bottom: 100px;
  }
}
