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

/* Title font — matches the ZombieMaze.io logo */
@font-face {
  font-family: 'Ithaca';
  src: url('font/ithaca-font/Ithaca-LVB75.ttf') format('truetype');
  font-display: swap;
}

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: 'Menlo', 'Monaco', monospace;
  color: #eee;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
}

#container {
  position: relative;
  width: 100vw;
  height: 100vh;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #0a0a0a;
}

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  /* Radial gradient so the player can see the world simulating behind the death overlay */
  background:
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0.80) 0%, rgba(0, 0, 0, 0.62) 55%, rgba(0, 0, 0, 0.45) 100%);
  pointer-events: none;
  text-align: center;
}

#overlay.hidden { display: none; }

#overlay h1 {
  font-size: 48px;
  color: #f55;
  letter-spacing: 4px;
  margin-bottom: 8px;
  text-shadow: 0 0 18px rgba(255, 70, 70, 0.5);
}

#overlay p {
  font-size: 16px;
  margin: 4px 0;
}

#overlay .hint {
  margin-top: 12px;
  opacity: 0.75;
  font-size: 13px;
}

#finalStats {
  color: #fff;
  text-align: center;
  margin: 4px 0 8px;
}

.stat-newhigh {
  color: #ffd24a;
  font-size: 18px;
  letter-spacing: 4px;
  margin-bottom: 4px;
}

.stat-prevhigh {
  color: #888;
  font-size: 12px;
  letter-spacing: 2px;
  margin-bottom: 2px;
}

.stat-score {
  font-size: 56px;
  font-weight: bold;
  letter-spacing: 2px;
  margin-bottom: 12px;
}

/* New sectioned stats layout (SURVIVAL / KILLS / COLLECTED) */
.stats-block {
  width: 320px;
  max-width: 90vw;
  margin: 12px auto 4px;
  text-align: left;
}

.stats-section {
  padding: 6px 0 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.stats-section:first-child { border-top: none; padding-top: 0; }
.stats-section:last-child  { padding-bottom: 0; }

.stats-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: #888;
  font-size: 11px;
  letter-spacing: 3px;
  font-weight: bold;
  margin-bottom: 6px;
}

.stats-heading-value {
  color: #fff;
  font-size: 18px;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 14px;
  color: #ccc;
}

.stats-row > span:first-child {
  color: #aaa;
  letter-spacing: 1px;
}

.stats-row > span:last-child {
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

#hsInput {
  margin: 14px 0 6px;
  text-align: center;
  pointer-events: auto;
}

#hsInput.hidden { display: none; }

.hs-input-label {
  color: #ffd24a;
  font-size: 14px;
  letter-spacing: 4px;
  margin-bottom: 8px;
}

#hsInputField {
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 213, 74, 0.6);
  color: #ffd24a;
  font-family: inherit;
  font-size: 26px;
  font-weight: bold;
  letter-spacing: 14px;
  padding: 8px 0 8px 14px;
  width: 110px;
  text-align: center;
  text-transform: uppercase;
  outline: none;
}

#hsInputField:focus {
  border-color: #ffd24a;
  background: rgba(255, 213, 74, 0.1);
}

#hsSubmit {
  background: rgba(255, 213, 74, 0.15);
  border: 2px solid rgba(255, 213, 74, 0.6);
  color: #ffd24a;
  font-family: inherit;
  font-size: 14px;
  padding: 9px 18px;
  margin-left: 8px;
  letter-spacing: 2px;
  cursor: pointer;
  pointer-events: auto;
}

#hsSubmit:hover { background: rgba(255, 213, 74, 0.3); }

#hsTable {
  margin: 12px 0 6px;
  display: inline-block;
}

#hsTable:empty { display: none; }

.hs-table-title {
  color: #888;
  font-size: 12px;
  letter-spacing: 3px;
  margin-bottom: 6px;
  text-align: center;
}

.hs-rows {
  display: grid;
  grid-template-columns: 26px 60px 90px;
  gap: 2px 18px;
  font-size: 14px;
  color: #ccc;
}

