/* Troll High — page chrome. World rendering happens on the canvas;
   this file only styles the shell (title, HUD, touch, loading). */

:root {
  --th-bg: #14110c;
  --th-paper: #f5f0e4;
  --th-ink: #2b2417;
  --th-gold: #f5b52e;
  --th-navy: #27408b;
}

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

/* display:flex on containers would otherwise beat the hidden attribute's
   UA display:none — hidden overlays then swallow clicks (see verify skill) */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--th-bg);
  font-family: "DM Sans", system-ui, sans-serif;
  overscroll-behavior: none;
  touch-action: none;
}

#th-root { position: fixed; inset: 0; overflow: hidden; }

#th-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: var(--th-bg);
}

/* ------------------------------------------------------------ title */
#th-title {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(245, 181, 46, 0.14), transparent 60%),
    var(--th-bg);
  z-index: 30;
}

.th-title-card {
  text-align: center;
  color: var(--th-paper);
  padding: 28px 34px;
  width: min(400px, 92vw);
  border: 2px solid rgba(245, 181, 46, 0.35);
  border-radius: 14px;
  background: rgba(20, 17, 12, 0.82);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  max-height: 90vh;
  overflow-y: auto;
}

.th-title-emoji { font-size: 44px; margin-bottom: 6px; }

.th-title-card h1 {
  font-weight: 900;
  font-size: clamp(34px, 7vw, 56px);
  letter-spacing: 0.04em;
  color: var(--th-gold);
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.5);
}

.th-tagline {
  font-family: "DM Mono", monospace;
  font-size: 13px;
  opacity: 0.75;
  margin: 6px 0 20px;
}

/* ------------------------------------------------------------- gate */
.th-gate-loading {
  font-family: "DM Mono", monospace;
  font-size: 13px;
  opacity: 0.6;
  padding: 10px 0;
}

.th-gate-note {
  font-size: 12px;
  line-height: 1.5;
  opacity: 0.65;
  margin-bottom: 16px;
  text-align: left;
}

.th-tab-row { display: flex; gap: 6px; margin-bottom: 16px; }
.th-tab-row button {
  flex: 1;
  font: 700 12px "DM Sans", sans-serif;
  color: var(--th-paper);
  background: rgba(245, 240, 228, 0.06);
  border: 1.5px solid rgba(245, 240, 228, 0.18);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  opacity: 0.6;
}
.th-tab-row button.is-active {
  opacity: 1;
  border-color: var(--th-gold);
  background: rgba(245, 181, 46, 0.1);
}

.th-field { margin-bottom: 12px; text-align: left; }
.th-field label {
  display: block;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  opacity: 0.6;
  margin-bottom: 5px;
}
.th-field input {
  display: block;
  width: 100%;
  font: 600 14px "DM Sans", sans-serif;
  color: var(--th-paper);
  background: rgba(245, 240, 228, 0.08);
  border: 1.5px solid rgba(245, 240, 228, 0.25);
  border-radius: 8px;
  padding: 9px 12px;
}
.th-field input:focus-visible { outline: 2px solid var(--th-gold); outline-offset: 1px; }

#th-gate-submit {
  width: 100%;
  font: 700 15px "DM Sans", sans-serif;
  color: var(--th-ink);
  background: linear-gradient(180deg, #ffd977, var(--th-gold));
  border: 0;
  border-radius: 999px;
  padding: 11px;
  cursor: pointer;
  margin-top: 4px;
  box-shadow: 0 3px 0 #a97a12;
}
#th-gate-submit:disabled { opacity: 0.5; cursor: not-allowed; }

.th-gate-status {
  font-size: 12px;
  margin-top: 10px;
  min-height: 16px;
}
.th-gate-status.is-bad { color: #ff6b6b; }

.th-welcome-msg { font-size: 14px; margin-bottom: 16px; }
.th-welcome-msg b { color: var(--th-gold); }

#th-start {
  font: 700 17px "DM Sans", sans-serif;
  color: var(--th-ink);
  background: linear-gradient(180deg, #ffd977, var(--th-gold));
  border: 0;
  border-radius: 999px;
  padding: 13px 30px;
  cursor: pointer;
  box-shadow: 0 4px 0 #a97a12, 0 10px 24px rgba(0, 0, 0, 0.4);
  transition: transform 0.08s ease;
}
#th-start:hover { transform: translateY(-1px); }
#th-start:active { transform: translateY(2px); box-shadow: 0 2px 0 #a97a12; }
#th-start:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.th-build {
  margin-top: 16px;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  opacity: 0.45;
}

