:root {
  /* Theme palette tuned for the dark UI */
  --bg: #0b1020;
  --panel-bg-top: rgba(15, 20, 32, 0.98);
  --panel-bg-bottom: rgba(11, 16, 28, 0.98);
  --panel-border: rgba(255, 255, 255, 0.04);
  --panel-accent: rgba(96, 119, 255, 0.06);
  --muted: #97a3c6;
  --line: rgba(255, 255, 255, 0.03);
  --accent: #6377ff;
  --accent-dark: #4d60d8;
  --green: #17b38b;
  --red: #ef4b5b;
  --blue: #4264db;
  --yellow: #f1cf3f;
  --radius-xl: 24px;
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --hero-font: "Rockwell", "Bookman Old Style", "Georgia", serif;
  --body-font: "Trebuchet MS", "Lucida Sans Unicode", sans-serif;
  --shadow-soft: 0 18px 36px rgba(0,0,0,0.45);
  --shadow-card: 0 20px 40px rgba(0,0,0,0.55);
  --control-bg: rgba(255,255,255,0.04);
  --control-very-light: rgba(255,255,255,0.92);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--body-font);
  color: #ecf0ff;
  background:
    radial-gradient(circle at 8% 12%, rgba(88, 117, 255, 0.16), transparent 22%),
    radial-gradient(circle at 92% 10%, rgba(64, 230, 255, 0.08), transparent 18%),
    linear-gradient(180deg, #0a0e19 0%, #0f1422 48%, #0b1020 100%);
}

html {
  min-height: 100%;
}

.page-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.045;
  mix-blend-mode: screen;
  background-image:
    linear-gradient(transparent 0, transparent 94%, rgba(0, 0, 0, 0.18) 95%, transparent 100%),
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.8) 0 1px, transparent 2px);
  background-size: 100% 11px, 14px 14px;
  mix-blend-mode: multiply;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1360px, calc(100% - 28px));
  margin: 18px auto 24px;
  display: grid;
  gap: 18px;
  /* don't clip content; allow internal stack to scroll */
  max-height: none;
  overflow: visible;
}

/* Left navigation/sidebar layout rules */
.admin-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  align-items: start;
  min-height: 0; /* allow inner scrolling */
}

.admin-sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  min-height: 0;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border: 1px solid var(--panel-border);
}

.admin-brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.admin-brand__logo {
  width: 44px;
  height: 44px;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-nav__button {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--control-very-light);
}

.admin-nav__button.is-active {
  background: linear-gradient(180deg, rgba(99,119,255,0.12), rgba(77,96,216,0.08));
  border-color: rgba(99,119,255,0.12);
}

.admin-sidebar__footer {
  margin-top: auto;
}

/* Custom dropdown styles */
.custom-dropdown {
  position: relative;
  display: inline-block;
  width: 100%;
  max-width: 100%;
}
.custom-dropdown__button {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--control-very-light);
  cursor: pointer;
}
.custom-dropdown__list {
  position: absolute;
  left: 0;
  right: 0;
  margin-top: 8px;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--panel-bg-top), var(--panel-bg-bottom));
  border: 1px solid var(--panel-border);
  max-height: 240px;
  overflow: auto;
  display: none;
  z-index: 30;
  padding: 6px 0;
}
.custom-dropdown__list.is-open { display: block; }
.custom-dropdown__option {
  list-style: none;
  padding: 10px 14px;
  cursor: pointer;
  color: var(--control-very-light);
}
.custom-dropdown__option:hover,
.custom-dropdown__option.is-selected {
  background: rgba(99,119,255,0.18);
  color: #fff;
}

/* Improve contrast for selected / hovered items */
.custom-dropdown__option.is-selected {
  background: rgba(99,119,255,0.28);
  color: #ffffff;
  font-weight: 700;
}

/* Ensure the native select remains out of flow but accessible for forms */
select[data-custom-dropdown] { position: relative; z-index: 1; }

.masthead,
.panel,
.panel--hero,
.detail-box,
.toast {
  background: linear-gradient(180deg, var(--panel-bg-top), var(--panel-bg-bottom));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  backdrop-filter: none;
}

.masthead {
  padding: 26px 28px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 18px;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.74rem;
  font-weight: 700;
  color: #8d98ff;
}

.masthead h1,
.panel__heading h2,
.hero-bar h2 {
  margin: 0;
  font-family: var(--hero-font);
  line-height: 0.96;
}

.masthead h1 {
  font-size: clamp(2.6rem, 5vw, 4.8rem);
}

.masthead__lede,
.panel__heading p,
.form-note,
.delivery-note,
.detail-box,
.feedback-panel {
  color: #97a3c6;
  line-height: 1.55;
}

.masthead__status {
  display: grid;
  gap: 12px;
  align-content: end;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  background: rgba(16, 24, 40, 0.94);
  border: 1px solid rgba(134, 147, 221, 0.25);
  font-size: 0.92rem;
  font-weight: 700;
  color: #d9e1ff;
}

.status-note {
  color: #97a3c6;
}

.screen-stack,
.view {
  display: grid;
  gap: 18px;
}

/* Keep the active view contained to the viewport so login -> player transitions
   don't push content further down the page. */
.screen-stack {
  padding-bottom: 18px;
}

/* Hide native scrollbar while preserving scroll behaviour */
.screen-stack {
  -ms-overflow-style: none; /* IE and Edge */
  scrollbar-width: none; /* Firefox */
}
.screen-stack::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.view[hidden] {
  display: none !important;
}

.panel-grid {
  display: grid;
  gap: 18px;
}

