/* Akads Leaderboards -- a deliberate break from the quiz app's Bluebook skin.
   Everything here is hard-edged: no border-radius, no gradients on chrome, no
   soft shadows. The palette is a dark CRT with the two Akads brand colours
   carried through so the two apps still look related. */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
  --bg: #0b0a18;
  --bg-2: #141130;
  --panel: #1c1840;
  --panel-2: #262059;
  --ink: #f4f1ff;
  --ink-dim: #9f97d4;
  --line: #4a3f8f;
  --accent: #ed5531;        /* akads orange */
  --accent-2: #5a6cd8;      /* akads blue, lifted for contrast on dark */
  --gold: #ffcf3f;
  --silver: #d3dcea;
  --bronze: #e08a4a;
  --good: #5ce08a;
  --bad: #ff6b6b;

  /* Numerals and chrome only. The name stack is separate: a username can be any
     unicode a student liked the look of, and a pixel font has ~200 glyphs. */
  --font-pixel: 'Press Start 2P', 'Courier New', monospace;
  --font-name: ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas, monospace;

  --edge: 4px;
  --gap: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-pixel);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  image-rendering: pixelated;
  padding: var(--gap);
}

/* Scanlines. Decoration only, never over an interactive element's hit area. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.16) 0 2px,
    rgba(0, 0, 0, 0) 2px 4px
  );
}

.screen {
  max-width: 900px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* --- chrome --- */

.titlebar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px var(--gap);
  border-bottom: var(--edge) solid var(--line);
  padding-bottom: 10px;
  margin-bottom: 12px;
}

h1 {
  font-size: 18px;
  line-height: 1.5;
  margin: 0;
  color: var(--accent);
  text-shadow: 3px 3px 0 #000;
}

.subtitle {
  font-size: 9px;
  line-height: 1.8;
  color: var(--ink-dim);
}

.panel {
  background: var(--panel);
  border: var(--edge) solid var(--line);
  box-shadow: 6px 6px 0 #000;
  padding: var(--gap);
  margin-bottom: var(--gap);
}

.panel h2 {
  font-size: 11px;
  line-height: 1.8;
  margin: 0 0 12px;
  color: var(--accent-2);
}

/* --- buttons --- */

.btn {
  font-family: var(--font-pixel);
  font-size: 10px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--panel-2);
  border: var(--edge) solid var(--line);
  box-shadow: 4px 4px 0 #000;
  padding: 12px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  /* The press is a 2px nudge into the shadow -- the whole button moves, the way
     a physical key does. Transform would blur the pixel grid. */
  transition: none;
}

.btn:hover:not(:disabled) { background: var(--line); }

.btn:active:not(:disabled) {
  box-shadow: 0 0 0 #000;
  margin: 4px -4px -4px 4px;
}

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