/* -------------------------------------------------------------- hud */
#th-hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  z-index: 20;
  pointer-events: none;
}

#th-hud span {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  color: var(--th-paper);
  background: rgba(20, 17, 12, 0.72);
  border: 1px solid rgba(245, 240, 228, 0.18);
  border-radius: 8px;
  padding: 5px 10px;
}

#th-btn-leaderboard {
  pointer-events: auto;
  cursor: pointer;
  font-size: 13px;
  color: var(--th-paper);
  background: rgba(20, 17, 12, 0.72);
  border: 1px solid rgba(245, 240, 228, 0.18);
  border-radius: 8px;
  padding: 5px 10px;
}
#th-btn-leaderboard:hover { background: rgba(245, 181, 46, 0.18); }

#th-btn-map {
  pointer-events: auto;
  cursor: pointer;
  font-size: 13px;
  color: var(--th-paper);
  background: rgba(20, 17, 12, 0.72);
  border: 1px solid rgba(245, 240, 228, 0.18);
  border-radius: 8px;
  padding: 5px 10px;
}
#th-btn-map:hover { background: rgba(77, 201, 255, 0.18); }

#th-btn-schedule {
  pointer-events: auto;
  cursor: pointer;
  font-size: 13px;
  color: var(--th-paper);
  background: rgba(20, 17, 12, 0.72);
  border: 1px solid rgba(245, 240, 228, 0.18);
  border-radius: 8px;
  padding: 5px 10px;
}
#th-btn-schedule:hover { background: rgba(46, 93, 67, 0.28); }

#th-btn-bedroom {
  pointer-events: auto;
  cursor: pointer;
  font-size: 13px;
  color: var(--th-paper);
  background: rgba(20, 17, 12, 0.72);
  border: 1px solid rgba(245, 240, 228, 0.18);
  border-radius: 8px;
  padding: 5px 10px;
}
#th-btn-bedroom:hover { background: rgba(138, 90, 43, 0.28); }

#th-btn-yearbook {
  pointer-events: auto;
  cursor: pointer;
  font-size: 13px;
  color: var(--th-paper);
  background: rgba(20, 17, 12, 0.72);
  border: 1px solid rgba(245, 240, 228, 0.18);
  border-radius: 8px;
  padding: 5px 10px;
}
#th-btn-yearbook:hover { background: rgba(77, 201, 255, 0.22); }

/* ----------------------------------------------------------- yearbook */
#th-yearbook-overlay {
  position: absolute;
  inset: 0;
  z-index: 28;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 5, 0.72);
}
.th-yearbook-panel {
  position: relative;
  width: min(520px, 94vw);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--th-paper);
  color: var(--th-ink);
  border-radius: 14px;
  padding: 20px 20px 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}
.th-yearbook-panel h2 { font-size: 18px; font-weight: 900; margin-bottom: 12px; }
#th-yearbook-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  background: rgba(43, 36, 23, 0.1);
  color: var(--th-ink);
  font-size: 14px;
  cursor: pointer;
}
#th-yearbook-capture {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 0;
  background: #2b2417;
  color: var(--th-paper);
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 10px;
}
#th-yearbook-capture:disabled { opacity: 0.5; cursor: not-allowed; }
.th-yearbook-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
}
.th-yearbook-photo { border-radius: 8px; overflow: hidden; background: #000; position: relative; }
.th-yearbook-photo img { width: 100%; display: block; aspect-ratio: 16/10; object-fit: cover; }
.th-yearbook-photo .cap {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 9px;
  padding: 2px 4px;
}
.th-yearbook-loading { opacity: 0.6; font-size: 12px; margin-top: 10px; }

/* ------------------------------------------------------------ bedroom */
#th-bedroom-overlay {
  position: absolute;
  inset: 0;
  z-index: 28;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 5, 0.72);
}
.th-bedroom-panel {
  position: relative;
  width: min(480px, 94vw);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--th-paper);
  color: var(--th-ink);
  border-radius: 14px;
  padding: 20px 20px 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}