.hs-row {
  display: contents;
}

.hs-row > .hs-rank  { color: #777; text-align: right; }
.hs-row > .hs-name  { color: #fff; letter-spacing: 3px; }
.hs-row > .hs-score { color: #fff; text-align: right; font-variant-numeric: tabular-nums; }

.hs-row.hs-new > .hs-rank,
.hs-row.hs-new > .hs-name,
.hs-row.hs-new > .hs-score { color: #ffd24a; }

#controls {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 11px;
  color: #888;
  display: flex;
  gap: 14px;
  pointer-events: none;
  text-shadow: 0 1px 0 #000;
}

#overlay .menu-btn { pointer-events: auto; margin-top: 24px; }

.menu-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  /* Semi-transparent so the live demo game underneath bleeds through. A subtle radial
     gradient darkens the center so the title and buttons stay legible. */
  background:
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0.55) 60%, rgba(0, 0, 0, 0.4) 100%);
  z-index: 20;
  font-family: 'Menlo', 'Monaco', monospace;
}

.menu-overlay.hidden { display: none; }

.menu-overlay .title {
  font-family: 'Ithaca', 'Menlo', 'Monaco', monospace;
  font-size: 88px;
  color: #ff9e00;
  letter-spacing: 4px;
  margin-bottom: 48px;
  text-shadow: 0 0 28px rgba(255, 158, 0, 0.55);
}

.menu-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-family: inherit;
  font-size: 20px;
  padding: 14px 48px;
  margin: 6px 0;
  cursor: pointer;
  letter-spacing: 3px;
  min-width: 240px;
  transition: background 0.12s, border-color 0.12s;
}

.menu-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: #fff;
}

.menu-foot {
  position: absolute;
  bottom: 24px;
  color: #666;
  font-size: 12px;
  letter-spacing: 1px;
}

.setting {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 32px;
}

.setting-label {
  color: #888;
  font-size: 13px;
  letter-spacing: 2px;
  margin-bottom: 14px;
}

.setting-options {
  display: flex;
  gap: 12px;
}

.setting-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  padding: 14px 22px;
  cursor: pointer;
  letter-spacing: 2px;
  transition: background 0.12s, border-color 0.12s;
}

.setting-btn:hover { background: rgba(255, 255, 255, 0.14); }

.setting-btn.active {
  background: rgba(255, 183, 77, 0.22);
  border-color: #ffb74d;
  color: #fff;
}

.setting-btn small {
  display: block;
  font-size: 10px;
  color: #aaa;
  margin-top: 6px;
  letter-spacing: 0;
}

.setting-slider {
  width: 320px;
  margin-bottom: 22px;
}

.setting-slider .setting-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  width: 100%;
  margin-bottom: 10px;
}

.setting-value {
  color: #ffb74d;
  font-size: 12px;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  outline: none;
  cursor: pointer;
  border-radius: 3px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: #ffb74d;
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(255, 183, 77, 0.6);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #ffb74d;
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: pointer;
}

.inv-toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 24px;
  margin-top: 4px;
}

.inv-toggles label {
  color: #ddd;
  font-size: 14px;
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.inv-toggles input[type="checkbox"] {
  accent-color: #ffb74d;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.setting.hidden { display: none; }

/* Character selection grid */
.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  max-height: 56vh;
  width: 560px;
  max-width: 90vw;
  overflow-y: auto;
  padding: 12px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 28px;
}

.char-tile {
  width: 72px;
  height: 72px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  transition: border-color 0.12s, transform 0.12s, filter 0.12s, opacity 0.12s;
  position: relative;
}
.char-tile img {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  display: block;
}

.char-tile.unlocked { cursor: pointer; }
.char-tile.unlocked:hover {
  border-color: rgba(255, 183, 77, 0.6);
  transform: scale(1.06);
}

.char-tile.locked {
  cursor: pointer;
}
.char-tile.locked:hover {
  border-color: rgba(255, 213, 74, 0.55);
  transform: scale(1.04);
}

/* Sprite not yet cropped — darkened, no hover lift, no cost badge */
.char-tile.coming-soon {
  cursor: not-allowed;
  filter: brightness(0.32) saturate(0.4);
}
.char-tile.coming-soon:hover {
  border-color: rgba(255, 255, 255, 0.1);
  transform: none;
}

.char-tile .cost-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  color: #ffd24a;
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 1px;
  background: rgba(0, 0, 0, 0.78);
  padding: 2px 0;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

/* Shake feedback when the player can't afford an unlock */
@keyframes char-shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-3px); }
  40%      { transform: translateX(3px); }
  60%      { transform: translateX(-2px); }
  80%      { transform: translateX(2px); }
}
.char-tile.shake { animation: char-shake 0.32s ease-out; }

