:root {
  --bg-light: #f5f5f5;
  --bg-soft: #fafafa;
  --ink: #2c3e50;
  --ink-soft: #546e7a;
  --muted: #78909c;
  --line: rgba(0, 0, 0, 0.08);
  --card: #ffffff;
  --accent: #5c6bc0;
  --accent-soft: rgba(92, 107, 192, 0.1);
  --green: #66bb6a;
  --red: #ef5350;
  --shadow: rgba(0, 0, 0, 0.08);
  font-family: "Courier New", "Courier", monospace;
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-light);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  position: relative;
}

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

.page {
  width: 100%;
  height: 100vh;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  z-index: 1;
}

#landing {
  justify-content: center;
}

.hidden {
  display: none !important;
}

.hero {
  text-align: center;
  padding: 4px 0;
}

.hero h1 {
  margin: 4px 0;
  font-size: 48px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--ink);
  position: relative;
  text-transform: uppercase;
}

.subtitle {
  margin: 6px auto 0;
  color: var(--ink-soft);
  max-width: 640px;
  line-height: 1.5;
  font-size: 15px;
  font-weight: 500;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 8px;
}

.mode-selector {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin: 20px 0;
}

.mode-btn {
  min-width: 200px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 30px;
  position: relative;
  z-index: 1;
  justify-content: center;
}

/* Leaderboard styling */
ol {
  list-style: none;
  counter-reset: item;
  padding: 0;
  margin: 10px 0 0;
}

ol li {
  counter-increment: item;
  padding: 12px 14px;
  margin-bottom: 8px;
  background: var(--bg-soft);
  border: 3px solid var(--line);
  position: relative;
  color: var(--ink);
  font-weight: 500;
  transition: all 0.2s ease;
}

ol li:hover {
  background: #ffffff;
  border-color: var(--accent);
  transform: translateX(4px);
}

ol li::before {
  content: counter(item);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-right: 12px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  font-size: 13px;
}

ol li:first-child {
  background: #fff9e6;
  border-color: #ffc107;
}

ol li:first-child::before {
  background: #ffc107;
}

.card {
  background: var(--card);
  border: 3px solid var(--ink);
  padding: 28px;
  box-shadow: 4px 4px 0 var(--shadow);
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
}

.card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--shadow);
}

.card.slim {
  max-width: 560px;
  margin: 0 auto;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}

.card h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}

.card h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}

.mono {
  font-family: inherit;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

label {
  display: block;
  margin: 14px 0 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  position: relative;
  z-index: 1;
}

input[type="text"] {
  width: 100%;
  margin-top: 8px;
  padding: 14px 16px;
  border: 3px solid var(--ink);
  background: var(--bg-soft);
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  transition: all 0.2s ease;
  font-family: inherit;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 3px 3px 0 var(--accent-soft);
}

input[type="text"]::placeholder {
  color: var(--muted);
  opacity: 0.5;
}

input[type="range"] {
  width: 100%;
  margin-top: 8px;
  height: 8px;
  background: var(--accent);
  opacity: 0.3;
  outline: none;
  -webkit-appearance: none;
  transition: opacity 0.2s ease;
}

input[type="range"]:hover {
  opacity: 0.5;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid white;
  box-shadow: 2px 2px 0 var(--shadow);
  transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid white;
  box-shadow: 2px 2px 0 var(--shadow);
  transition: all 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.1);
}

.hint {
  display: inline-block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  opacity: 0.8;
}

button {
  border: 3px solid var(--ink);
  background: var(--accent);
  color: #fff;
  padding: 16px 28px;
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  position: relative;
  transition: all 0.1s ease;
  box-shadow: 4px 4px 0 var(--ink);
  font-family: inherit;
}

button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--ink);
  background: #4a5cb8;
}

button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

button.small {
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 700;
}

button.ghost {
  background: #ffffff;
  border: 3px solid var(--ink);
  color: var(--accent);
  font-weight: 700;
  box-shadow: 3px 3px 0 var(--ink);
}

