:root { --ink:#1d2433; --muted:#667085; --line:#d9dee7; --bg:#f5f7fb; --card:#fff; --brand:#2f5bd8; --danger:#c0392b; --ok:#1e8e4e; }
* { box-sizing: border-box; }
body { margin:0; font:16px/1.45 system-ui, "Segoe UI", Arial, sans-serif; color:var(--ink); background:var(--bg); }
header.top { background:var(--brand); color:#fff; padding:12px 20px; display:flex; align-items:center; justify-content:space-between; }
header.top h1 { font-size:1.15rem; margin:0; }
header.top nav { display:flex; gap:16px; }
header.top nav a { color:#fff; text-decoration:none; opacity:.9; }
header.top button { background:transparent; color:#fff; border:1px solid #fff8; }
main { max-width:1000px; margin:0 auto; padding:20px; }
.card { background:var(--card); border:1px solid var(--line); border-radius:10px; padding:16px; margin-bottom:16px; }
h2 { margin:0 0 12px; font-size:1.2rem; }
button { font:inherit; padding:7px 14px; border-radius:7px; border:1px solid var(--line); background:#fff; cursor:pointer; }
button.primary { background:var(--brand); color:#fff; border-color:var(--brand); }
button.danger { color:var(--danger); }
button.link { border:none; background:none; color:var(--brand); padding:0; }
button:disabled { opacity:.5; cursor:default; }
input, textarea, select { font:inherit; padding:7px 9px; border:1px solid var(--line); border-radius:7px; }
textarea { width:100%; min-height:140px; }
label { display:block; margin:8px 0; }
label span { display:block; color:var(--muted); font-size:.9rem; }
.row { display:flex; gap:10px; flex-wrap:wrap; align-items:end; }
/* a checkbox with its sentence: one line, the sentence wraps beside the box and never drops below it */
label.row:has(> input[type=checkbox]) { flex-wrap: nowrap; align-items: flex-start; }
label.row:has(> input[type=checkbox]) input { flex: none; margin-top: 3px; }
label.row:has(> input[type=checkbox]) span { flex: 1; }
.msg { padding:8px 12px; border-radius:7px; margin:10px 0; }
.msg.error { background:#fdecea; color:var(--danger); }
.msg.ok { background:#e8f6ee; color:var(--ok); }
.muted { color:var(--muted); font-size:.9rem; }
table { width:100%; border-collapse:collapse; }
th, td { text-align:left; padding:8px 6px; border-bottom:1px solid var(--line); vertical-align:middle; }
th { color:var(--muted); font-weight:600; font-size:.85rem; }
.login { max-width:380px; margin:60px auto; }
.classlist { list-style:none; padding:0; margin:0; }
/* name on the left, grade exactly in the middle, code on the right (the middle column is the same width on both sides) */
.classlist li { display:grid; grid-template-columns:minmax(0,1fr) auto minmax(0,1fr); column-gap:12px; align-items:center; padding:10px 0; border-bottom:1px solid var(--line); }
.classlist li > :nth-child(2) { justify-self:center; white-space:nowrap; }
.classlist li > :nth-child(3) { justify-self:end; white-space:nowrap; }
.classlist .codecell { display:flex; flex-wrap:wrap; align-items:center; justify-content:flex-end; gap:6px 0; }
.cards { display:grid; grid-template-columns:repeat(2, 1fr); gap:10px; }
.logincard { border:1px dashed #777; border-radius:8px; padding:12px 14px; break-inside:avoid; background:#fff; }
.logincard h3 { margin:0 0 6px; font-size:1rem; }
.logincard .big { font:600 1.15rem ui-monospace, Consolas, monospace; }
.logincard .small { font-size:.85rem; color:#444; }
.printonly { display:none; }
@media print {
  body { background:#fff; }
  header.top, .noprint { display:none !important; }
  main { padding:0; max-width:none; }
  .card { border:none; padding:0; }
  .printonly { display:block; }
}

.streak { display:inline-flex; align-items:center; gap:4px; font-weight:700; white-space:nowrap; }
.streak svg { width:18px; height:18px; }
.streak.cold { color:var(--muted); }
.pill { display:inline-block; padding:2px 9px; border-radius:999px; background:#eef2ff; color:var(--brand); font-size:.85rem; font-weight:600; }
.pill.late { background:#fdecea; color:var(--danger); }
.pill.ok { background:#e8f6ee; color:var(--ok); }

/* the leaderboard podium */
.pd-dlg { border: none; padding: 0; margin: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; color: #fff; overflow: hidden;
  background: radial-gradient(circle at 50% 25%, #2b2060 0%, #120d33 55%, #070a1a 100%); }
.pd-dlg::backdrop { background: #000; }
.pd-dlg[open] { display: flex; flex-direction: column; }
.pd-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 22px; position: relative; z-index: 5; flex-wrap: wrap; }
.pd-title { margin: 0; font-size: 2.1rem; letter-spacing: .05em; color: #ffd166; text-shadow: 0 0 18px rgba(255, 170, 40, .6); }
.pd-range { color: #b9c3e6; }
.pd-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pd-rank { color: #cdd6f5; font-size: .95rem; margin: 0; }
.pd-select { background: #1b2550; color: #fff; border: 1px solid #3a4a8a; }
.pd-btn { background: #1f2a55; color: #fff; border: 1px solid #3a4a8a; }
.pd-btn.primary { background: #ffd166; color: #1d2433; border-color: #ffd166; font-weight: 700; }
.pd-stage { position: relative; flex: 1; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 4vh; overflow: hidden; }
.pd-spot { position: absolute; left: 0; right: 0; top: 0; height: 100%; pointer-events: none; transition: all .8s;
  background: radial-gradient(ellipse at 50% 0, rgba(255, 235, 170, .26), transparent 62%); }
.pd-dlg.suspense .pd-spot { background: radial-gradient(ellipse at 50% 0, rgba(255, 235, 170, .55), transparent 40%); }
.pd-dlg.suspense .pd-col.in { opacity: .45; transition: opacity .5s; }
.pd-cols { position: relative; display: flex; align-items: flex-end; gap: 2vw; z-index: 2; }
.pd-col { width: min(27vw, 300px); display: flex; flex-direction: column; align-items: center; }
.pd-who { text-align: center; opacity: 0; transform: translateY(-180px) scale(.6); padding: 0 4px; }
.pd-col.in .pd-who { animation: pdDrop .9s cubic-bezier(.3, 1.5, .5, 1) forwards; }
@keyframes pdDrop { 0% { opacity: 0; transform: translateY(-200px) scale(.6); } 60% { opacity: 1; transform: translateY(8px) scale(1.05); } 100% { opacity: 1; transform: none; } }
.pd-creature { width: min(16vw, 140px); height: min(16vw, 140px); image-rendering: pixelated; display: block; margin: 0 auto; }
.pd-col.p1 .pd-creature { width: min(20vw, 190px); height: min(20vw, 190px); }
.pd-col.winner .pd-creature { animation: pdHop .55s ease-in-out infinite alternate; }
@keyframes pdHop { to { transform: translateY(-14px); } }
.pd-crown { font-size: 2.2rem; line-height: 1; animation: pdCrown 1.1s ease-in-out infinite alternate; }
@keyframes pdCrown { from { transform: rotate(-8deg) translateY(0); } to { transform: rotate(8deg) translateY(-6px); } }
.pd-name { font-size: 1.4rem; font-weight: 800; margin-top: 4px; }
.pd-col.p1 .pd-name { font-size: 2rem; color: #ffd166; text-shadow: 0 0 14px rgba(255, 170, 40, .6); }
.pd-stats { margin: 6px 0 10px; font-size: .95rem; background: rgba(255, 255, 255, .09); border-radius: 10px; padding: 6px 12px; min-width: 9.5em; }
.pd-stat { display: flex; justify-content: space-between; gap: 14px; }
.pd-stat .k { color: #aeb9e6; }
.pd-stat.main .v { color: #ffd166; font-weight: 800; }
.pd-block { width: 100%; border-radius: 10px 10px 0 0; display: flex; align-items: flex-start; justify-content: center; padding-top: 10px; font-size: 2.2rem; font-weight: 900;
  transform: scaleY(0); transform-origin: bottom; transition: transform .7s cubic-bezier(.2, 1.3, .4, 1); }
.pd-col.in .pd-block { transform: scaleY(1); }
.p1 .pd-block { height: 24vh; background: linear-gradient(#ffd166, #c98a10); color: #5a3b00; }
.p2 .pd-block { height: 17vh; background: linear-gradient(#e3e9f5, #9aa6c2); color: #37405c; }
.p3 .pd-block { height: 11vh; background: linear-gradient(#e0a070, #a8683a); color: #4d2a12; }
.pd-dlg.flash::after { content: ""; position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 6; animation: pdFlash .9s ease-out; }
@keyframes pdFlash { 0% { opacity: .9; } 100% { opacity: 0; } }
.pd-confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 4; }
.conf { position: absolute; top: -24px; width: 10px; height: 16px; opacity: 0; animation: pdFall 3s linear forwards; }
@keyframes pdFall { 0% { opacity: 1; margin-top: 0; } 100% { opacity: 0; margin-top: 108vh; transform: rotate(720deg); } }
.pd-empty { margin: auto; font-size: 1.3rem; color: #cdd6f5; z-index: 2; text-align: center; padding: 0 20px; }
@media (prefers-reduced-motion: reduce) { .pd-col.winner .pd-creature, .pd-crown { animation: none; } }
/* the custom date range */
.rangebox { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rangebox input[type=date] { padding: 5px 8px; }

/* the Start screen before the show */
.pd-startbox { position: absolute; inset: 0; z-index: 7; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; }
.pd-ready { font-size: clamp(1.6rem, 4vw, 2.6rem); font-weight: 800; color: #ffd166; text-shadow: 0 0 20px rgba(255, 170, 40, .7); }
.pd-start { font-size: 1.6rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; padding: 16px 56px; border: none; border-radius: 999px;
  background: linear-gradient(#ffd166, #f0a020); color: #3b2600; box-shadow: 0 6px 0 #a86a00, 0 0 30px rgba(255, 190, 70, .6); animation: pdPulse 1.2s ease-in-out infinite alternate; }
.pd-start:hover { filter: brightness(1.08); }
@keyframes pdPulse { from { transform: scale(1); } to { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .pd-start { animation: none; } }

/* the student list: each username and the three buttons stay on one line */
table.students th { white-space: nowrap; }
table.students td code { white-space: nowrap; }
table.students .row { flex-wrap: wrap; align-items: center; gap: 6px; }
table.students td:last-child { min-width: 235px; }
table.students input:not([type=checkbox]) { width: 9em; }
table.students .row button { padding: 6px 10px; white-space: nowrap; }

/* Conversation Station: one dot per recorded line */
.convtable td, .convtable th { text-align: center; padding: 4px 6px; }
.convtable td:first-child, .convtable th:first-child { text-align: left; }
.dot { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #c7cedb; background: none; padding: 0; vertical-align: middle; }
.dot.new { background: #2e9e5b; border-color: #2e9e5b; cursor: pointer; }
.dot.heard { background: #b8c2d4; border-color: #b8c2d4; cursor: pointer; }
.dot.none { opacity: .5; }
.classcode { font: 700 1.6rem/1 ui-monospace, Consolas, monospace; letter-spacing: .25em; background: #fff4d6; border-radius: 8px; padding: 6px 12px; margin-left: 6px; }
.toplink { color:#fff; margin:0 12px; }

.gradebadge { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: #fff4d6; color: #7a5200; font-size: .8rem; font-weight: 700; white-space: nowrap; }

/* narrow screens: the Delete for good button of an archived class goes on its own line under the row */
@media (max-width: 600px) {
  .classlist .codecell { display: contents; }
  .classlist .codecell > span { justify-self: end; white-space: nowrap; }
  .classlist .codecell > button { grid-column: 1 / -1; justify-self: end; margin: 6px 0 0 !important; }
}

/* the owner page (teachers and students): many columns, so keep buttons and dates on one line and scroll sideways only if the screen is too narrow */
.owner-table { overflow-x: auto; }
.owner-table table { font-size: .92rem; }
.owner-table th, .owner-table td { white-space: nowrap; padding: 7px 8px; }
.owner-table .row button { padding: 6px 10px; white-space: nowrap; }

/* the class pages: class name and tab bar */
.classhead { margin-bottom: 14px; }
.classhead > p { margin: 0 0 6px; }
.classtitle { font-size: 1.5rem; font-weight: 700; margin-bottom: 10px; }
.classtitle .muted { font-size: 1rem; font-weight: 400; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid var(--line); }
.tabs .tab { padding: 9px 18px; border-radius: 8px 8px 0 0; color: var(--muted); font-weight: 600; text-decoration: none; margin-bottom: -2px; border-bottom: 3px solid transparent; }
.tabs .tab:hover { background: #eaf0fe; color: var(--brand); }
.tabs .tab.active { color: var(--brand); background: var(--card); border: 1px solid var(--line); border-bottom: 3px solid var(--brand); }
h3.settinggroup { margin: 22px 0 8px; font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
h3.settinggroup:first-child { margin-top: 4px; }
/* the student list: Save name, New password and Remove stay on one line */
main:has(table.students) { max-width: 1150px; }
table.students .row { flex-wrap: nowrap; }
table.students td:last-child { min-width: 0; white-space: nowrap; }
table.students input:not([type=checkbox]) { width: 8.5em; }
table.students th, table.students td { padding-left: 6px; padding-right: 6px; }
