@font-face {
  font-family: 'PS2P';
  src: url('../fonts/PressStart2P.ttf') format('truetype');
  font-display: block;
}

:root {
  --burgundy: #7b2d43;
  --plum: #9c4368;
  --rose: #e58cb6;
  --pink: #f3c9dd;
  --olive: #a8b545;
  --olive-dark: #6e7a2a;
  --cream: #f8f7e4;
  --pale: #f2f0c0;
  --night: #2a1420;
  --black: #1a0d13;
}

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

html, body {
  height: 100%;
}

body {
  font-family: 'PS2P', monospace;
  background: var(--night);
  background-image:
    linear-gradient(rgba(123, 45, 67, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(123, 45, 67, 0.12) 1px, transparent 1px);
  background-size: 16px 16px;
  color: var(--cream);
  -webkit-font-smoothing: none;
  image-rendering: pixelated;
  touch-action: manipulation;
}

button { font-family: inherit; cursor: pointer; }

/* ------------------------------------------------------------- hub page */

.hub {
  max-width: 900px;
  margin: 0 auto;
  padding: 12px 12px 48px;
}

.hub-top {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 4px 0;
}

.lang-btn, .pixel-btn {
  background: var(--cream);
  color: var(--black);
  border: 3px solid var(--black);
  box-shadow: 3px 3px 0 var(--black);
  padding: 6px 10px;
  font-size: 10px;
  text-transform: uppercase;
}

.lang-btn.active { background: var(--olive); }
.lang-btn:active, .pixel-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--black); }

.banner-wrap {
  border: 4px solid var(--black);
  box-shadow: 5px 5px 0 var(--black);
  margin: 8px 0 4px;
  line-height: 0;
  background: var(--sky, #9ad7e8);
}

#banner { width: 100%; height: auto; image-rendering: pixelated; }

.subtitle {
  text-align: center;
  color: var(--rose);
  font-size: 9px;
  margin: 14px 0 20px;
  line-height: 1.8;
}

/* "press start" blinking underscore after the subtitle */
.subtitle::after {
  content: '_';
  color: var(--pale);
  animation: blink 1s steps(1) infinite;
}

.player-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--burgundy);
  border: 3px solid var(--black);
  box-shadow: 4px 4px 0 var(--black);
  padding: 10px 12px;
  margin-bottom: 24px;
  font-size: 10px;
}

.player-bar .nick { color: var(--pale); }
.player-bar .stats { color: var(--pink); }
.player-bar .edit-nick {
  background: var(--rose);
  border: 2px solid var(--black);
  font-size: 8px;
  padding: 4px 6px;
}

.nick-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.nick-form[hidden] { display: none; }
.nick-form input {
  font-family: inherit;
  font-size: 10px;
  padding: 6px;
  border: 3px solid var(--black);
  background: var(--cream);
  color: var(--black);
  width: 180px;
}

h2.group-title {
  font-size: 11px;
  color: var(--olive);
  text-transform: uppercase;
  margin: 22px 0 12px;
  text-shadow: 2px 2px 0 var(--black);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  display: block;
  text-decoration: none;
  color: var(--black);
  background: var(--cream);
  border: 3px solid var(--black);
  box-shadow: 4px 4px 0 var(--black);
  transition: transform 0.12s, box-shadow 0.12s;
  animation: card-pop 0.35s calc(var(--i, 0) * 45ms) backwards;
  outline: none;
}

@keyframes card-pop {
  0% { opacity: 0; transform: translateY(14px) scale(0.9); }
  70% { opacity: 1; transform: translateY(-3px) scale(1.03); }
  100% { opacity: 1; transform: none; }
}

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

/* retro menu cursor: pulsing frame + blinking ► on the selected card */
.card.selected {
  transform: translate(-2px, -2px);
  animation:
    card-pop 0.35s calc(var(--i, 0) * 45ms) backwards,
    sel-glow 0.9s steps(2, jump-none) infinite;
}

@keyframes sel-glow {
  0%, 100% { box-shadow: 6px 6px 0 var(--black), 0 0 0 3px var(--rose); }
  50% { box-shadow: 6px 6px 0 var(--black), 0 0 0 3px var(--pale); }
}