.th-bedroom-panel h2 { font-size: 18px; font-weight: 900; margin-bottom: 12px; }
.th-bedroom-panel h3 { font-size: 13px; font-weight: 900; margin: 14px 0 8px; }
#th-bedroom-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  background: rgba(43, 36, 23, 0.1);
  color: var(--th-ink);
  font-size: 14px;
  cursor: pointer;
}
.th-bedroom-slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.th-bedroom-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border-radius: 10px;
  border: 1px dashed rgba(43, 36, 23, 0.25);
  background: rgba(43, 36, 23, 0.04);
  cursor: pointer;
  font-size: 10px;
  text-align: center;
}
.th-bedroom-slot .icon { font-size: 24px; }
.th-bedroom-slot .label { opacity: 0.55; text-transform: uppercase; letter-spacing: 0.04em; font-size: 9px; }
.th-bedroom-slot.is-filled { border-style: solid; border-color: #f5b52e; background: rgba(245, 181, 46, 0.12); }
.th-bedroom-locked {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.th-bedroom-locked .item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: 10px;
  background: rgba(43, 36, 23, 0.04);
  opacity: 0.55;
  font-size: 10px;
  text-align: center;
}
.th-bedroom-locked .item .icon { font-size: 18px; filter: grayscale(1); }

/* --------------------------------------------------------- orientation */
#th-orientation-overlay {
  position: absolute;
  inset: 0;
  z-index: 31;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 5, 0.82);
}
.th-orientation-panel {
  width: min(420px, 94vw);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--th-paper);
  color: var(--th-ink);
  border-radius: 14px;
  padding: 22px 22px 18px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}
.th-orientation-panel h2 { font-size: 18px; font-weight: 900; margin: 0 0 14px; }
.th-orientation-controls { list-style: none; margin: 0 0 16px; padding: 0; font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.th-orientation-electives { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 8px 0 16px; }
.th-orientation-elective {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(43, 36, 23, 0.15);
  background: rgba(43, 36, 23, 0.04);
  cursor: pointer;
  font-size: 13px;
  text-align: center;
}
.th-orientation-elective.is-selected { border-color: #f5b52e; background: rgba(245, 181, 46, 0.16); font-weight: 700; }
#th-orientation-start {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 0;
  background: #2b2417;
  color: var(--th-paper);
  font-weight: 700;
  cursor: pointer;
}

/* -------------------------------------------------------- schedule/tasks */
#th-schedule-overlay {
  position: absolute;
  inset: 0;
  z-index: 28;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 5, 0.72);
}
.th-schedule-panel {
  position: relative;
  width: min(420px, 94vw);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--th-paper);
  color: var(--th-ink);
  border-radius: 14px;
  padding: 20px 20px 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}
.th-schedule-panel h2 { font-size: 15px; font-weight: 900; margin: 14px 0 8px; }
.th-schedule-panel h2:first-of-type { margin-top: 0; }
.th-schedule-flavor {
  margin: 0 0 6px;
  font-size: 12px;
  opacity: 0.75;
  background: rgba(43, 36, 23, 0.05);
  border-radius: 8px;
  padding: 6px 10px;
}
.th-schedule-special-event {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: #8a6a10;
  background: rgba(245, 181, 46, 0.18);
  border: 1px solid rgba(245, 181, 46, 0.4);
  border-radius: 8px;
  padding: 8px 10px;
}
#th-schedule-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  background: rgba(43, 36, 23, 0.1);
  color: var(--th-ink);
  font-size: 14px;
  cursor: pointer;
}
#th-schedule-table { width: 100%; border-collapse: collapse; font-size: 12px; }
#th-schedule-table td { padding: 5px 6px; border-bottom: 1px solid rgba(43, 36, 23, 0.08); }
#th-schedule-table tr.is-current td { background: rgba(245, 181, 46, 0.18); font-weight: 700; }
.th-schedule-tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.th-schedule-tasks li {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(43, 36, 23, 0.06);
}
.th-schedule-tasks li.is-done { text-decoration: line-through; opacity: 0.6; }