.panel-grid--login {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel,
.panel--hero {
  padding: 22px;
}

.panel__heading {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.panel__heading h2,
.hero-bar h2 {
  font-size: clamp(1.6rem, 2.8vw, 2.4rem);
}

.panel__actions {
  margin-top: 18px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.form-stack--tight {
  margin-top: 12px;
}

.field {
  display: grid;
  gap: 8px;
}

.field--compact {
  max-width: 360px;
}

.field--compound {
  gap: 10px;
}

.field span {
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8390b3;
  font-weight: 700;
}

.inline-action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-list__empty {
  color: var(--muted);
  font-size: 0.92rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(208, 190, 164, 0.92);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font: inherit;
}

.table-action-stack {
  display: grid;
  justify-items: start;
  gap: 8px;
  width: max-content;
}

input,
select,
.solver-shell input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--control-bg);
  font-size: 1rem;
  font-family: var(--body-font);
  color: var(--control-very-light);
}

/* Dropdown option styling (improves readability in dark theme) */
select option,
.panel select option,
.admin-stage select option {
  background: linear-gradient(180deg, var(--panel-bg-top), var(--panel-bg-bottom));
  color: var(--control-very-light);
}

/* Hover / selected option styles where supported */
select option:hover,
select option:checked {
  background: rgba(99,119,255,0.12);
  color: #fff;
}

/* Ensure native dropdown doesn't force a light background on some browsers */
select {
  -webkit-appearance: none;
  appearance: none;
}

input::placeholder {
  color: #7280aa;
}

input:focus,
select:focus,
.solver-shell input:focus {
  outline: 3px solid rgba(115, 129, 255, 0.14);
  border-color: rgba(144, 157, 255, 0.48);
}

.button,
.pad-key {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.button:hover,
.pad-key:hover {
  transform: translateY(-1px);
}

.button {
  min-height: 52px;
  padding: 0 18px;
  border-radius: 18px;
  font-family: var(--body-font);
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(180deg, rgba(34, 43, 68, 0.96), rgba(22, 29, 49, 0.96));
  color: #ecf1ff;
  box-shadow: none;
}

.button--primary {
  color: #ffffff;
  background: linear-gradient(180deg, #6377ff, #4d60d8);
  box-shadow: 0 14px 28px rgba(99, 119, 255, 0.24);
}

.button--accent {
  color: #ffffff;
  background: linear-gradient(180deg, #17b38b, #118267);
  box-shadow: 0 14px 28px rgba(23, 179, 139, 0.22);
}

.button--ghost {
  color: #d7def8;
  border: 1px solid rgba(130, 145, 214, 0.2);
  background: rgba(12, 18, 31, 0.6);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.45fr);
  gap: 18px;
  align-items: start;
}

.workspace--admin {
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
}

.workspace__sidebar,
.workspace__main {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.metric-list {
  display: grid;
  gap: 12px;
}

.metric-list__item {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.metric-list__item:last-child {
  border-bottom: 0;
}

.metric-list__item span {
  color: #97a3c6;
}

.metric-list__item strong {
  color: #d9e1ff;
  text-align: right;
}

.panel--hero {
  display: grid;
  gap: 18px;
}

.hero-bar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  flex-wrap: wrap;
}

.hero-bar > div {
  min-width: 0;
}

.hero-bar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.session-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
}

.metric-card {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.02));
  border: 1px solid var(--line);
}

/* Pad keys - unified sizing and spacing */
.pad-key {
  min-height: 56px;
  padding: 0 14px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  color: var(--control-very-light);
  box-shadow: 0 8px 18px rgba(0,0,0,0.45) inset;
}

/* Make the solver and arena panels align spacing */
.arena {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.arena__card,
.arena__solver {
  padding: 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border: 1px solid var(--panel-border);
}

.metric-card__label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-family: var(--hero-font);
  font-size: clamp(1.4rem, 2.6vw, 2rem);
  color: var(--accent);
}

.stats-grid {
  display: grid;
  gap: 12px;
}

.stats-grid--compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-tile {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(229, 213, 190, 0.88);
}

.stat-tile span {
  display: block;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.stat-tile strong {
  display: block;
  margin-top: 8px;
  font-family: var(--hero-font);
  font-size: 1.5rem;
  color: var(--accent);
}

.arena {
  display: grid;
  grid-template-columns: minmax(340px, 0.92fr) minmax(0, 1.08fr);
  gap: 18px;
  align-items: start;
}

.arena__card,
.arena__solver {
  display: grid;
  gap: 18px;
}

.card-stage {
  min-height: 470px;
  display: grid;
  place-items: center;
  padding: 20px;
  border-radius: calc(var(--radius-xl) + 8px);
  background:
    radial-gradient(circle at 50% 28%, rgba(241, 207, 63, 0.33), transparent 30%),
    linear-gradient(180deg, rgba(53, 83, 182, 0.06), rgba(255, 255, 255, 0));
  border: 1px solid rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.math-card {
  --card-size: min(68vw, 360px);
  position: relative;
  width: var(--card-size);
  aspect-ratio: 1;
  border-radius: 42px;
  border: 10px solid var(--yellow);
  box-shadow: var(--shadow-card);
  transform: rotate(-2deg);
}

.math-card--easy {
  background: linear-gradient(180deg, #f45e68, var(--red));
}

.math-card--medium {
  background: linear-gradient(180deg, #5373f0, var(--blue));
}

.math-card--hard {
  background: linear-gradient(180deg, #f8dd73, var(--yellow));
}

.math-card::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 30px;
  border: 3px solid rgba(255, 255, 255, 0.42);
}

.math-card__panel {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(circle at 52% 44%, rgba(255, 255, 255, 0.11), transparent 34%),
    linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.05));
}

.math-card__tab {
  position: absolute;
  display: grid;
  place-items: center;
  width: 46%;
  height: 17%;
  background: linear-gradient(180deg, #fffdfb, #fef5ef);
  border-radius: 14px;
  box-shadow: 0 4px 0 rgba(252, 231, 221, 0.9);
}

.math-card__tab span {
  position: relative;
  display: inline-block;
  font-family: var(--hero-font);
  font-size: clamp(1.45rem, 5.2vw, 2.5rem);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--accent);
}

.math-card__tab span::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  top: calc(100% + 6px);
  height: 4px;
  border-radius: 999px;
  background: currentColor;
}

.math-card__tab--top {
  top: 4.5%;
  left: 27%;
}

.math-card__tab--right {
  top: 42%;
  right: -3.2%;
  transform: rotate(90deg);
}

.math-card__tab--bottom {
  bottom: 4.5%;
  left: 27%;
  transform: rotate(180deg);
}

.math-card__tab--left {
  top: 42%;
  left: -3.2%;
  transform: rotate(-90deg);
}

.math-card__badge {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  clip-path: polygon(
    50% 0%,
    58% 18%,
    76% 6%,
    72% 24%,
    92% 18%,
    80% 36%,
    100% 40%,
    82% 50%,
    100% 60%,
    80% 64%,
    92% 82%,
    72% 76%,
    76% 94%,
    58% 82%,
    50% 100%,
    42% 82%,
    24% 94%,
    28% 76%,
    8% 82%,
    20% 64%,
    0% 60%,
    18% 50%,
    0% 40%,
    20% 36%,
    8% 18%,
    28% 24%,
    24% 6%,
    42% 18%
  );
  background: linear-gradient(180deg, #fffef8, #f9edd0);
  border: 4px solid #d79e1d;
  display: grid;
  place-items: center;
}

.math-card__badge-core {
  display: inline-flex;
  gap: 7px;
}

.math-card__badge-core span {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

.math-card--easy .math-card__badge-core span {
  background: var(--red);
}

.math-card--medium .math-card__badge-core span {
  background: var(--blue);
}

.math-card--hard .math-card__badge-core span {
  background: var(--yellow-dark);
}

.math-card__id {
  position: absolute;
  right: 22px;
  bottom: 16px;
  color: rgba(255, 250, 244, 0.9);
  font-size: 0.82rem;
  font-weight: 700;
  text-shadow: 1px 1px 0 rgba(69, 43, 27, 0.4);
}

.queue-strip {
  padding: 18px;
  border-radius: var(--radius-xl);
  background: rgba(255, 250, 241, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-soft);
}

.queue-strip__heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  font-weight: 700;
}

.queue-strip__heading span {
  color: var(--muted);
}

.mini-queue {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.queue-card {
  min-height: 90px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(251, 242, 228, 0.9));
  border: 1px solid rgba(232, 214, 188, 0.84);
  display: grid;
  gap: 5px;
  align-content: start;
}

.queue-card strong {
  font-family: var(--hero-font);
  color: var(--accent);
}

.queue-card span {
  font-size: 0.82rem;
  color: var(--muted);
}

.queue-card--current {
  border-color: rgba(53, 83, 182, 0.34);
  box-shadow: 0 12px 24px rgba(53, 83, 182, 0.12);
}

.queue-card--solved {
  background: linear-gradient(180deg, rgba(223, 246, 230, 0.95), rgba(247, 255, 249, 0.9));
}

.digit-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.digit-chip {
  min-width: 68px; /* smaller so labels fit */
  padding: 8px 12px;
  border-radius: 12px;
  text-align: center;
  font-family: var(--hero-font);
  font-size: clamp(0.95rem, 2.1vw, 1.04rem);
  color: var(--accent);
  background: linear-gradient(180deg, #fffdfb, #fff5eb);
  border: 1px solid rgba(236, 220, 198, 0.96);
  position: relative;
}

.digit-chip::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 8px;
  height: 3px;
  border-radius: 999px;
  background: currentColor;
}

.digit-chip--used {
  opacity: 0.42;
}

.solver-shell {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center; /* vertically align input and check button */
}

.pad-rows {
  display: grid;
  gap: 12px;
  margin-top: 12px; /* space between solver input row and pad rows */
}

.pad-row {
  display: grid;
  gap: 12px;
}

.pad-row--symbols {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.pad-row--numbers {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.pad-row--actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 6px; /* separate action row from number rows */
}

.pad-key {
  min-height: 48px; /* slightly smaller for tighter layout */
  padding: 10px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(250, 240, 225, 0.9));
  color: #222; /* darker text for better contrast on light control */
  font-size: 0.98rem;
  font-family: var(--body-font);
  font-weight: 700;
  border: 1px solid rgba(235, 218, 193, 0.9);
}

.pad-key--number {
  font-family: var(--hero-font);
  font-size: clamp(1.1rem, 2.6vw, 1.3rem);
  color: var(--accent);
}

.pad-key--ghost {
  color: var(--red-dark);
}

.feedback-panel {
  min-height: 72px;
  padding: 14px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(235, 218, 193, 0.9);
  margin-top: 12px; /* distance from action row */
}

.feedback-panel[data-tone="success"] {
  background: linear-gradient(180deg, #e6f9eb, #f6fff8);
  color: #165b39;
  border-color: rgba(17, 105, 72, 0.28);
}

.feedback-panel[data-tone="error"] {
  background: linear-gradient(180deg, #fff0f0, #fff8f8);
  color: #8e2d36;
  border-color: rgba(183, 45, 58, 0.24);
}

.solver-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 14px; /* ensure Continue button is separated from feedback panel */
}

.flag-card-button {
  min-height: 38px;
  border: 1px solid rgba(245, 158, 11, 0.42);
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.flag-card-button:hover,
.flag-card-button:focus-visible {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(251, 191, 36, 0.68);
  outline: 0;
}

.flag-card-button:disabled {
  cursor: default;
  opacity: 0.72;
}

/* Tweak check button sizing so it doesn't overlap neighbouring rows */
.solver-shell .button {
  min-width: 84px;
  padding: 10px 14px;
}

/* Make the clear/backspace buttons visually separated from the feedback panel */
.pad-row--actions .pad-key {
  padding-top: 12px;
  padding-bottom: 12px;
  /* Make action buttons visually distinct and high-contrast */
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(245,240,230,0.94));
  border: 1px solid rgba(200,180,160,0.9);
  color: #1e2533; /* dark text for strong contrast */
  font-weight: 800;
  text-shadow: none;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.table-shell {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.data-table th {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.data-table td strong {
  color: var(--accent);
}

.detail-box {
  margin-top: 16px;
  padding: 16px 18px;
}

.quest-panel {
  border: 1px solid rgba(94, 234, 212, 0.28);
  border-radius: 8px;
  padding: 14px;
  margin: 12px 0;
  background:
    linear-gradient(135deg, rgba(18, 24, 40, 0.96), rgba(29, 45, 58, 0.94)),
    radial-gradient(circle at top right, rgba(232, 170, 46, 0.16), transparent 32%);
  color: var(--ink);
}

.quest-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quest-panel__header h3 {
  margin: 0;
}

.quest-panel__header strong {
  font-size: 1.8rem;
  color: #5eead4;
}

.quest-meter {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(151, 163, 198, 0.18);
  margin: 12px 0;
}

.quest-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #5eead4, #f5c451);
  transition: width 240ms ease;
}

.quest-panel__meta {
  color: #c4cbea;
  font-size: 0.9rem;
}

.quest-panel__contributors {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.quest-chip {
  border: 1px solid rgba(94, 234, 212, 0.24);
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(255, 255, 255, 0.07);
  color: #edf2ff;
}

.detail-box h3 {
  margin: 0 0 8px;
  font-family: var(--hero-font);
  color: var(--ink);
}

.detail-box__stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.panel--compact {
  padding: 14px 22px;
}

.deck-preview-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: center;
}

.deck-preview-label {
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.app-shell--tournament {
  width: min(1600px, calc(100% - 24px));
  margin-top: 12px;
}

#tournament-page-view {
  display: grid;
  gap: 18px;
  min-height: calc(100vh - 32px);
}

#tp-join-view,
#tp-waiting-view,
#tp-game-view,
#tp-display-view,
#tp-finished-view {
  min-height: calc(100vh - 32px);
}

.tp-centered {
  min-height: calc(100vh - 40px);
  display: grid;
  place-items: center;
}

.tp-join-panel,
.tp-waiting-panel,
.tp-finished-panel {
  width: min(560px, 100%);
}

.tp-waiting-panel {
  display: grid;
  gap: 18px;
}

.tp-waiting-status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tp-waiting-status strong,
.tp-waiting-status span {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(132, 145, 214, 0.22);
  background: rgba(16, 24, 40, 0.94);
  color: #d9e1ff;
  font-weight: 800;
}

.tp-header,
.tp-display__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 16px;
  align-items: center;
}

.tp-header__title,
.tp-display__title {
  font-family: var(--hero-font);
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 0.96;
  color: var(--ink);
}

.tp-header__timer,
.tp-display__timer {
  min-width: 140px;
  padding: 14px 18px;
  border-radius: 22px;
  text-align: center;
  font-family: var(--hero-font);
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  color: #fff9f3;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  box-shadow: 0 18px 34px rgba(53, 83, 182, 0.22);
}

.tp-arena {
  align-items: start;
}

.tp-card-stage {
  min-height: 520px;
}

.tp-solver-panel {
  min-height: 100%;
}

.tp-solver-actions {
  justify-content: space-between;
  gap: 12px;
}

.tp-display {
  min-height: calc(100vh - 40px);
  display: grid;
  gap: 18px;
}

.tp-display__leaderboard {
  padding: 24px;
}

.tp-display__leaderboard .data-table td,
.tp-display__leaderboard .data-table th {
  padding-top: 14px;
  padding-bottom: 14px;
}

#admin-heading {
  overflow-wrap: anywhere;
}

.admin-monitor-panel {
  display: grid;
  gap: 18px;
}

.admin-monitor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.monitor-picker {
  display: grid;
  gap: 8px;
  max-width: 620px;
}

.monitor-picker span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.monitor-picker select {
  min-height: 46px;
  padding-right: 42px;
}

.admin-monitor-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.admin-monitor-stats .stat-tile strong {
  display: block;
  margin-top: 8px;
  font-family: var(--hero-font);
  font-size: 1.35rem;
  color: var(--accent);
}

#admin-monitor-empty {
  margin-top: 0;
}

#tournaments-table tbody tr.is-selected {
  background: rgba(53, 83, 182, 0.06);
}

#tournaments-table button + button {
  margin-left: 10px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(380px, calc(100% - 36px));
  padding: 16px 18px;
  z-index: 20;
}