.card.selected::after {
  content: '\25B6';
  position: absolute;
  top: 5px;
  left: 6px;
  font-size: 10px;
  color: var(--black);
  animation: blink 0.7s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.card .top {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  font-size: 28px;
  border-bottom: 3px solid var(--black);
}

.card:not(.soon):hover .icon, .card.selected .icon { animation: icon-bounce 0.55s infinite; }

@keyframes icon-bounce {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
  60% { transform: translateY(2px); }
}

.card .icon { display: inline-block; }

.card .body { padding: 8px; }
.card .name { font-size: 9px; margin-bottom: 6px; line-height: 1.5; }
.card .meta { font-size: 8px; color: #6b5560; line-height: 1.6; }
.card.soon { opacity: 0.55; cursor: default; }
.card.soon .badge {
  display: inline-block;
  background: var(--plum);
  color: var(--cream);
  font-size: 7px;
  padding: 3px 5px;
  border: 2px solid var(--black);
}

.card .badge.daily {
  display: inline-block;
  background: var(--olive);
  color: var(--black);
  font-size: 7px;
  padding: 3px 5px;
  border: 2px solid var(--black);
  margin-top: 5px;
  animation: badge-pulse 1.2s steps(2, jump-none) infinite;
}

@keyframes badge-pulse { 50% { background: var(--pale); } }

/* ------------------------------------------------------------- leaderboard */

.board {
  background: var(--burgundy);
  border: 3px solid var(--black);
  box-shadow: 4px 4px 0 var(--black);
  padding: 12px;
  margin-top: 10px;
}

.board-controls { display: flex; gap: 8px; flex-wrap: wrap; }

.team-line {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 8px;
  padding: 6px 2px;
}

.team-line .team-name { color: var(--pale); overflow: hidden; text-overflow: ellipsis; }
.team-line .team-bar {
  display: block;
  height: 12px;
  background: rgba(26, 13, 19, 0.5);
  border: 2px solid var(--black);
}
.team-line .team-fill {
  display: block;
  height: 100%;
  background: var(--olive);
  animation: fill-grow 0.9s cubic-bezier(0.2, 0.7, 0.3, 1) calc(var(--i, 0) * 80ms) backwards;
}

@keyframes fill-grow { from { width: 0; } }
.team-line:nth-child(1) .team-fill { background: var(--pale); }
.team-line .team-pts { color: var(--pink); white-space: nowrap; }

.team-tag { color: var(--pale); font-size: 10px; }
#team-select {
  font-family: inherit;
  font-size: 10px;
  padding: 6px;
  border: 3px solid var(--black);
  background: var(--cream);
  color: var(--black);
}

/* ---------------------------------------------------------------- kiosk */

body.kiosk-mode { overflow: hidden; }

#kiosk {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 30px;
  text-align: center;
}

#kiosk .banner-wrap { max-width: 560px; margin: 0 auto; }
#kiosk .banner-wrap canvas { width: 100%; height: auto; }

#kiosk h1 {
  font-size: 22px;
  color: var(--pale);
  text-shadow: 3px 3px 0 var(--black);
  margin: 22px 0;
  text-transform: uppercase;
}

#kiosk ol { list-style: none; max-width: 700px; margin: 0 auto; }
#kiosk li {
  display: flex;
  justify-content: space-between;
  font-size: 16px;
  padding: 10px 6px;
  border-bottom: 3px solid rgba(123, 45, 67, 0.5);
  line-height: 1.4;
}
#kiosk li .who { color: var(--pink); }
#kiosk li .pts { color: var(--pale); }
#kiosk li:nth-child(1) .who { color: var(--pale); }
#kiosk .team-line { font-size: 13px; grid-template-columns: 170px 1fr auto; max-width: 800px; margin: 0 auto; }
#kiosk .team-line .team-bar { height: 20px; }
#kiosk .empty { font-size: 13px; color: var(--pink); }

.board select {
  font-family: inherit;
  font-size: 9px;
  padding: 6px;
  border: 3px solid var(--black);
  background: var(--cream);
  color: var(--black);
  max-width: 100%;
  margin-bottom: 10px;
}

.board ol { list-style: none; }
.board li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 9px;
  padding: 6px 4px;
  border-bottom: 2px solid rgba(26, 13, 19, 0.4);
  line-height: 1.4;
}

.board li { animation: row-in 0.3s calc(var(--i, 0) * 40ms) backwards; }

@keyframes row-in {
  from { opacity: 0; transform: translateX(-10px); }
}

.board li .who { color: var(--pink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board li .pts { color: var(--pale); flex-shrink: 0; }
.board li:nth-child(1) .who { color: var(--pale); }
.board .empty { font-size: 9px; color: var(--pink); padding: 8px 2px; line-height: 1.6; }

footer {
  text-align: center;
  font-size: 8px;
  color: var(--plum);
  margin-top: 36px;
  line-height: 2;
}
footer a { color: var(--rose); }

/* ------------------------------------------------------------- game page */

body.game-page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.game-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  font-size: 9px;
}

.game-head a { color: var(--rose); text-decoration: none; }
.game-head .gname { color: var(--pale); }

#stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  position: relative;
}

#screen {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 4px solid var(--black);
  box-shadow: 6px 6px 0 var(--black);
  background: var(--black);
}

/* CRT scanlines */
#stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 2px,
    rgba(0, 0, 0, 0.08) 2px 4px
  );
}

#touch-controls {
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 8px 14px 16px;
  gap: 10px;
  user-select: none;
  -webkit-user-select: none;
}

.tpad { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tpad-row { display: flex; gap: 34px; }
.tactions { display: flex; gap: 14px; align-items: center; }

.tbtn {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  border: 3px solid var(--black);
  box-shadow: 0 4px 0 var(--black);
  background: var(--plum);
  color: var(--cream);
  font-family: inherit;
  font-size: 16px;
  touch-action: none;
}

.tbtn.act { background: var(--olive); border-radius: 50%; width: 64px; height: 64px; font-size: 13px; }
.tbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--black); }

@media (max-width: 480px) {
  .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card .top { height: 44px; font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