/* ------------------------------------------------------- leaderboard */
#th-leaderboard-overlay {
  position: absolute;
  inset: 0;
  z-index: 28;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 5, 0.72);
}
.th-leaderboard-panel {
  position: relative;
  width: min(560px, 92vw);
  max-height: 82vh;
  overflow-y: auto;
  background: var(--th-paper);
  color: var(--th-ink);
  border-radius: 14px;
  padding: 20px 20px 14px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}
.th-leaderboard-panel h2 { font-size: 18px; font-weight: 900; margin-bottom: 12px; }
#th-leaderboard-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  background: rgba(43, 36, 23, 0.1);
  color: var(--th-ink);
  font-size: 14px;
  cursor: pointer;
}

/* ------------------------------------------------------------- map */
#th-map-overlay {
  position: absolute;
  inset: 0;
  z-index: 28;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 5, 0.72);
}
.th-map-panel {
  position: relative;
  width: min(760px, 94vw);
  max-height: 92vh;
  overflow-y: auto;
  background: linear-gradient(160deg, #f2ead9, #e4d8bc);
  color: var(--th-ink);
  border-radius: 6px;
  padding: 20px 20px 14px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(58, 47, 29, 0.35);
}
.th-map-panel h2 {
  font-family: "DM Mono", monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
#th-map-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(58, 47, 29, 0.4);
  background: rgba(58, 47, 29, 0.08);
  color: var(--th-ink);
  font-size: 13px;
  cursor: pointer;
}
#th-map-canvas { width: 100%; height: auto; display: block; border-radius: 3px; cursor: default; }

/* ---------------------------------------------------- arcade launcher */
#th-arcade-overlay {
  position: absolute;
  inset: 0;
  z-index: 29;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 5, 3, 0.85);
  padding: 16px;
}
.th-crt-frame {
  width: min(900px, 96vw);
  max-height: 92vh;
  background: linear-gradient(160deg, #3a3f4a, #1c1f26);
  border-radius: 22px;
  padding: 16px 16px 26px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65), inset 0 0 0 2px rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
}
.th-crt-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 6px 12px;
  color: #cfd6e0;
  font-family: "DM Mono", monospace;
  font-size: 12px;
}
.th-crt-titlebar button {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 0;
  background: #4a3030;
  color: #f0d0d0;
  cursor: pointer;
}
.th-crt-screen {
  background: #000;
  border-radius: 8px;
  padding: 10px;
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.8);
  aspect-ratio: 16 / 10;
  max-height: calc(92vh - 70px);
}
#th-arcade-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 3px;
  background: #000;
}

/* ----------------------------------------------------- trading/gifting */
#th-trade-overlay {
  position: absolute;
  inset: 0;
  z-index: 29;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 5, 0.72);
}
.th-trade-panel {
  position: relative;
  width: min(460px, 94vw);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--th-paper);
  color: var(--th-ink);
  border-radius: 14px;
  padding: 20px 20px 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}
.th-trade-panel h2 { font-size: 18px; font-weight: 900; margin-bottom: 12px; }
#th-trade-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  background: rgba(43, 36, 23, 0.1);
  color: var(--th-ink);
  font-size: 14px;
  cursor: pointer;
}
.th-trade-mode-row { display: flex; gap: 8px; margin-bottom: 12px; }
.th-trade-mode {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(43, 36, 23, 0.15);
  background: rgba(43, 36, 23, 0.04);
  cursor: pointer;
  font-size: 13px;
}
.th-trade-mode.is-active { border-color: #f5b52e; background: rgba(245, 181, 46, 0.16); font-weight: 700; }
.th-trade-step p { margin: 0 0 8px; font-size: 13px; }
.th-trade-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
  max-height: 240px;
  overflow-y: auto;
}
.th-trade-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: 10px;
  border: 1px solid rgba(43, 36, 23, 0.15);
  background: rgba(43, 36, 23, 0.04);
  cursor: pointer;
  font-size: 10px;
  text-align: center;
}
.th-trade-card .icon { font-size: 20px; }
.th-trade-card .count { opacity: 0.6; }
.th-trade-card.is-selected { border-color: #f5b52e; background: rgba(245, 181, 46, 0.16); font-weight: 700; }
.th-trade-cards-readonly .th-trade-card { cursor: default; }
#th-trade-send, #th-trade-accept {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 0;
  background: #2b2417;
  color: var(--th-paper);
  font-weight: 700;
  cursor: pointer;
}
#th-trade-send:disabled { opacity: 0.4; cursor: not-allowed; }
.th-trade-btn-row { display: flex; gap: 8px; }
.th-trade-btn-row button { flex: 1; }
#th-trade-decline, #th-trade-cancel {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(43, 36, 23, 0.2);
  background: transparent;
  color: var(--th-ink);
  cursor: pointer;
}