.toast[data-tone="success"] {
  background: linear-gradient(180deg, #e6f9eb, #f6fff8);
  color: #165b39;
}

.toast[data-tone="error"] {
  background: linear-gradient(180deg, #fff0f0, #fff8f8);
  color: #8e2d36;
}

.text-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

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

@media (max-width: 1120px) {
  .panel-grid--login,
  .workspace,
  .workspace--admin,
  .arena,
  .masthead {
    grid-template-columns: 1fr;
  }

  .session-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tp-header,
  .tp-display__header {
    grid-template-columns: 1fr;
  }

  .admin-monitor-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 18px, 1360px);
    margin-top: 12px;
  }

  .masthead,
  .panel,
  .panel--hero,
  .detail-box {
    padding: 18px;
  }

  .hero-bar,
  .queue-strip__heading,
  .metric-list__item {
    flex-direction: column;
    align-items: start;
  }

  .session-metrics,
  .stats-grid--compact,
  .detail-box__stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-stage {
    min-height: 390px;
  }

  .mini-queue {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .solver-shell {
    grid-template-columns: 1fr;
  }

  .pad-row--symbols {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .pad-key {
    min-height: 48px;
    padding: 10px;
  }

  .tp-card-stage {
    min-height: 420px;
  }

  .tp-header__timer,
  .tp-display__timer {
    width: 100%;
  }

  .tp-solver-actions {
    flex-direction: column;
  }

  .admin-monitor-stats {
    grid-template-columns: 1fr;
  }

  .toast {
    right: 10px;
    left: 10px;
    max-width: none;
  }
}

body[data-view="admin"] {
  /* Admin-specific overrides if needed */
}

.masthead {
  display: none !important;
}

body[data-view="admin"] .page-noise {
  /* Already set globally */
}

.app-shell {
  width: min(1480px, calc(100% - 28px));
  margin: 10px auto 10px;
}

body[data-view="admin"] .app-shell {
  width: calc(100% - 8px);
  max-width: none;
  margin-top: 4px;
  margin-bottom: 4px;
  margin-left: 4px;
  margin-right: 4px;
  overflow: visible;
}

#login-view,
#player-view,
#admin-view {
  gap: 0;
  min-height: calc(100dvh - 20px);
}

/* Player view tweaks: tighter spacing and responsive box fits so text doesn't overflow */
#player-view {
  --player-pad-key-min-height: 48px;
  --player-digit-chip-min-width: 62px;
  --player-input-min-height: 48px;
}

#player-view .digit-bank {
  gap: 8px;
}

#player-view .digit-chip {
  min-width: var(--player-digit-chip-min-width);
  padding: 8px 10px;
  font-size: clamp(0.95rem, 2.1vw, 1.04rem);
}

#player-view .pad-key {
  min-height: var(--player-pad-key-min-height);
  padding: 10px;
  border-radius: 12px;
}

/* Make solver input and feedback panels slightly smaller to avoid overflow */
#player-view .solver-shell input,
#player-view input,
#player-view select {
  min-height: var(--player-input-min-height);
  padding: 10px 12px;
  font-size: 0.96rem;
}

#player-view .feedback-panel {
  min-height: 64px;
  padding: 12px 14px;
}

#player-view .metric-list__item {
  align-items: start;
  gap: 10px;
}

#player-view .metric-list__item span {
  flex: 0 0 auto;
  font-size: 0.88rem;
}

#player-view .metric-list__item strong {
  min-width: 0;
  font-size: 0.86rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

#player-view .stat-tile {
  min-height: 72px;
  padding: 12px;
  border-color: rgba(132, 145, 214, 0.18);
  background: linear-gradient(180deg, rgba(20, 27, 45, 0.94), rgba(10, 15, 27, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

#player-view .stat-tile span {
  color: #97a3c6;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
}

#player-view .stat-tile strong {
  color: #8391ff;
  font-family: "Bahnschrift", "Trebuchet MS", sans-serif;
  font-size: 1.32rem;
}

#player-view .stats-grid--compact {
  grid-template-columns: 1fr;
}

@media (max-width: 420px) {
  #player-view .stat-tile {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  #player-view .stat-tile strong {
    margin-top: 0;
    flex: 0 0 auto;
  }
}

/* Ensure expression input text wraps or scrolls cleanly without pushing layout */
#player-view #expression-input,
#player-view #tp-expression-input {
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Reduce stage height slightly on smaller screens to keep spacing consistent */
@media (min-width: 1000px) {
  #player-view .tp-card-stage {
    min-height: 480px;
  }
}

body[data-view="admin"] .app-shell {
  /* Already set globally */
}

body[data-view="admin"] #admin-view {
  gap: 0;
  min-height: calc(100dvh - 8px);
  height: auto;
  overflow: visible;
}

.admin-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  min-height: calc(100dvh - 8px);
  height: auto;
  overflow: visible;
}

body[data-view="admin"] #admin-view .admin-shell {
  align-items: start;
}

.admin-sidebar {
  position: sticky;
  top: 10px;
  display: grid;
  gap: 16px;
  padding: 18px 16px;
  min-height: calc(100dvh - 8px);
  height: auto;
  align-content: start;
  border-radius: 30px;
  border: 1px solid rgba(140, 153, 222, 0.26);
  background:
    linear-gradient(180deg, rgba(16, 20, 34, 0.96), rgba(12, 16, 28, 0.98)),
    radial-gradient(circle at top, rgba(132, 144, 255, 0.18), transparent 36%);
  box-shadow:
    0 30px 70px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.admin-brand__logo {
  width: 42px;
  height: 42px;
  display: block;
}

.admin-brand__copy {
  display: grid;
  gap: 2px;
}

.admin-brand__copy strong {
  font-size: 1.08rem;
  letter-spacing: 0.02em;
}

.admin-brand__copy span {
  color: #8e98ba;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.68rem;
  font-weight: 700;
}

.admin-account {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: 22px;
  background: rgba(20, 28, 46, 0.82);
  border: 1px solid rgba(114, 128, 190, 0.24);
}

.admin-account__label {
  color: #7f8aad;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.68rem;
  font-weight: 700;
}

.admin-account strong {
  min-width: 0;
  font-size: 0.9rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.admin-account__meta {
  color: #9ca7ca;
  font-size: 0.78rem;
  line-height: 1.35;
}

.admin-nav {
  display: grid;
  gap: 8px;
}

.admin-nav__button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: transparent;
  color: #b7c0de;
  font-family: inherit;
  font-size: 0.96rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.admin-nav__button:hover,
.admin-nav__button:focus-visible {
  transform: translateX(2px);
  color: #f6f8ff;
  background: rgba(113, 125, 198, 0.16);
  border-color: rgba(135, 148, 224, 0.25);
  outline: 0;
}

.admin-nav__button.is-active {
  color: #ffffff;
  background: linear-gradient(90deg, rgba(96, 104, 208, 0.28), rgba(70, 80, 167, 0.16));
  border-color: rgba(155, 168, 255, 0.36);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.admin-nav__icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(92, 108, 196, 0.14);
  border: 1px solid rgba(125, 139, 220, 0.18);
  color: #7b88ff;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 800;
}

.admin-sidebar__footer {
  margin-top: auto;
}

.admin-stage {
  display: grid;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  overflow: visible;
  align-content: start;
  padding-bottom: 24px;
}

.admin-topbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: end;
  padding: 20px 24px;
  border-radius: 28px;
  border: 1px solid rgba(136, 149, 222, 0.24);
  background:
    linear-gradient(180deg, rgba(18, 24, 40, 0.97), rgba(12, 17, 30, 0.98)),
    radial-gradient(circle at top right, rgba(95, 120, 255, 0.16), transparent 32%);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.34);
}

.admin-topbar__copy {
  display: grid;
  gap: 6px;
}

.admin-topbar__copy h2 {
  margin: 0;
  font-family: "Bahnschrift", "Trebuchet MS", sans-serif;
  font-size: clamp(1.55rem, 2.4vw, 2.15rem);
  letter-spacing: -0.03em;
}

.admin-topbar__copy p:last-child {
  margin: 0;
  color: #9ca7ca;
  max-width: 50ch;
  font-size: 0.95rem;
}

.admin-topbar__status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.admin-section {
  display: none;
  gap: 14px;
}

.admin-section.is-active {
  display: grid;
}

.admin-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.admin-metric {
  padding: 16px 18px;
  border-radius: 20px;
  border: 1px solid rgba(132, 147, 220, 0.22);
  background: linear-gradient(180deg, rgba(17, 23, 38, 0.96), rgba(10, 14, 25, 0.98));
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.26);
}

.admin-metric__label {
  display: block;
  color: #8893b6;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.72rem;
  font-weight: 700;
}