button.ghost:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--ink);
}

button.ghost:active {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 var(--ink);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: 3px 3px 0 var(--ink);
}

.play-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 8px;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.side-head {
  background: var(--card);
  border: 3px solid var(--ink);
  padding: 12px;
  box-shadow: 3px 3px 0 var(--shadow);
  position: relative;
  overflow: hidden;
}

.room-line {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 8px 0;
  position: relative;
  z-index: 1;
}

.side-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  position: relative;
  z-index: 1;
}

.side-card {
  background: var(--card);
  border: 3px solid var(--ink);
  padding: 12px;
  box-shadow: 3px 3px 0 var(--shadow);
  position: relative;
  overflow: hidden;
}

.bullets {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--ink);
  position: relative;
  z-index: 1;
}

.bullets li {
  margin-bottom: 8px;
  line-height: 1.6;
  font-weight: 500;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--accent-soft);
  border: 3px solid var(--accent);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.pill.muted {
  background: var(--bg-soft);
  border-color: var(--muted);
  color: var(--muted);
}

.board-wrap {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
}

.play-area {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border: 3px solid var(--ink);
  background: #ffffff;
  box-shadow: 4px 4px 0 var(--shadow);
  overflow: hidden;
  padding: 8px;
}

canvas {
  display: block;
  width: 90vh !important;
  height: 90vh !important;
  max-width: 90vh;
  max-height: 90vh;
  background: #fafafa;
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--shadow);
  position: relative;
  z-index: 1;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

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

.overlay.hidden {
  display: none;
}

.overlay-card {
  background: #ffffff;
  border: 4px solid var(--ink);
  padding: 40px 44px;
  text-align: center;
  min-width: 360px;
  box-shadow: 6px 6px 0 var(--shadow);
  position: relative;
  overflow: hidden;
}

.overlay-card h2 {
  margin: 0 0 16px;
  font-size: 32px;
  font-weight: 700;
  color: var(--ink);
  position: relative;
  z-index: 1;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.overlay-card p {
  margin: 0 0 16px;
  color: var(--ink-soft);
  font-size: 16px;
  font-weight: 500;
  position: relative;
  z-index: 1;
}

.overlay-leaders {
  margin: 20px 0 0;
  padding-left: 24px;
  text-align: left;
  color: var(--ink);
  position: relative;
  z-index: 1;
}

.footer {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.mini-card {
  background: var(--card);
  border: 3px solid var(--ink);
  padding: 18px;
  box-shadow: 3px 3px 0 var(--shadow);
}

.mini-card ol {
  margin: 10px 0 0;
  padding-left: 20px;
  color: var(--ink-soft);
}

.mini-card li {
  margin-bottom: 6px;
}

.muted {
  color: var(--muted);
}

/* Status and info text */
#status {
  font-size: 13px;
  padding: 6px 0;
  position: relative;
  z-index: 1;
}

/* Pixelated fade-in animation */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card, .side-card, .side-head {
  animation: fadeInUp 0.3s ease-out;
}

.card:nth-child(1) {
  animation-delay: 0.05s;
}

.card:nth-child(2) {
  animation-delay: 0.1s;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--bg-soft);
}

::-webkit-scrollbar-thumb {
  background: var(--muted);
  border: 2px solid rgba(255, 255, 255, 0.5);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ink-soft);
}

@media (max-width: 1200px) {
  .play-shell {
    grid-template-columns: 240px 1fr;
  }
  .side-card, .side-head {
    padding: 12px;
  }
}

@media (max-width: 900px) {
  .page {
    padding: 18px 16px;
  }
  .play-shell {
    grid-template-columns: 1fr;
  }
  .side {
    order: 2;
  }
  .hero h1 {
    font-size: 36px;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .mode-selector {
    flex-direction: column;
    align-items: center;
  }
  .mode-btn {
    width: 100%;
    max-width: 300px;
  }
}