#th-gift-toast {
  position: absolute;
  left: 50%;
  top: 60px;
  transform: translateX(-50%);
  z-index: 40;
  background: rgba(20, 17, 12, 0.88);
  color: var(--th-paper);
  border: 1px solid rgba(245, 181, 46, 0.4);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
}

/* -------------------------------------------------------- cafeteria */
#th-cafeteria-overlay {
  position: absolute;
  inset: 0;
  z-index: 29;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 5, 0.72);
}
.th-cafeteria-panel {
  position: relative;
  width: min(460px, 94vw);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--th-paper);
  color: var(--th-ink);
  border-radius: 14px;
  padding: 20px 20px 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}
.th-cafeteria-panel h2 { font-size: 18px; font-weight: 900; margin-bottom: 12px; }
#th-cafeteria-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  background: rgba(43, 36, 23, 0.1);
  color: var(--th-ink);
  font-size: 14px;
  cursor: pointer;
}
.th-cafeteria-menu {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.th-cafeteria-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(43, 36, 23, 0.15);
  background: rgba(43, 36, 23, 0.04);
  cursor: pointer;
  font-size: 13px;
  text-align: left;
}
.th-cafeteria-item .icon { font-size: 18px; }
.th-cafeteria-item.is-selected {
  border-color: #f5b52e;
  background: rgba(245, 181, 46, 0.16);
  font-weight: 700;
}
.th-cafeteria-step p { margin: 0 0 8px; font-size: 13px; }
#th-cafeteria-checkout {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 0;
  background: #2b2417;
  color: var(--th-paper);
  font-weight: 700;
  cursor: pointer;
}
#th-cafeteria-checkout:disabled { opacity: 0.4; cursor: not-allowed; }
#th-cafeteria-id-form { display: flex; gap: 8px; }
#th-cafeteria-id-input {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(43, 36, 23, 0.25);
  font-family: "DM Mono", monospace;
  text-transform: uppercase;
}
#th-cafeteria-id-form button {
  padding: 8px 14px;
  border-radius: 8px;
  border: 0;
  background: #2b2417;
  color: var(--th-paper);
  font-weight: 700;
  cursor: pointer;
}
#th-cafeteria-id-status { font-size: 12px; min-height: 16px; }
#th-cafeteria-id-status.is-error { color: #a13a3a; }
#th-cafeteria-id-status.is-ok { color: #2e5d43; }
#th-cafeteria-done-msg { font-size: 14px; font-weight: 700; }

/* -------------------------------------------------- recess minigames */
#th-minigame-overlay {
  position: absolute;
  inset: 0;
  z-index: 29;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 5, 3, 0.85);
  padding: 16px;
}
.th-minigame-frame {
  width: min(420px, 96vw);
  background: linear-gradient(160deg, #3a3f4a, #1c1f26);
  border-radius: 22px;
  padding: 16px 16px 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65), inset 0 0 0 2px rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.th-minigame-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 6px;
  color: #cfd6e0;
  font-family: "DM Mono", monospace;
  font-size: 12px;
}
#th-minigame-score { flex: 1; text-align: right; color: #9be89b; }
.th-minigame-titlebar button {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 0;
  background: #4a3030;
  color: #f0d0d0;
  cursor: pointer;
}
#th-minigame-canvas {
  width: 100%;
  aspect-ratio: 320 / 220;
  background: #0c3b16;
  border-radius: 8px;
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.6);
}
#th-minigame-help {
  margin: 0;
  padding: 0 4px;
  text-align: center;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: #a8b0bc;
}