.admin-metric strong {
  display: block;
  margin-top: 8px;
  font-family: "Bahnschrift", "Trebuchet MS", sans-serif;
  font-size: clamp(1.45rem, 2.5vw, 2rem);
  color: #f5f7ff;
}

.admin-overview-layout,
.admin-split {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(0, 1.05fr);
  gap: 14px;
  align-items: start;
}

.admin-split--students {
  grid-template-columns: minmax(320px, 360px) minmax(0, 1fr);
}

.admin-split--tournaments {
  grid-template-columns: minmax(360px, 0.82fr) minmax(560px, 1.18fr);
}

.admin-overview-list {
  display: grid;
  gap: 12px;
}

.admin-overview-item {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid rgba(131, 144, 218, 0.2);
  border-radius: 18px;
  background: rgba(12, 18, 32, 0.84);
  color: #eef2ff;
  cursor: pointer;
  text-align: left;
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    background-color 160ms ease;
}

.admin-overview-item:hover,
.admin-overview-item:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(148, 161, 255, 0.38);
  background: rgba(20, 28, 48, 0.94);
  outline: 0;
}

.admin-overview-item__avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, #7784ff, #5766db);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 800;
}

.admin-overview-item__copy {
  display: grid;
  gap: 4px;
}

.admin-overview-item__copy strong {
  font-size: 0.98rem;
}

.admin-overview-item__copy span,
.admin-overview-item__meta {
  color: #9ba6c8;
  font-size: 0.84rem;
}

body[data-view="admin"] #admin-view .panel,
body[data-view="admin"] #admin-view .panel--hero,
body[data-view="admin"] #admin-view .detail-box {
  background:
    linear-gradient(180deg, rgba(18, 24, 40, 0.98), rgba(11, 16, 28, 0.98)),
    radial-gradient(circle at top right, rgba(96, 119, 255, 0.08), transparent 28%);
  border: 1px solid rgba(136, 149, 222, 0.22);
  border-radius: 28px;
  box-shadow: 0 26px 64px rgba(0, 0, 0, 0.3);
  backdrop-filter: none;
}

body[data-view="admin"] #admin-view .panel,
body[data-view="admin"] #admin-view .panel--hero {
  padding: 18px;
}

body[data-view="admin"] #admin-view .panel__heading h2,
body[data-view="admin"] #admin-view .hero-bar h2 {
  font-family: "Bahnschrift", "Trebuchet MS", sans-serif;
  font-size: clamp(1.28rem, 1.8vw, 1.75rem);
  letter-spacing: -0.03em;
}

body[data-view="admin"] #admin-view .panel__heading {
  gap: 6px;
  margin-bottom: 14px;
}

body[data-view="admin"] #admin-view .panel__heading p:last-child,
body[data-view="admin"] #admin-view .delivery-note,
body[data-view="admin"] #admin-view .detail-box {
  font-size: 0.92rem;
  line-height: 1.45;
}

body[data-view="admin"] #admin-view .panel__heading p,
body[data-view="admin"] #admin-view .delivery-note,
body[data-view="admin"] #admin-view .detail-box,
body[data-view="admin"] #admin-view .muted {
  color: #97a3c6;
}

body[data-view="admin"] #admin-view .eyebrow {
  color: #8d98ff;
}

body[data-view="admin"] #admin-view .status-pill {
  min-height: 36px;
  padding: 0 12px;
  background: rgba(16, 24, 40, 0.94);
  border: 1px solid rgba(134, 147, 221, 0.25);
  color: #d9e1ff;
  font-size: 0.88rem;
}

body[data-view="admin"] #admin-view input,
body[data-view="admin"] #admin-view select {
  min-height: 48px;
  border-radius: 15px;
  border-color: rgba(132, 146, 214, 0.2);
  background: rgba(10, 15, 27, 0.94);
  color: #f4f7ff;
}

body[data-view="admin"] #admin-view input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

body[data-view="admin"] #admin-view input[type="number"]::-webkit-inner-spin-button,
body[data-view="admin"] #admin-view input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

body[data-view="admin"] #admin-view input::placeholder {
  color: #7280aa;
}

body[data-view="admin"] #admin-view input:focus,
body[data-view="admin"] #admin-view select:focus {
  outline: 3px solid rgba(115, 129, 255, 0.14);
  border-color: rgba(144, 157, 255, 0.48);
}

body[data-view="admin"] #admin-view .field span {
  color: #8390b3;
}

body[data-view="admin"] #admin-view .inline-action-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

body[data-view="admin"] #admin-view .chip {
  border-color: rgba(132, 145, 214, 0.2);
  background: rgba(20, 27, 45, 0.82);
  color: #e7edff;
}

body[data-view="admin"] #admin-view .chip-list__empty {
  color: #8f9cc3;
}

body[data-view="admin"] #admin-view .button {
  min-height: 42px;
  border-radius: 15px;
  background: linear-gradient(180deg, rgba(34, 43, 68, 0.96), rgba(22, 29, 49, 0.96));
  color: #ecf1ff;
  box-shadow: none;
}

body[data-view="admin"] #admin-view .button--sm {
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.86rem;
}

body[data-view="admin"] #admin-view .button--primary {
  background: linear-gradient(180deg, #6377ff, #4d60d8);
  color: #ffffff;
}

body[data-view="admin"] #admin-view .button--accent {
  background: linear-gradient(180deg, #17b38b, #118267);
  color: #ffffff;
}

body[data-view="admin"] #admin-view .button--ghost {
  border: 1px solid rgba(130, 145, 214, 0.2);
  background: rgba(12, 18, 31, 0.6);
  color: #d7def8;
}

body[data-view="admin"] #admin-view .table-shell {
  border-radius: 20px;
  border: 1px solid rgba(132, 145, 214, 0.16);
  background: rgba(10, 15, 27, 0.9);
  overflow: auto;
}

body[data-view="admin"] #admin-view .data-table {
  width: 100%;
  border-collapse: collapse;
  color: #edf2ff;
}

body[data-view="admin"] #admin-view .data-table thead th {
  padding: 14px 16px;
  text-align: left;
  color: #8994b6;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  border-bottom: 1px solid rgba(132, 145, 214, 0.14);
  background: rgba(18, 24, 40, 0.96);
}

body[data-view="admin"] #admin-view .data-table tbody td {
  padding: 15px 16px;
  border-top: 1px solid rgba(132, 145, 214, 0.1);
  vertical-align: middle;
}

body[data-view="admin"] #admin-view .data-table tbody tr:hover {
  background: rgba(91, 105, 180, 0.08);
}

body[data-view="admin"] #admin-view .text-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  margin-right: 6px;
  border-radius: 999px;
  border: 1px solid rgba(132, 145, 214, 0.16);
  background: rgba(20, 27, 45, 0.9);
  color: #dfe6ff;
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 700;
}

body[data-view="admin"] #admin-view .text-link:last-child {
  margin-right: 0;
}

body[data-view="admin"] #admin-view .table-action-stack .text-link {
  width: 100%;
  justify-content: center;
  margin-right: 0;
}

body[data-view="admin"] #admin-view #tournaments-table {
  table-layout: fixed;
}

body[data-view="admin"] #admin-view #tournaments-table,
body[data-view="admin"] #admin-view #tournaments-table th,
body[data-view="admin"] #admin-view #tournaments-table td {
  min-width: 0;
}

body[data-view="admin"] #admin-view #tournaments-table th:nth-child(1),
body[data-view="admin"] #admin-view #tournaments-table td:nth-child(1) {
  width: 30%;
}

body[data-view="admin"] #admin-view #tournaments-table th:nth-child(2),
body[data-view="admin"] #admin-view #tournaments-table td:nth-child(2) {
  width: 28%;
}

body[data-view="admin"] #admin-view #tournaments-table th:nth-child(3),
body[data-view="admin"] #admin-view #tournaments-table td:nth-child(3) {
  width: 16%;
}

body[data-view="admin"] #admin-view #tournaments-table th:nth-child(4),
body[data-view="admin"] #admin-view #tournaments-table td:nth-child(4) {
  width: 14%;
}

body[data-view="admin"] #admin-view #tournaments-table th:nth-child(5),
body[data-view="admin"] #admin-view #tournaments-table td:nth-child(5) {
  width: 12%;
  text-align: center;
}

body[data-view="admin"] #admin-view #tournaments-table th,
body[data-view="admin"] #admin-view #tournaments-table td {
  padding-left: 10px;
  padding-right: 10px;
}

body[data-view="admin"] #admin-view #tournaments-table th {
  font-size: 0.64rem;
  letter-spacing: 0.08em;
}

body[data-view="admin"] #admin-view #tournaments-table td {
  overflow-wrap: normal;
  word-break: normal;
}

body[data-view="admin"] #admin-view #tournaments-table .tournament-name,
body[data-view="admin"] #admin-view #tournaments-table .tournament-room-code {
  display: block;
}

body[data-view="admin"] #admin-view #tournaments-table .tournament-name {
  max-width: 100%;
  color: #7890ff;
  line-height: 1.2;
  overflow-wrap: break-word;
}

body[data-view="admin"] #admin-view #tournaments-table tr[data-tournament-row] {
  cursor: pointer;
}

body[data-view="admin"] #admin-view #tournaments-table .tournament-room-code {
  margin-top: 6px;
  color: #c3ccee;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

body[data-view="admin"] #admin-view #tournaments-table th:nth-child(3),
body[data-view="admin"] #admin-view #tournaments-table td:nth-child(3),
body[data-view="admin"] #admin-view #tournaments-table th:nth-child(5),
body[data-view="admin"] #admin-view #tournaments-table td:nth-child(5) {
  white-space: nowrap;
}

body[data-view="admin"] #admin-view #tournaments-table .table-action-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  gap: 6px;
}

body[data-view="admin"] #admin-view #tournaments-table .table-action-stack .text-link {
  min-height: 30px;
  padding: 0 8px;
  font-size: 0.78rem;
  line-height: 1.15;
  white-space: normal;
}

body[data-view="admin"] #admin-view .table-menu {
  position: relative;
  display: inline-flex;
  justify-content: center;
}