.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.btn-primary { background: var(--accent); border-color: #7a2410; color: #180a05; }
.btn-primary:hover:not(:disabled) { background: #ff6a44; }

.btn-ghost { background: transparent; }

.btn-big { font-size: 13px; padding: 18px; width: 100%; }

/* --- the board --- */

.board { display: flex; flex-direction: column; gap: 5px; }

/* Board-only: the class links are navigation, not actions, so they stay small
   and leave the vertical space to the players. */
.board-nav .btn { font-size: 9px; padding: 8px 10px; }

.row {
  display: grid;
  grid-template-columns: 52px 1fr 68px;
  align-items: center;
  gap: 12px;
  background: var(--bg-2);
  border: var(--edge) solid var(--line);
  padding: 4px 12px;
}

.row.is-gold { border-color: var(--gold); }
.row.is-silver { border-color: var(--silver); }
.row.is-bronze { border-color: var(--bronze); }

.rank {
  font-size: 16px;
  text-align: center;
  padding: 6px 0;
  border: 3px solid currentColor;
  background: #000;
}

.is-gold .rank { color: var(--gold); }
.is-silver .rank { color: var(--silver); }
.is-bronze .rank { color: var(--bronze); }

.who { min-width: 0; }

.name {
  font-family: var(--font-name);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* --- the XP bar ---
   The only thing on the public page derived from a cumulative total, and it is
   deliberately lossy: the server snaps the width to a 10% step before sending it,
   so the segments here cannot be measured back into a score. */

.xp {
  position: relative;
  height: 12px;
  margin-top: 5px;
  background: #000;
  border: 3px solid var(--line);
}

.xp-fill {
  height: 100%;
  background: var(--accent-2);
  background-image: repeating-linear-gradient(
    to right,
    rgba(255, 255, 255, 0.18) 0 2px,
    rgba(255, 255, 255, 0) 2px 10px
  );
}

.is-gold .xp-fill { background-color: var(--gold); }
.is-silver .xp-fill { background-color: var(--silver); }
.is-bronze .xp-fill { background-color: var(--bronze); }

.today {
  font-size: 12px;
  color: var(--good);
  white-space: nowrap;
  text-align: right;
}

.today.is-zero { color: var(--ink-dim); opacity: 0.5; }

/* --- teacher page: portrait first ---
   The teacher holds this in one hand during a lesson, so the quick button is a
   full-height target down the right of each card and nothing else is near it. */

.student-card {
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 12px;
  align-items: stretch;
  background: var(--bg-2);
  border: var(--edge) solid var(--line);
  padding: 12px;
  margin-bottom: 10px;
}

.student-card .meta { min-width: 0; }
.student-card .score { font-size: 14px; color: var(--good); margin-top: 8px; }
.student-card .score.is-zero { color: var(--ink-dim); }

.quick-btn {
  font-family: var(--font-pixel);
  font-size: 15px;
  color: #180a05;
  background: var(--accent);
  border: var(--edge) solid #7a2410;
  box-shadow: 4px 4px 0 #000;
  cursor: pointer;
  padding: 8px 4px;
}

.quick-btn:active:not(:disabled) { box-shadow: 0 0 0 #000; margin: 4px -4px -4px 4px; }
.quick-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.quick-btn .next { display: block; font-size: 7px; margin-top: 8px; line-height: 1.6; opacity: 0.8; }

.picker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.roll {
  text-align: center;
  padding: 28px 12px;
  background: #000;
  border: var(--edge) solid var(--gold);
  margin-bottom: var(--gap);
}

.roll .label { font-size: 9px; color: var(--ink-dim); line-height: 1.8; }
.roll .picked {
  font-family: var(--font-name);
  font-size: 30px;
  font-weight: 700;
  color: var(--gold);
  margin-top: 12px;
  overflow-wrap: anywhere;
}
.roll.is-rolling .picked { color: var(--ink-dim); }

/* --- sheet (multi-point award) --- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(3, 2, 10, 0.88);
  display: none;
  overflow-y: auto;
  padding: var(--gap);
}

.sheet-backdrop.is-open { display: block; }

.sheet {
  max-width: 560px;
  margin: 0 auto;
  background: var(--panel);
  border: var(--edge) solid var(--accent);
  box-shadow: 8px 8px 0 #000;
  padding: var(--gap);
}

label { display: block; font-size: 9px; line-height: 1.9; color: var(--ink-dim); margin-bottom: 6px; }

input[type='text'],
input[type='number'] {
  width: 100%;
  font-family: var(--font-name);
  font-size: 18px;
  color: var(--ink);
  background: #000;
  border: 3px solid var(--line);
  padding: 12px;
  margin-bottom: var(--gap);
}

input:focus { outline: 3px solid var(--gold); outline-offset: 2px; }

.checks { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--gap); }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-name);
  font-size: 16px;
  background: var(--bg-2);
  border: 3px solid var(--line);
  padding: 10px;
  cursor: pointer;
}

.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.check.is-on { border-color: var(--accent); }

.sheet-actions { display: flex; gap: 10px; }
.sheet-actions .btn { flex: 1; }

/* --- history and lists --- */

.log { list-style: none; margin: 0; padding: 0; }

.log li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 3px solid var(--line);
  padding: 12px 0;
  font-size: 9px;
  line-height: 1.8;
}

.log li:last-child { border-bottom: 0; }
.log .what { font-family: var(--font-name); font-size: 15px; overflow-wrap: anywhere; }
.log .when { color: var(--ink-dim); }
.log .pts { font-size: 12px; color: var(--good); white-space: nowrap; }

.stat-row { display: flex; flex-wrap: wrap; gap: var(--gap); }

.stat {
  flex: 1 1 140px;
  background: #000;
  border: 3px solid var(--line);
  padding: 14px;
  text-align: center;
}

.stat .k { font-size: 8px; color: var(--ink-dim); line-height: 1.9; }
.stat .v { font-size: 24px; color: var(--gold); margin-top: 10px; }

/* --- states --- */

.note { font-size: 9px; line-height: 1.9; color: var(--ink-dim); }
.error { font-size: 9px; line-height: 1.9; color: var(--bad); min-height: 17px; }
.is-hidden { display: none !important; }

.toast {
  position: fixed;
  left: var(--gap);
  right: var(--gap);
  bottom: var(--gap);
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--panel-2);
  border: var(--edge) solid var(--gold);
  box-shadow: 6px 6px 0 #000;
  padding: 12px;
  font-size: 9px;
  line-height: 1.8;
}

.toast .btn { font-size: 9px; padding: 8px 10px; }

.gate {
  max-width: 460px;
  margin: 12vh auto;
  text-align: center;
}

.gate h1 { font-size: 15px; }
.gate p { font-size: 9px; line-height: 2; color: var(--ink-dim); }

@media (min-width: 720px) {
  body { padding: 20px 28px; }
  h1 { font-size: 24px; }
  .row { grid-template-columns: 64px 1fr 76px; gap: 16px; }
  /* Large enough to read from the back of a classroom, small enough that ten
     players still fit one screen. Both constraints are real; this is the seam. */
  .name { font-size: 21px; }
  .student-card { grid-template-columns: 1fr 140px; }
}

/* A cold call is a moment in a room full of people; the animation is the point.
   Anyone who has asked for less motion gets the result with no roll at all. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