/* Bright pulse when unlocking */
@keyframes char-unlock {
  0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(255, 213, 74, 0.85); }
  50%  { transform: scale(1.18); box-shadow: 0 0 18px 8px rgba(255, 213, 74, 0.55); }
  100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(255, 213, 74, 0); }
}
.char-tile.unlocking { animation: char-unlock 0.55s ease-out; }

/* Bank coins line at the top of the CHARACTERS menu */
.char-bank-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
  background: rgba(0, 0, 0, 0.45);
  padding: 8px 18px;
  border-radius: 6px;
  border: 1px solid rgba(255, 213, 74, 0.25);
}
.char-bank-label {
  color: #888;
  font-size: 11px;
  letter-spacing: 3px;
}
.char-bank-value {
  color: #ffd24a;
  font-size: 22px;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

/* Tiny inline coin "icon" used in the bank line and cost badges */
.cost-coin {
  display: inline-block;
  width: 11px;
  height: 11px;
  background: #ffd24a;
  border: 1.5px solid #a8761a;
  border-radius: 50%;
  margin: 0 2px;
  vertical-align: middle;
}

.char-grid::-webkit-scrollbar { width: 10px; }
.char-grid::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 5px;
}
.char-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 183, 77, 0.45);
  border-radius: 5px;
}
.char-grid::-webkit-scrollbar-thumb:hover { background: rgba(255, 183, 77, 0.7); }

/* Game-over button row */
.gameover-buttons {
  display: flex;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
  justify-content: center;
  pointer-events: auto;
}
.gameover-buttons .menu-btn {
  min-width: 160px;
  padding: 11px 22px;
  margin: 0;
  font-size: 16px;
}

/* Welcome (first-launch) + HOW TO PLAY overlays */
.welcome-name-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
#welcomeNameField, #settingsNameField {
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 158, 0, 0.55);
  color: #ffb74d;
  font-family: inherit;
  font-size: 22px;
  font-weight: bold;
  letter-spacing: 6px;
  padding: 10px 16px;
  width: 280px;
  text-align: center;
  text-transform: uppercase;
  outline: none;
  border-radius: 4px;
}
#welcomeNameField:focus, #settingsNameField:focus {
  border-color: #ffb74d;
  background: rgba(255, 183, 77, 0.08);
}

.setting-name {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 30px;
}

.howto-card {
  width: 460px;
  max-width: 92vw;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 18px 22px;
  margin-bottom: 24px;
  text-align: left;
}
.howto-card-title {
  color: #888;
  font-size: 11px;
  letter-spacing: 3px;
  margin-bottom: 12px;
}
.howto-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 18px;
  font-size: 14px;
}
.howto-row { display: contents; }
.howto-row > .howto-key {
  display: inline-block;
  min-width: 56px;
  text-align: center;
  background: rgba(255, 158, 0, 0.18);
  border: 1px solid rgba(255, 158, 0, 0.5);
  color: #ffb74d;
  font-weight: bold;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 1px;
}
.howto-row > span:last-child { color: #ccc; align-self: center; }
.howto-tips {
  color: #aaa;
  font-size: 12px;
  letter-spacing: 0.5px;
  line-height: 1.5;
  margin-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 12px;
}