body[data-view="admin"] #admin-view .table-menu__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 34px;
  border: 1px solid rgba(132, 145, 214, 0.22);
  border-radius: 999px;
  background: rgba(20, 27, 45, 0.9);
  color: #edf2ff;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

body[data-view="admin"] #admin-view .table-menu__trigger:hover,
body[data-view="admin"] #admin-view .table-menu__trigger:focus-visible,
body[data-view="admin"] #admin-view .table-menu__trigger[aria-expanded="true"] {
  border-color: rgba(145, 158, 255, 0.42);
  background: rgba(92, 108, 196, 0.2);
  outline: 0;
}

body[data-view="admin"] #admin-view .table-menu__panel,
body[data-view="admin"] #floating-tournament-menu {
  position: absolute;
  z-index: 1000;
  display: grid;
  width: 190px;
  min-width: 190px;
  max-width: calc(100vw - 24px);
  padding: 6px;
  border: 1px solid rgba(132, 145, 214, 0.22);
  border-radius: 14px;
  background: #0b1020;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
  overflow: visible;
  text-align: left;
}

body[data-view="admin"] #admin-view .table-menu__panel[hidden],
body[data-view="admin"] #floating-tournament-menu[hidden] {
  display: none;
}

body[data-view="admin"] #admin-view .table-menu__item,
body[data-view="admin"] #floating-tournament-menu .table-menu__item {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #dfe6ff;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

body[data-view="admin"] #admin-view .table-menu__item:hover,
body[data-view="admin"] #admin-view .table-menu__item:focus-visible,
body[data-view="admin"] #floating-tournament-menu .table-menu__item:hover,
body[data-view="admin"] #floating-tournament-menu .table-menu__item:focus-visible {
  background: rgba(92, 108, 196, 0.2);
  color: #ffffff;
  outline: 0;
}

body[data-view="admin"] #admin-view .table-menu__note,
body[data-view="admin"] #floating-tournament-menu .table-menu__note {
  padding: 6px 10px;
  color: #8d98ba;
  font-size: 0.78rem;
  line-height: 1.25;
}

body[data-view="admin"] #admin-view .text-link:hover,
body[data-view="admin"] #admin-view .text-link:focus-visible {
  background: rgba(92, 108, 196, 0.18);
  border-color: rgba(145, 158, 255, 0.34);
  outline: 0;
}

body[data-view="admin"] #admin-view .detail-box__stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

body[data-view="admin"] #admin-view .stat-tile {
  background: rgba(12, 18, 31, 0.92);
  border: 1px solid rgba(132, 145, 214, 0.16);
}

body[data-view="admin"] #admin-view .stat-tile span {
  color: #8c98bb;
}

body[data-view="admin"] #admin-view .stat-tile strong {
  color: #f4f7ff;
  font-family: "Bahnschrift", "Trebuchet MS", sans-serif;
}

body[data-view="admin"] #admin-view .group-item {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(132, 145, 214, 0.16);
  background: rgba(10, 15, 27, 0.9);
}

body[data-view="admin"] #admin-view .group-item--active {
  border-color: rgba(135, 148, 224, 0.4);
  box-shadow: inset 0 0 0 1px rgba(103, 119, 255, 0.22);
}

body[data-view="admin"] #admin-view .group-item + .group-item {
  margin-top: 12px;
}

body[data-view="admin"] #admin-view .group-target-row,
body[data-view="admin"] #admin-view .admin-monitor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

body[data-view="admin"] #admin-view .group-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

body[data-view="admin"] #admin-view .group-name-text {
  flex: 1 1 120px;
  min-width: 0;
  overflow: hidden;
  color: #f4f7ff;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-view="admin"] #admin-view .group-targets {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

body[data-view="admin"] #admin-view .group-target-row {
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(20, 27, 45, 0.72);
  color: #d7def8;
  font-size: 0.88rem;
}

body[data-view="admin"] #admin-view .add-target-form {
  margin-top: 12px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(20, 27, 45, 0.5);
  border: 1px solid rgba(132, 145, 214, 0.2);
}

body[data-view="admin"] #admin-view .add-target-form__inputs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

body[data-view="admin"] #admin-view .add-target-input {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(132, 145, 214, 0.3);
  background: rgba(30, 38, 64, 0.6);
  color: #d7def8;
  font-size: 0.88rem;
  font-family: inherit;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

body[data-view="admin"] #admin-view .add-target-input:focus {
  outline: none;
  border-color: rgba(103, 119, 255, 0.6);
  background: rgba(30, 38, 64, 0.8);
}

body[data-view="admin"] #admin-view .add-target-input::placeholder {
  color: rgba(215, 222, 248, 0.4);
}

body[data-view="admin"] #admin-view .add-target-form__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

body[data-view="admin"] #admin-view .digit-mode-field {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

body[data-view="admin"] #admin-view .digit-mode-label {
  font-size: 0.8rem;
  color: var(--ink-2);
  white-space: nowrap;
}

body[data-view="admin"] #admin-view .digit-mode-options {
  display: flex;
  gap: 6px;
}

body[data-view="admin"] #admin-view .digit-mode-option input[type="radio"] {
  display: none;
}

body[data-view="admin"] #admin-view .digit-mode-option span {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid rgba(132, 145, 214, 0.3);
  background: rgba(20, 27, 45, 0.6);
  color: rgba(215, 222, 248, 0.6);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

body[data-view="admin"] #admin-view .digit-mode-option input[type="radio"]:checked + span {
  background: rgba(92, 108, 196, 0.35);
  border-color: rgba(103, 119, 255, 0.7);
  color: #d7def8;
}

body[data-view="admin"] #admin-view .digit-mode-option span:hover {
  border-color: rgba(132, 145, 214, 0.55);
  color: rgba(215, 222, 248, 0.85);
}

body[data-view="admin"] #admin-view .text-link--accent {
  background: rgba(92, 108, 196, 0.22);
  border-color: rgba(103, 119, 255, 0.45);
  color: #a5b0ff;
}

body[data-view="admin"] #admin-view .text-link--accent:hover,
body[data-view="admin"] #admin-view .text-link--accent:focus-visible {
  background: rgba(92, 108, 196, 0.38);
  border-color: rgba(103, 119, 255, 0.7);
  color: #c5ccff;
}

body[data-view="admin"] #admin-view .admin-monitor-toolbar {
  flex-wrap: wrap;
  margin-bottom: 16px;
}

body[data-view="admin"] #admin-view .monitor-picker {
  margin-bottom: 2px;
}

body[data-view="admin"] #admin-view .admin-monitor-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.assign-popup.panel {
  max-width: 300px;
}

body[data-view="admin"] .assign-popup.panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(18, 24, 40, 0.98), rgba(11, 16, 28, 0.98));
  border: 1px solid rgba(136, 149, 222, 0.22);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.38);
}

body[data-view="admin"] .assign-popup.panel select {
  min-height: 44px;
  border-radius: 12px;
  background: rgba(10, 15, 27, 0.96);
  color: #eef2ff;
  border: 1px solid rgba(132, 145, 214, 0.18);
}

/* ============================================================
   TEACHER FILTER BAR (SuperAdmin view)
   ============================================================ */
.teacher-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 0.78rem;
  color: var(--ink-2);
}

.teacher-filter-bar select {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.78rem;
  cursor: pointer;
}

@media (max-width: 1100px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    min-height: auto;
  }

  .admin-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .admin-nav__button {
    justify-content: center;
  }

  .admin-nav__button span:last-child {
    display: none;
  }

  .admin-overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-overview-layout,
  .admin-split,
  .admin-split--students {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1320px) {
  .admin-split--tournaments {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .admin-topbar {
    padding: 20px;
    align-items: start;
  }

  .admin-topbar,
  .admin-monitor-toolbar {
    flex-direction: column;
  }

  .admin-nav {
    grid-template-columns: 1fr 1fr;
  }

  .admin-nav__button span:last-child {
    display: inline;
  }

  .admin-overview-grid,
  body[data-view="admin"] #admin-view .admin-monitor-stats,
  body[data-view="admin"] #admin-view .detail-box__stats {
    grid-template-columns: 1fr;
  }
}