/* interaction hint */
#th-hint {
  position: absolute;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%);
  z-index: 20;
  pointer-events: none;
  font: 700 14px "DM Sans", sans-serif;
  color: var(--th-ink);
  background: var(--th-paper);
  border-radius: 999px;
  padding: 8px 16px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}
#th-hint kbd {
  font-family: "DM Mono", monospace;
  background: var(--th-navy);
  color: #fff;
  border-radius: 5px;
  padding: 1px 7px;
  margin-right: 6px;
}

#th-roster { cursor: default; }

/* ------------------------------------------------------------- chat */
#th-chat-log {
  position: absolute;
  left: 12px;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  flex-direction: column-reverse;
  gap: 3px;
  max-width: min(320px, 70vw);
  pointer-events: none;
}
#th-chat-log .th-log-line {
  font: 700 12px "DM Sans", sans-serif;
  color: var(--th-paper);
  background: rgba(20, 17, 12, 0.6);
  border-radius: 6px;
  padding: 3px 8px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
#th-chat-log .th-log-line b { color: var(--th-gold); }

#th-chat-bar {
  position: absolute;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 26;
  width: min(420px, 88vw);
}
#th-chat-input {
  width: 100%;
  font: 600 14px "DM Sans", sans-serif;
  color: var(--th-ink);
  background: var(--th-paper);
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}
#th-chat-input:focus-visible { outline: 2px solid var(--th-gold); }

/* ----------------------------------------------------------- emotes */
#th-btn-profile {
  position: absolute;
  right: 12px;
  top: max(12px, env(safe-area-inset-top));
  z-index: 21;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(245, 240, 228, 0.2);
  background: rgba(20, 17, 12, 0.55);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
#th-btn-profile:hover { background: rgba(20, 17, 12, 0.8); }

/* -------------------------------------------------------- profile card */
#th-profile-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 5, 0.72);
}
.th-profile-panel {
  position: relative;
  width: min(400px, 92vw);
  max-height: 82vh;
  overflow-y: auto;
  background: var(--th-paper);
  color: var(--th-ink);
  border-radius: 14px;
  padding: 20px 20px 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}
#th-profile-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  background: rgba(43, 36, 23, 0.1);
  color: var(--th-ink);
  font-size: 14px;
  cursor: pointer;
}
.th-profile-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.th-profile-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(43, 36, 23, 0.08);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; flex-shrink: 0;
}
.th-profile-head h2 { font-size: 17px; font-weight: 900; margin: 0; }
.th-profile-id { margin: 2px 0 0; font-family: "DM Mono", monospace; font-size: 12px; opacity: 0.7; letter-spacing: 0.03em; }
.th-profile-sub { margin: 4px 0 14px; font-size: 12px; opacity: 0.65; }
.th-profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 8px; margin-bottom: 16px; }
.th-profile-stat { text-align: center; }
.th-profile-stat span { display: block; font-size: 18px; font-weight: 900; }
.th-profile-stat label { font-size: 10px; opacity: 0.65; }
.th-profile-panel h3 { font-size: 13px; font-weight: 900; margin: 0 0 8px; }
.th-profile-scores { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.th-profile-scores li {
  display: flex; justify-content: space-between;
  font-size: 12px; padding: 6px 10px;
  background: rgba(43, 36, 23, 0.06);
  border-radius: 8px;
}
.th-profile-scores li b { font-family: "DM Mono", monospace; }
.th-profile-scores .th-profile-empty { opacity: 0.55; justify-content: center; }

#th-emotes {
  position: absolute;
  right: 12px;
  top: max(52px, calc(env(safe-area-inset-top) + 42px));
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#th-emotes button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(245, 240, 228, 0.2);
  background: rgba(20, 17, 12, 0.55);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
#th-emotes button:hover { background: rgba(20, 17, 12, 0.8); }
#th-emotes button:active { transform: scale(0.92); }

#th-btn-chat {
  position: absolute;
  right: 26px;
  bottom: max(120px, calc(env(safe-area-inset-bottom) + 116px));
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1.5px solid rgba(245, 240, 228, 0.35);
  background: rgba(39, 64, 139, 0.85);
  color: #fff;
  font-size: 18px;
  pointer-events: auto;
}

