:root {
  --bg: #0b0b0f;
  --fg: #ffffff;
  --accent: #f6c948;
  --pill: rgba(0, 0, 0, 0.55);
  --font: "Press Start 2P", "Courier New", monospace;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

#stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
}

#cam {
  /* hidden: the canvas draws the mirrored feed itself */
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

#game {
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
  image-rendering: pixelated;
  background: #000;
}

.pill {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  font: 10px/1 var(--font);
  color: var(--fg);
  background: var(--pill);
  padding: 8px 10px;
  border-radius: 999px;
  border: 0;
  z-index: 3;
}
#status {
  left: 12px;
  max-width: calc(100% - 120px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#status.ok { color: #7cf29a; }
#status.bad { color: #ff7b7b; }
#mute {
  right: 12px;
  font-size: 14px;
  cursor: pointer;
}
#mode {
  top: auto;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  color: var(--accent);
  cursor: pointer;
  letter-spacing: 1px;
}
#board {
  right: 56px;
  font-size: 14px;
  cursor: pointer;
}

.seg {
  display: inline-flex;
  max-width: 100%;
  border: 3px solid #3d1c12;
  background: #1a1a22;
  margin: 0 0 18px;
}
.seg button {
  font: 10px/1 var(--font);
  color: #b8bccb;
  background: transparent;
  border: 0;
  padding: 12px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.seg button.active {
  color: #000;
  background: var(--accent);
}

#intro {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  overflow-y: auto;
  padding: 24px 16px;
  background: linear-gradient(180deg, rgba(5, 6, 12, 0.35) 0%, rgba(5, 6, 12, 0.72) 60%, rgba(5, 6, 12, 0.9) 100%);
}
#intro[hidden] { display: none; }
body.in-intro #stage .pill { display: none; }

.hero {
  width: min(560px, 100%);
  background: rgba(11, 11, 15, 0.82);
  border: 4px solid var(--accent);
  box-shadow: 8px 8px 0 #000;
  padding: 28px 22px 22px;
  text-align: center;
  font-family: var(--body);
}
.hero-top { margin-bottom: 22px; }
.hero-bird {
  width: 88px;
  height: 88px;
  image-rendering: pixelated;
  animation: bob 1.6s ease-in-out infinite;
  filter: drop-shadow(4px 4px 0 rgba(0, 0, 0, 0.6));
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-10px) rotate(6deg); }
}
.hero h1 {
  font: 26px/1.2 var(--font);
  color: var(--accent);
  text-shadow: 4px 4px 0 #000;
  margin: 10px 0 12px;
}
.tagline {
  font-size: 17px;
  line-height: 1.5;
  color: #d7dbe8;
  margin: 0;
}
.tagline b { color: var(--fg); }

.modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 0 14px;
}
.modes button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 6px 12px;
  background: #16161e;
  border: 3px solid #2c2c38;
  color: #b8bccb;
  cursor: pointer;
  font-family: var(--body);
  transition: transform 0.1s, border-color 0.1s;
}
.modes button:hover { transform: translateY(-2px); border-color: #55556a; }
.modes button.active {
  background: #2a2410;
  border-color: var(--accent);
  color: var(--fg);
  box-shadow: 4px 4px 0 #000;
}
.modes .ico { font-size: 30px; line-height: 1; }
.modes .name { font: 9px/1 var(--font); letter-spacing: 0.5px; }
.modes .sub { font-size: 11px; line-height: 1.3; color: #8b91a3; }
.modes button.active .sub { color: #d7dbe8; }

.hint {
  font-size: 15px;
  line-height: 1.55;
  color: #d7dbe8;
  margin: 0 0 22px;
  min-height: 2.6em;
}

.steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 0 24px;
  padding: 0;
}
.steps li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  line-height: 1.35;
  color: #d7dbe8;
}
.steps b {
  font: 12px/1 var(--font);
  color: #000;
  background: var(--accent);
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 3px solid #000;
}

.cta { display: flex; flex-direction: column; gap: 12px; align-items: center; margin-bottom: 16px; }
#start {
  width: 100%;
  max-width: 340px;
  font: 16px/1 var(--font);
  color: #000;
  background: var(--accent);
  border: 0;
  border-bottom: 6px solid #a8841f;
  padding: 20px 20px;
  cursor: pointer;
}
#start:active { transform: translateY(3px); border-bottom-width: 3px; }
.secondary {
  font: 10px/1 var(--font);
  color: var(--accent);
  background: transparent;
  border: 3px solid var(--accent);
  padding: 12px 16px;
  cursor: pointer;
}
.tiny { font-size: 11px; line-height: 1.5; color: #8b91a3; margin: 0; }

@media (max-width: 420px) {
  .hero { padding: 22px 14px 18px; }
  .hero h1 { font-size: 20px; }
  .tagline { font-size: 15px; }
  .modes { gap: 6px; }
  .modes .ico { font-size: 24px; }
  .modes .name { font-size: 7px; }
  .modes .sub { font-size: 10px; }
  .steps li { font-size: 12px; }
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  overflow-y: auto;
  padding: 20px;
  background: rgba(5, 6, 12, 0.88);
}
.overlay[hidden] { display: none; }

.card.board {
  width: min(460px, 100%);
  background: #ded895;
  color: #3d1c12;
  border: 4px solid #3d1c12;
  box-shadow: 6px 6px 0 #000;
  padding: 16px;
  text-align: left;
}
.board-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.board-head h2 {
  font-size: 16px;
  margin: 0;
  color: #e0432b;
  text-shadow: 2px 2px 0 #fff;
}
#board-close {
  font: 14px/1 var(--font);
  background: transparent;
  border: 0;
  color: #3d1c12;
  cursor: pointer;
}
.name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 9px;
  margin-bottom: 14px;
}
.name-row input {
  flex: 1;
  min-width: 0;
  font: 11px/1 var(--font);
  text-transform: uppercase;
  padding: 8px;
  border: 3px solid #3d1c12;
  background: #fff8d6;
  color: #3d1c12;
}
.card.board .seg { display: flex; width: 100%; margin-bottom: 12px; background: #3d1c12; }
.card.board .seg button { flex: 1; padding: 12px 4px; font-size: 9px; color: #ded895; }
.card.board .seg button.active { color: #000; background: var(--accent); }

#board-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  font-size: 10px;
}
#board-list li {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  gap: 10px;
  align-items: baseline;
  padding: 8px 6px;
  border-bottom: 2px dashed rgba(61, 28, 18, 0.35);
}
#board-list li.me { background: rgba(246, 201, 72, 0.45); }
#board-list li .rank { color: #e0432b; }
#board-list li .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#board-list li .when { font-size: 7px; color: #6b4a3a; }
#board-list li.empty { display: block; text-align: center; color: #6b4a3a; font-size: 9px; padding: 18px 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.stats div {
  background: #fff8d6;
  border: 2px solid #3d1c12;
  padding: 8px 4px;
  text-align: center;
}
.stats b { display: block; font-size: 14px; margin-bottom: 6px; }
.stats span { font-size: 6px; color: #6b4a3a; }

.link {
  font: 8px/1 var(--font);
  background: transparent;
  border: 0;
  color: #6b4a3a;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 0;
}