/* ── Phase 2+4: Student detail panel ──────────────────── */
.players-toolbar { margin-bottom: 12px; }
.student-profile-header { background: var(--surface-2, #f8f9fa); border-radius: 8px; padding: 14px 16px; margin-bottom: 16px; }
.badge-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.badge-chip { background: var(--accent-dim, #ede9fe); color: var(--accent, #5c6cc4); border-radius: 6px; padding: 3px 10px; font-size: 0.78rem; font-weight: 600; }
.profile-stats { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.85rem; color: var(--ink-2); margin-top: 8px; }
.school-name { color: var(--ink-2); font-size: 0.85rem; margin-left: 8px; }
.history-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.history-table th, .history-table td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border, #e5e7eb); }
.history-table th { font-weight: 600; color: var(--ink-2); }
.session-row:hover td { background: rgba(92,108,196,0.04); }
.attempt-table { width: 100%; font-size: 0.78rem; border-collapse: collapse; }
.attempt-table td, .attempt-table th { padding: 4px 8px; }
.retry-label { font-size: 0.72rem; color: var(--ink-2); }
.history-pager { font-size: 0.78rem; color: var(--ink-2); margin-top: 8px; }

/* ── Phase 2+4: Group editing + leaderboard ──────────── */
.inline-edit-input { border: 1px solid var(--accent, #5c6cc4); border-radius: 4px; padding: 2px 6px; font-size: 0.9rem; min-width: 120px; }
.inline-target-form { display: flex; gap: 6px; align-items: center; padding: 6px 0; flex-wrap: wrap; }
.form-input-sm { width: 68px; padding: 4px 6px; border: 1px solid var(--border, #d1d5db); border-radius: 4px; font-size: 0.82rem; }
.drag-handle { cursor: grab; color: var(--ink-2); user-select: none; margin-right: 4px; }
.group-hint-settings { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 0.82rem; color: var(--ink-2); border-top: 1px solid rgba(132,145,214,0.1); margin-top: 6px; }
.group-hint-label { font-weight: 600; }
.group-hint-note { color: var(--ink-3, #9ca3af); font-style: italic; }
.overdue { background: rgba(239,68,68,0.12) !important; }
.overdue strong { color: #ef4444; }
.overdue-label { font-size: 0.72rem; color: #ef4444; font-weight: 600; }
.due-label { font-size: 0.72rem; color: var(--ink-3, #9ca3af); }
.group-target-row.dragging { opacity: 0.4; }
.group-target-row.drag-over { background: rgba(92,108,196,0.08); border-radius: 4px; }
.leaderboard-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.leaderboard-table th, .leaderboard-table td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border, #e5e7eb); }
.leaderboard-table th { font-weight: 600; color: var(--ink-2); }
.compare-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin-bottom: 20px; }
.compare-table th, .compare-table td { padding: 8px 12px; text-align: center; border-bottom: 1px solid var(--border, #e5e7eb); }
.compare-table th { font-weight: 600; background: rgba(92,108,196,0.07); }
.compare-table .compare-label { font-weight: 500; color: var(--ink-2); text-align: center; font-size: 0.8rem; }
.compare-winner { font-weight: 700; color: var(--accent, #5c6cc4); }
.compare-entries { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 4px; }
.compare-entries-col { min-width: 0; }
.compare-col-title { font-size: 0.9rem; font-weight: 600; margin-bottom: 8px; color: var(--ink-1); }
.compare-entries-table { font-size: 0.8rem; }
.digest-toggle { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--ink-2); cursor: pointer; padding: 6px 0; }
.digest-toggle input { accent-color: var(--accent, #5c6cc4); width: 14px; height: 14px; cursor: pointer; }

body[data-view="admin"] #admin-view .group-menu {
  position: relative;
  flex: 0 0 auto;
}

body[data-view="admin"] #admin-view .group-menu__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 34px;
  border: 1px solid rgba(132, 145, 214, 0.22);
  border-radius: 999px;
  background: rgba(20, 27, 45, 0.9);
  color: #edf2ff;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

body[data-view="admin"] #admin-view .group-menu__trigger:hover,
body[data-view="admin"] #admin-view .group-menu__trigger:focus-visible,
body[data-view="admin"] #admin-view .group-menu__trigger[aria-expanded="true"] {
  border-color: rgba(145, 158, 255, 0.42);
  background: rgba(92, 108, 196, 0.2);
  outline: 0;
}

body[data-view="admin"] #admin-view .group-menu__panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 12;
  display: grid;
  min-width: 180px;
  padding: 6px;
  border: 1px solid rgba(132, 145, 214, 0.22);
  border-radius: 14px;
  background: #0b1020;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
}

body[data-view="admin"] #admin-view .group-menu__panel[hidden] {
  display: none;
}

body[data-view="admin"] #admin-view .group-menu__item {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #dfe6ff;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

body[data-view="admin"] #admin-view .group-menu__item:hover,
body[data-view="admin"] #admin-view .group-menu__item:focus-visible {
  background: rgba(92, 108, 196, 0.2);
  color: #ffffff;
  outline: 0;
}

body[data-view="admin"] #admin-view .group-hint-settings {
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(132,145,214,0.14);
  border-radius: 14px;
  background: rgba(12, 18, 31, 0.72);
}

body[data-view="admin"] #admin-view .group-hint-settings .form-input-sm {
  width: 104px !important;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 12px;
}

body[data-view="admin"] #admin-view .group-hint-label {
  color: #b6c0df;
}

body[data-view="admin"] #admin-view .group-hint-note {
  color: #8d98ba;
  white-space: normal;
}

body[data-view="admin"] #admin-view .digest-toggle {
  width: fit-content;
  gap: 8px;
  color: #d7def8;
}

body[data-view="admin"] #admin-view .digest-toggle input[type="checkbox"] {
  position: relative;
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  appearance: none;
  border: 1px solid rgba(132, 145, 214, 0.42);
  border-radius: 5px;
  background: rgba(10, 15, 27, 0.94);
  cursor: pointer;
}

body[data-view="admin"] #admin-view .digest-toggle input[type="checkbox"]:checked {
  border-color: rgba(116, 132, 255, 0.9);
  background: #6377ff;
}

body[data-view="admin"] #admin-view .digest-toggle input[type="checkbox"]:checked::after {
  position: absolute;
  top: 1px;
  left: 5px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  content: "";
  transform: rotate(45deg);
}

@media (max-width: 760px) {
  body[data-view="admin"] #admin-view #tournaments-table .table-action-stack {
    grid-template-columns: 1fr;
  }
}

.push-card-results { margin-top: 12px; }
.push-card-solved-count { font-weight: 600; font-size: 0.85rem; color: var(--ink-2); margin-bottom: 8px; }
.push-card-results-list { list-style: none; padding: 0; margin: 0; font-size: 0.82rem; }
.push-card-results-list li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--border, #e5e7eb); }

.flags-badge { display: inline-block; background: #ef4444; color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 0.7rem; font-weight: 700; margin-left: 4px; }
.flag-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border, #e5e7eb); flex-wrap: wrap; gap: 4px; }
.flag-card-info { font-weight: 600; font-size: 0.88rem; }
.flag-numbers { font-family: monospace; }
.flag-target { color: var(--ink-2); margin-left: 6px; }
.flag-meta { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--ink-3); }

/* Difficulty heatmap */
.heatmap-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem 0;
}

.heatmap-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.8rem;
  min-width: 90px;
  text-align: center;
  border: 1px solid transparent;
}

.heatmap-card--green  { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }
.heatmap-card--amber  { background: #fef3c7; border-color: #fcd34d; color: #78350f; }
.heatmap-card--red    { background: #fee2e2; border-color: #fca5a5; color: #7f1d1d; }
.heatmap-card--grey   { background: #f3f4f6; border-color: #d1d5db; color: #6b7280; }

.heatmap-card__numbers { font-weight: 700; font-size: 0.9rem; letter-spacing: 0.05em; }
.heatmap-card__pct     { font-weight: 600; }
.heatmap-card__sub     { font-size: 0.7rem; opacity: 0.8; }

.heatmap-btn { font-size: 0.75rem; padding: 0.1rem 0.4rem; }

.heatmap-card__hint-input {
  width: 100%;
  font-size: 0.65rem;
  padding: 2px 4px;
  margin-top: 4px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 3px;
  background: rgba(0,0,0,0.2);
  color: inherit;
  box-sizing: border-box;
}
.heatmap-card__hint-input::placeholder { opacity: 0.6; }

/* ============================================================
   2026 clean responsive redesign
   ============================================================ */
:root {
  --bg: #f5f7fb;
  --panel-bg-top: #ffffff;
  --panel-bg-bottom: #ffffff;
  --panel-border: #dfe6f2;
  --panel-accent: #eef6f3;
  --muted: #647086;
  --line: #e8edf5;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --green: #14866d;
  --red: #dc2626;
  --blue: #2563eb;
  --yellow: #d48a00;
  --ink: #152033;
  --ink-2: #536174;
  --ink-3: #7a8698;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --border: #dfe6f2;
  --border-strong: #bfcbda;
  --radius-xl: 18px;
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --hero-font: "Aptos Display", "Segoe UI", sans-serif;
  --body-font: "Aptos", "Segoe UI", sans-serif;
  --shadow-soft: 0 18px 48px rgba(22, 34, 52, 0.08);
  --shadow-card: 0 22px 56px rgba(22, 34, 52, 0.12);
  --control-bg: #ffffff;
  --control-very-light: #152033;
}

html {
  background: var(--bg);
  color-scheme: light;
}

body {
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(245, 247, 251, 0.94)),
    repeating-linear-gradient(90deg, rgba(37, 99, 235, 0.035) 0 1px, transparent 1px 72px),
    #f5f7fb;
  font-family: var(--body-font);
  letter-spacing: 0;
}

.page-noise {
  opacity: 0.28;
  mix-blend-mode: normal;
  background-image:
    linear-gradient(rgba(21, 32, 51, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 32, 51, 0.035) 1px, transparent 1px);
  background-size: 32px 32px;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 16px auto 28px;
  gap: 16px;
}

.masthead {
  position: sticky;
  top: 10px;
  z-index: 20;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 86px;
  padding: 18px 20px;
  border-radius: 14px;
}

.masthead,
.panel,
.panel--hero,
.detail-box,
.toast,
.admin-sidebar,
.admin-stage,
.metric-card,
.stat-tile,
.table-shell,
.feedback-panel,
.queue-strip,
.tp-join-panel,
.tp-waiting-panel,
.tp-finished-panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  color: var(--ink);
}

.masthead h1,
.panel__heading h2,
.hero-bar h2,
.admin-topbar h2,
.tp-display__title,
#admin-heading {
  margin: 0;
  color: var(--ink);
  font-family: var(--hero-font);
  font-weight: 800;
  letter-spacing: 0;
}

.masthead h1 {
  font-size: clamp(1.8rem, 3vw, 2.8rem);
}

.masthead__lede,
.panel__heading p,
.form-note,
.delivery-note,
.detail-box,
.feedback-panel,
.status-note,
.muted {
  color: var(--ink-2);
}

.eyebrow {
  color: #1d8175;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.status-pill {
  min-height: 32px;
  border-color: #cfd9e8;
  background: #f8fafc;
  color: #334155;
  box-shadow: none;
}

.admin-shell {
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.admin-sidebar {
  position: sticky;
  top: 112px;
  max-height: calc(100vh - 128px);
  overflow: auto;
  padding: 16px;
  border-radius: 14px;
}

.admin-brand {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.admin-brand__logo {
  width: 42px;
  height: 42px;
}

.admin-brand__copy strong,
.admin-account strong {
  color: var(--ink);
}

.admin-brand__copy span,
.admin-account__label,
.admin-account__meta {
  color: var(--ink-3);
}

.admin-account {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
}

.admin-nav {
  gap: 8px;
}

.admin-nav__button {
  min-height: 48px;
  border-radius: 8px;
  color: var(--ink-2);
  font-weight: 800;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.admin-nav__button:hover {
  background: #f1f5f9;
  color: var(--ink);
  transform: translateX(2px);
}

.admin-nav__button.is-active {
  border-color: rgba(37, 99, 235, 0.28);
  background: #eaf1ff;
  color: #1749b8;
}

.admin-nav__icon {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #dbe4f0;
  color: #1d8175;
  font-size: 0.82rem;
  font-weight: 900;
}

.admin-stage {
  min-width: 0;
  padding: 18px;
  border-radius: 14px;
}

.admin-section:not(.is-active) {
  display: none;
}

.admin-topbar,
.hero-bar {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.admin-topbar__copy,
.hero-bar > div {
  min-width: 0;
}

.admin-topbar h2 {
  font-size: clamp(1.35rem, 2.4vw, 2rem);
}

.panel,
.panel--hero {
  padding: 18px;
  border-radius: 12px;
}

.panel--compact {
  padding: 14px;
  border-radius: 10px;
  box-shadow: none;
}

.form-stack {
  gap: 14px;
}

.field span,
.metric-card__label,
.stat-tile span,
.metric-list__item span,
.queue-strip__heading span {
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

input,
select,
textarea,
.solver-shell input,
.custom-dropdown__button {
  min-height: 46px;
  border: 1px solid #ccd7e6;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(22, 34, 52, 0.03);
}

input:focus,
select:focus,
textarea:focus,
.solver-shell input:focus,
.custom-dropdown__button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.16);
  border-color: #2563eb;
}

input::placeholder {
  color: #9aa6b6;
}

select option,
.panel select option,
.admin-stage select option {
  background: #ffffff;
  color: var(--ink);
}

.custom-dropdown__list {
  border-color: var(--border);
  background: #ffffff;
  box-shadow: 0 16px 40px rgba(22, 34, 52, 0.16);
}

.custom-dropdown__option {
  color: var(--ink);
}

.custom-dropdown__option:hover,
.custom-dropdown__option.is-selected {
  background: #eaf1ff;
  color: #1749b8;
}

.button,
.pad-key {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid #ccd7e6;
  background: #ffffff;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: none;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease, border-color 150ms ease;
}

.button:hover,
.pad-key:hover {
  transform: translateY(-1px);
  border-color: #aebdd0;
  box-shadow: 0 10px 24px rgba(22, 34, 52, 0.1);
}

.button--primary,
.button--accent {
  border-color: transparent;
  background: #2563eb;
  color: #ffffff;
}

.button--accent {
  background: #14866d;
}

.button--ghost {
  background: #f8fafc;
  color: #334155;
}

.session-metrics,
.stats-grid,
.admin-grid,
.student-info-grid {
  gap: 10px;
}

.metric-card,
.stat-tile {
  border-radius: 10px;
  padding: 14px;
  background: #ffffff;
  box-shadow: none;
}

.metric-card strong,
.stat-tile strong,
.metric-list__item strong {
  color: var(--ink);
  letter-spacing: 0;
}

.arena {
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: 16px;
}

.arena__card,
.arena__solver {
  min-width: 0;
}

.card-stage {
  min-height: 350px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(20, 134, 109, 0.06), rgba(37, 99, 235, 0.04)),
    #f8fafc;
}

.math-card {
  width: min(78vw, 310px);
  aspect-ratio: 1;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 22px 48px rgba(22, 34, 52, 0.15);
}

.math-card__panel {
  border-color: #cfd9e8;
  background: #fdfefe;
}

.math-card__tab span {
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(22, 34, 52, 0.12);
}

.math-card__id,
.math-card__badge {
  border-color: #dfe6f2;
  background: #ffffff;
  color: var(--ink-2);
}

.queue-strip,
.student-queue {
  border-radius: 10px;
  background: #f8fafc;
  box-shadow: none;
}

.digit-bank {
  gap: 8px;
}

.digit-chip,
.queue-card {
  border-color: #d6e0ed;
  background: #ffffff;
  color: var(--ink);
  box-shadow: none;
}

.solver-shell {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.pad-rows {
  gap: 10px;
}

.pad-row {
  gap: 8px;
}

.pad-key {
  min-width: 46px;
  background: #f8fafc;
}

.pad-key--number {
  background: #ffffff;
}

.feedback-panel {
  border-radius: 10px;
  box-shadow: none;
}

.feedback-panel[data-tone="success"] {
  border-color: rgba(20, 134, 109, 0.26);
  background: #edf9f6;
  color: #116b59;
}

.feedback-panel[data-tone="error"] {
  border-color: rgba(220, 38, 38, 0.22);
  background: #fff1f2;
  color: #b91c1c;
}

.table-shell {
  overflow: auto;
  border-radius: 10px;
  box-shadow: none;
}

.data-table {
  min-width: 720px;
  color: var(--ink);
}

.data-table th {
  background: #f8fafc;
  color: var(--ink-2);
  letter-spacing: 0.04em;
}

.data-table td {
  color: var(--ink);
}

.chip,
.quest-chip,
.flags-badge {
  border-radius: 999px;
}

.toast {
  color: var(--ink);
}

#tournament-page-view {
  min-height: calc(100vh - 130px);
}

.tp-centered {
  min-height: min(680px, calc(100vh - 150px));
}

.tp-header,
.tp-display__header {
  border-radius: 14px;
}

.tp-header__timer,
.tp-display__timer {
  color: #1749b8;
  letter-spacing: 0;
}

@media (max-width: 980px) {
  .masthead {
    position: static;
    grid-template-columns: 1fr;
  }

  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    max-height: none;
  }

  .admin-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .admin-nav__button {
    justify-content: center;
    text-align: center;
  }

  .arena {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .app-shell {
    width: min(100% - 20px, 560px);
    margin-top: 10px;
  }

  .masthead,
  .admin-stage,
  .admin-sidebar,
  .panel,
  .panel--hero {
    border-radius: 10px;
  }

  .masthead {
    padding: 16px;
  }

  .masthead h1 {
    font-size: 2rem;
  }

  .admin-nav {
    grid-template-columns: 1fr;
  }

  .admin-nav__button {
    justify-content: flex-start;
  }

  .admin-topbar,
  .hero-bar,
  .student-headline,
  .tp-header,
  .tp-display__header {
    display: grid;
    grid-template-columns: 1fr;
  }

  .session-metrics,
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .solver-shell {
    grid-template-columns: 1fr;
  }

  .solver-shell .button {
    width: 100%;
  }

  .pad-row--symbols,
  .pad-row--numbers,
  .pad-row--actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .math-card {
    width: min(78vw, 280px);
  }
}

@media (max-width: 420px) {
  .session-metrics,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .math-card {
    width: min(82vw, 250px);
  }
}

/* Dark-only finish: keep the cleaner layout without the mixed light shell. */
:root {
  --bg: #080d18;
  --panel-bg-top: #111827;
  --panel-bg-bottom: #0b1220;
  --panel-border: rgba(145, 162, 217, 0.18);
  --panel-accent: rgba(96, 119, 255, 0.08);
  --muted: #93a3c7;
  --line: rgba(145, 162, 217, 0.14);
  --accent: #7c8cff;
  --accent-dark: #6474e8;
  --green: #28c39f;
  --red: #ff5c75;
  --blue: #6f8cff;
  --yellow: #f0c14b;
  --ink: #edf3ff;
  --ink-2: #aab7d4;
  --ink-3: #8190b3;
  --surface: #111827;
  --surface-2: #0d1422;
  --surface-3: #182236;
  --border: rgba(145, 162, 217, 0.18);
  --border-strong: rgba(174, 190, 255, 0.34);
  --shadow-soft: 0 22px 58px rgba(0, 0, 0, 0.38);
  --shadow-card: 0 28px 74px rgba(0, 0, 0, 0.5);
  --control-bg: #090f1c;
  --control-very-light: #edf3ff;
}

html {
  background: var(--bg);
  color-scheme: dark;
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 10%, rgba(84, 104, 255, 0.18), transparent 24%),
    radial-gradient(circle at 88% 3%, rgba(40, 195, 159, 0.1), transparent 22%),
    linear-gradient(180deg, #080d18 0%, #0c1322 48%, #080d18 100%);
}

.page-noise {
  opacity: 0.12;
  mix-blend-mode: screen;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
}

.masthead,
.panel,
.panel--hero,
.detail-box,
.toast,
.admin-sidebar,
.admin-stage,
.metric-card,
.stat-tile,
.table-shell,
.feedback-panel,
.queue-strip,
.tp-join-panel,
.tp-waiting-panel,
.tp-finished-panel {
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(11, 18, 32, 0.98));
  border-color: var(--border);
  box-shadow: var(--shadow-soft);
  color: var(--ink);
}

.masthead h1,
.panel__heading h2,
.hero-bar h2,
.admin-topbar h2,
.tp-display__title,
#admin-heading,
.admin-brand__copy strong,
.admin-account strong,
.metric-card strong,
.stat-tile strong,
.metric-list__item strong {
  color: var(--ink);
}

.masthead__lede,
.panel__heading p,
.form-note,
.delivery-note,
.detail-box,
.feedback-panel,
.status-note,
.muted,
.admin-brand__copy span,
.admin-account__label,
.admin-account__meta {
  color: var(--ink-2);
}

.eyebrow,
.field span,
.metric-card__label,
.stat-tile span,
.metric-list__item span,
.queue-strip__heading span {
  color: #9aa8ff;
}

.admin-account,
.metric-card,
.stat-tile,
.queue-strip,
.student-queue,
.card-stage,
.feedback-panel,
.table-shell {
  background: rgba(8, 14, 26, 0.64);
  border-color: var(--border);
}

.admin-brand {
  border-bottom-color: var(--line);
}

.admin-nav__button {
  color: var(--ink-2);
}

.admin-nav__button:hover {
  background: rgba(124, 140, 255, 0.12);
  color: var(--ink);
}

.admin-nav__button.is-active {
  border-color: rgba(124, 140, 255, 0.42);
  background: rgba(124, 140, 255, 0.18);
  color: #ffffff;
}

.admin-nav__icon {
  border-color: rgba(145, 162, 217, 0.24);
  background: rgba(8, 14, 26, 0.84);
  color: #48d4b2;
}

input,
select,
textarea,
.solver-shell input,
.custom-dropdown__button {
  border-color: rgba(145, 162, 217, 0.26);
  background: #080e1a;
  color: var(--ink);
  box-shadow: none;
}

input::placeholder {
  color: #6f7e9e;
}

input:focus,
select:focus,
textarea:focus,
.solver-shell input:focus,
.custom-dropdown__button:focus-visible {
  outline-color: rgba(124, 140, 255, 0.2);
  border-color: rgba(154, 168, 255, 0.72);
}

select option,
.panel select option,
.admin-stage select option,
.custom-dropdown__list {
  background: #0b1220;
  color: var(--ink);
}

.custom-dropdown__option {
  color: var(--ink);
}

.custom-dropdown__option:hover,
.custom-dropdown__option.is-selected {
  background: rgba(124, 140, 255, 0.2);
  color: #ffffff;
}

.button,
.pad-key {
  border-color: rgba(145, 162, 217, 0.26);
  background: #101827;
  color: var(--ink);
}

.button:hover,
.pad-key:hover {
  border-color: rgba(174, 190, 255, 0.42);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.button--primary {
  background: #6474e8;
  color: #ffffff;
}

.button--accent {
  background: #159979;
  color: #ffffff;
}

.button--ghost {
  background: rgba(145, 162, 217, 0.11);
  color: var(--ink);
}

.data-table {
  color: var(--ink);
}

.data-table th {
  background: rgba(10, 17, 31, 0.88);
  color: var(--ink-3);
}

.data-table td {
  color: var(--ink-2);
  border-color: rgba(145, 162, 217, 0.12);
}

.math-card {
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.math-card__panel {
  background: #f8fbff;
  border-color: #d8dfec;
}

.math-card__tab span {
  color: #111827;
}

.math-card__id,
.math-card__badge {
  background: #ffffff;
  border-color: #d8dfec;
  color: #334155;
}

.digit-chip,
.queue-card {
  border-color: rgba(145, 162, 217, 0.24);
  background: rgba(8, 14, 26, 0.72);
  color: var(--ink);
}

.feedback-panel[data-tone="success"] {
  border-color: rgba(40, 195, 159, 0.34);
  background: rgba(40, 195, 159, 0.1);
  color: #7be6cd;
}

.feedback-panel[data-tone="error"] {
  border-color: rgba(255, 92, 117, 0.34);
  background: rgba(255, 92, 117, 0.1);
  color: #ff9aaa;
}

.tp-header__timer,
.tp-display__timer {
  color: #a8b3ff;
}

.heatmap-card--green  { background: rgba(40, 195, 159, 0.12); border-color: rgba(40, 195, 159, 0.34); color: #9df0dd; }
.heatmap-card--amber  { background: rgba(240, 193, 75, 0.12); border-color: rgba(240, 193, 75, 0.34); color: #ffe19b; }
.heatmap-card--red    { background: rgba(255, 92, 117, 0.12); border-color: rgba(255, 92, 117, 0.34); color: #ffb3bf; }
.heatmap-card--grey   { background: rgba(145, 162, 217, 0.1); border-color: rgba(145, 162, 217, 0.22); color: var(--ink-2); }

/* Arcade rebrand: align the full app with the retro leaderboard language. */
:root {
  --pixel-font: "Press Start 2P", "Courier New", monospace;
  --display-font: "VT323", "Courier New", monospace;
  --gold: #f6c54d;
  --arcade-red: #ff5b6e;
  --arcade-blue: #4b7dff;
  --arcade-green: #35d399;
  --arcade-cyan: #5fd3ff;
  --arcade-purple: #c78bff;
  --radius-xl: 0;
  --radius-lg: 0;
  --radius-md: 0;
  --radius-sm: 0;
  --hero-font: var(--pixel-font);
  --body-font: var(--display-font);
}

body {
  font-family: var(--display-font);
  font-size: 1.18rem;
  background:
    radial-gradient(circle at 15% 10%, rgba(124, 137, 255, 0.12), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(95, 211, 255, 0.10), transparent 45%),
    linear-gradient(180deg, #09111f 0%, #05080f 100%);
}

.page-noise {
  opacity: 1;
  mix-blend-mode: multiply;
  background:
    repeating-linear-gradient(0deg,
      rgba(0,0,0,0) 0px,
      rgba(0,0,0,0) 2px,
      rgba(0,0,0,0.18) 3px,
      rgba(0,0,0,0) 4px),
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: auto, 32px 32px, 32px 32px;
}

.masthead,
.panel,
.panel--hero,
.detail-box,
.toast,
.admin-sidebar,
.admin-stage,
.metric-card,
.stat-tile,
.table-shell,
.feedback-panel,
.queue-strip,
.tp-join-panel,
.tp-waiting-panel,
.tp-finished-panel,
.admin-account,
.chip,
.quest-panel,
.quest-chip,
.heatmap-card {
  border: 3px solid rgba(255,255,255,0.08);
  border-radius: 0;
  background: linear-gradient(90deg, rgba(10,15,30,0.82), rgba(5,8,15,0.52));
  box-shadow: inset 0 0 30px rgba(0,0,0,0.52), 4px 4px 0 rgba(0,0,0,0.72);
}

.masthead {
  border-bottom-color: rgba(124,137,255,0.25);
}

.masthead h1,
.panel__heading h2,
.hero-bar h2,
.admin-topbar h2,
.tp-display__title,
#admin-heading,
.admin-brand__copy strong,
.admin-account strong {
  font-family: var(--pixel-font);
  font-weight: 400;
  letter-spacing: 0.04em;
  text-shadow: 3px 3px 0 #000, 0 0 14px rgba(124,137,255,0.72);
}

.masthead h1 {
  font-size: clamp(1.4rem, 3vw, 2.5rem);
}

.panel__heading h2,
.admin-topbar h2,
.hero-bar h2 {
  font-size: clamp(0.98rem, 1.8vw, 1.5rem);
  line-height: 1.45;
}

.eyebrow,
.field span,
.metric-card__label,
.stat-tile span,
.metric-list__item span,
.queue-strip__heading span,
.admin-account__label,
.data-table th,
.deck-preview-label,
.lb-meta-cell .k {
  color: var(--gold);
  font-family: var(--pixel-font);
  font-size: 8px;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-shadow: 0 0 10px rgba(246,197,77,0.45);
}

.masthead__lede,
.panel__heading p,
.form-note,
.delivery-note,
.detail-box,
.feedback-panel,
.status-note,
.muted,
.admin-brand__copy span,
.admin-account__meta,
.data-table td {
  font-size: 1.1rem;
  line-height: 1.25;
}

.admin-brand__logo,
.student-brand-mark {
  image-rendering: pixelated;
}

.status-pill,
.button,
.pad-key,
input,
select,
textarea,
.solver-shell input,
.custom-dropdown__button,
.custom-dropdown__list,
.admin-nav__button,
.admin-nav__icon,
.digit-chip,
.queue-card,
.stat-tile,
.metric-card {
  border-radius: 0;
}

.status-pill {
  border: 2px solid rgba(124,137,255,0.28);
  background: rgba(5,8,15,0.78);
  color: #ffffff;
  font-family: var(--pixel-font);
  font-size: 9px;
  letter-spacing: 0.04em;
}

.admin-nav__button {
  min-height: 50px;
  border: 2px solid transparent;
  font-family: var(--pixel-font);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.admin-nav__button:hover,
.admin-nav__button:focus-visible {
  background: rgba(124,137,255,0.16);
  border-color: rgba(124,137,255,0.35);
  box-shadow: 3px 3px 0 #000;
}

.admin-nav__button.is-active {
  border-color: var(--arcade-blue);
  background: rgba(75,125,255,0.18);
  box-shadow: 3px 3px 0 #000, 0 0 24px rgba(75,125,255,0.24);
}

.admin-nav__icon {
  border: 2px solid #000;
  background: var(--gold);
  color: #05080f;
  box-shadow: 2px 2px 0 #000;
}

input,
select,
textarea,
.solver-shell input,
.custom-dropdown__button {
  border: 2px solid rgba(124,137,255,0.28);
  font-family: var(--display-font);
  font-size: 1.2rem;
}

.button,
.pad-key {
  border: 3px solid #000;
  font-family: var(--pixel-font);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.04em;
  box-shadow: 4px 4px 0 #000;
}

.button:hover,
.pad-key:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 #000, 0 0 22px rgba(124,137,255,0.24);
}

.button--primary {
  background: var(--arcade-blue);
}

.button--accent {
  background: var(--arcade-green);
  color: #04120e;
}

.button--ghost {
  background: rgba(124,137,255,0.12);
}

.metric-card strong,
.stat-tile strong,
.metric-list__item strong,
.tp-header__timer,
.tp-display__timer {
  font-family: var(--pixel-font);
  font-size: clamp(0.95rem, 2vw, 1.6rem);
  font-weight: 400;
  color: #ffffff;
  text-shadow: 3px 3px 0 #000;
}

.data-table {
  font-family: var(--display-font);
  font-size: 1.18rem;
}

.data-table th {
  border-bottom: 2px solid rgba(124,137,255,0.25);
  background: rgba(5,8,15,0.88);
}

.data-table td {
  border-bottom-color: rgba(255,255,255,0.14);
}

.table-action-stack .button,
.data-table .button {
  min-height: 36px;
  font-size: 8px;
}

.math-card {
  border: 4px solid #000;
  border-radius: 0;
  box-shadow: 7px 7px 0 #000, 0 24px 60px rgba(0,0,0,0.5);
}

.math-card__panel,
.math-card__tab span,
.math-card__id,
.math-card__badge {
  border-radius: 0;
}

.math-card__tab span {
  border: 3px solid #000;
  box-shadow: 3px 3px 0 #000;
}

.digit-chip,
.queue-card {
  border: 2px solid rgba(255,255,255,0.12);
  box-shadow: 3px 3px 0 #000;
}

.digit-chip {
  font-family: var(--pixel-font);
  font-size: 0.95rem;
}

.feedback-panel[data-tone="success"],
.quest-meter span {
  box-shadow: 0 0 20px rgba(53,211,153,0.3);
}

.feedback-panel[data-tone="error"] {
  box-shadow: 0 0 20px rgba(255,91,110,0.28);
}

.toast {
  font-family: var(--pixel-font);
  font-size: 9px;
  letter-spacing: 0.04em;
}

@media (max-width: 700px) {
  .masthead h1 {
    font-size: 1.45rem;
  }

  .admin-nav__button {
    font-size: 8px;
  }

  .button,
  .pad-key {
    font-size: 8px;
  }
}