/* popup card (Polaroid-ish) — memory cards AND NPC dialogue share this.
   Reliable DOM text beats trying to fit readable dialogue into a tiny
   in-world canvas bubble that can end up clipped by the camera or
   scaled illegibly depending on zoom and where the NPC stands. */
.th-popup-card {
  position: absolute;
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  z-index: 25;
  width: min(340px, 86vw);
  background: var(--th-paper);
  color: var(--th-ink);
  border-radius: 10px;
  padding: 14px 16px 12px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(43, 36, 23, 0.15);
}
.th-popup-card h3 { font-size: 15px; font-weight: 900; margin-bottom: 4px; }
.th-npc-tag {
  display: inline-block;
  vertical-align: middle;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #8a6a10;
  background: rgba(245, 181, 46, 0.22);
  border-radius: 5px;
  padding: 1px 5px;
  margin-left: 4px;
}
.th-popup-card p { font-size: 13px; line-height: 1.45; }
.th-mem-screen {
  display: block;
  width: 100%;
  height: 90px;
  margin-top: 8px;
  border-radius: 6px;
  image-rendering: pixelated;
  border: 2px solid #1b1b1f;
}
.th-popup-card .th-mem-close {
  margin-top: 8px;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  opacity: 0.55;
}

/* Real multi-club system (§23 Phase 6) — the club-charter founding/joining
   form, embedded inline in the memory-card popup. */
.th-club-form { margin-top: 8px; }
.th-club-form p { margin: 6px 0 4px; }
.th-club-join-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.th-club-join-btn, #th-club-found-btn {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid rgba(43, 36, 23, 0.25);
  background: var(--th-paper);
  font-family: "DM Sans", sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
#th-club-name-input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(43, 36, 23, 0.25);
  font-family: "DM Sans", sans-serif;
  margin-bottom: 6px;
  box-sizing: border-box;
}
#th-club-found-btn { width: 100%; }

/* Student elections (§23 Phase 6) — the ballot-box popup form. */
.th-election-list { margin-top: 6px; }
.th-election-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(43, 36, 23, 0.12);
  font-size: 13px;
}
.th-election-row span { flex: 1; }
.th-election-vote-btn {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(43, 36, 23, 0.25);
  background: var(--th-paper);
  font-family: "DM Sans", sans-serif;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.th-election-vote-btn:disabled { opacity: 0.5; cursor: default; }
#th-election-run-btn, #th-sciencefair-present-btn, #th-sciencefair-withdraw-btn, #th-graduate-btn {
  width: 100%;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(43, 36, 23, 0.25);
  background: var(--th-paper);
  font-family: "DM Sans", sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

/* ------------------------------------------------------------ touch */
#th-touch { position: absolute; inset: 0; z-index: 15; pointer-events: none; }

#th-stick {
  position: absolute;
  left: 22px;
  bottom: max(22px, env(safe-area-inset-bottom));
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(245, 240, 228, 0.08);
  border: 1.5px solid rgba(245, 240, 228, 0.25);
  pointer-events: auto;
}
#th-stick-nub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(245, 240, 228, 0.28);
}

#th-btn-act {
  position: absolute;
  right: 26px;
  bottom: max(38px, env(safe-area-inset-bottom));
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 1.5px solid rgba(245, 240, 228, 0.35);
  background: rgba(245, 181, 46, 0.85);
  color: var(--th-ink);
  font: 900 22px "DM Sans", sans-serif;
  pointer-events: auto;
}
#th-btn-act:active { transform: scale(0.94); }

/* ---------------------------------------------------------- loading */
#th-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--th-bg);
  z-index: 40;
  color: var(--th-paper);
  font-family: "DM Mono", monospace;
  font-size: 14px;
}

@media (prefers-reduced-motion: reduce) {
  #th-start { transition: none; }
}
