/* ---------------------------------------------------------------------------------------------------------
   English Mystery Games - dark UI theme (dark navy background, violet accent, rounded cards, colored
   category badges).
--------------------------------------------------------------------------------------------------------- */
:root {
  --bg: #0b0d14;
  --surface: #141a29;
  --surface-2: #1b2233;
  --surface-3: #232c42;
  --border: rgba(255, 255, 255, .08);
  --text: #f4f5fb;
  --text-muted: #97a1b9;
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-soft: rgba(124, 58, 237, .18);
  --danger: #ef4444;
  --ok: #22c55e;
  --open: #b9a6ff;
  --locked: #f59e0b;

  --evidence: #a855f7;
  --hint: #eab308;
  --object: #06b6d4;
  --character: #22c55e;
  --discussion: #f97316;
  --event: #ef4444;

  --radius: 14px;
  --radius-sm: 8px;
  font-size: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--open); }

.page, main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

/* Fit-to-viewport pages: the tablet /play view and the teacher's live room panel are meant to be used on a
   single landscape screen (tablet or laptop) with no page scrolling. Everything else keeps normal scrolling. */
body.tablet, body.room-panel-page {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.room-panel-page .topbar { flex: 0 0 auto; padding: .6rem 1.25rem; }
body.room-panel-page main.room-panel {
  flex: 1 1 auto;
  min-height: 0;
  max-width: 1600px;
  width: 100%;
  padding: .75rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.room-panel-page h1 { font-size: 1.2rem; margin: 0 0 .35rem; flex: 0 0 auto; }
body.room-panel-page nav { flex: 0 0 auto; font-size: .85rem; }
body.room-panel-page > main.room-panel > p { flex: 0 0 auto; margin: 0 0 .5rem; font-size: .9rem; }
body.room-panel-page .flash { flex: 0 0 auto; }

.controls {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: min-content;
  gap: .6rem;
  overflow-y: auto;
}
.panel-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem .9rem;
}
.panel-section h2 { margin: 0 0 .5rem; font-size: .95rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); }
.panel-section form { margin: .35rem 0; }
.panel-section label { margin: .3rem 0 .15rem; font-size: .8rem; }
.panel-section ul { margin: 0; padding-left: 1.1rem; }
.panel-section .card-grid { margin: .25rem 0; gap: .5rem; }
.panel-section button { padding: .5rem .9rem; font-size: .9rem; min-height: 40px; }

@media (max-width: 1100px) {
  .controls { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  body.room-panel-page, body.tablet { height: auto; overflow: visible; }
  .controls { grid-template-columns: 1fr; overflow-y: visible; }
}

/* Shared top bar (skipped on the tablet/screen views, which have their own header) */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .02);
}
.topbar-logo { font-weight: 800; letter-spacing: .02em; font-size: 1.1rem; }
.topbar-logo strong, .topbar-logo em { color: var(--open); font-style: normal; }
.topbar-nav a, .topbar-nav button.linklike {
  color: var(--text-muted);
  text-decoration: none;
  margin-left: 1.1rem;
  font-size: .95rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  min-height: auto;
}
.topbar-nav a:hover, .topbar-nav button.linklike:hover { color: var(--text); }

nav a, .teacher-link { color: var(--open); text-decoration: none; margin-right: .5rem; }

h1 { font-size: 1.6rem; margin: .25rem 0 1rem; }
h1, h2, h3 { color: var(--text); }
h2 { font-size: 1.15rem; margin-top: 2rem; }
p.muted, .muted { color: var(--text-muted); }

/* Cards -------------------------------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1rem;
}
.card.selected, .card.is-selected { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.card-grid .card { margin-bottom: 0; }

.centered-card {
  max-width: 420px;
  margin: 3.5rem auto 0;
  text-align: center;
}

/* Status pills / badges ------------------------------------------------------------------------------------ */
.status { font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.status-open { color: var(--open); }
.status-locked { color: var(--locked); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .25rem .65rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #0b0d14;
}
.badge-evidence { background: var(--evidence); color: #fff; }
.badge-hint { background: var(--hint); }
.badge-object { background: var(--object); }
.badge-character { background: var(--character); }
.badge-discussion { background: var(--discussion); color: #fff; }
.badge-event { background: var(--event); color: #fff; }

/* Forms -------------------------------------------------------------------------------------------------- */
form { margin: .75rem 0; }
label { display: block; margin: .5rem 0 .35rem; font-weight: 600; font-size: .92rem; color: var(--text-muted); }
input[type=text], input[type=password], input[type=number], input[type=file], select, textarea {
  width: 100%;
  padding: .7rem .8rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

button {
  min-height: 48px;
  min-width: 48px;
  padding: .7rem 1.3rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  margin: .25rem .35rem .25rem 0;
  transition: background-color .15s ease, opacity .15s ease;
}
button:hover { background: var(--primary-hover); }
button.secondary { background: var(--surface-3); color: var(--text); }
button.secondary:hover { background: var(--surface-2); }
button.danger { background: var(--danger); }

.error { color: #fca5a5; font-weight: 600; }
.flash { background: var(--primary-soft); border: 1px solid var(--primary); padding: .6rem .9rem; border-radius: var(--radius-sm); }
.active-auth { background: var(--primary-soft); border: 1px solid var(--primary); padding: .6rem .9rem; border-radius: var(--radius-sm); }

table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }

pre.json-preview {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  overflow: auto;
  max-height: 60vh;
  color: var(--text-muted);
}

/* PIN / login / install screens --------------------------------------------------------------------------- */
.pin-screen, .login-screen, .install-screen { text-align: center; }
.pin-form input {
  text-align: center;
  font-size: 2rem;
  letter-spacing: .5rem;
  background: var(--surface-2);
}
.pin-form button, .login-form button { width: 100%; }

/* Tablet UI (shared screen for the class) ------------------------------------------------------------------ */
body.tablet { background: var(--bg); color: var(--text); }
.tablet-page { max-width: none; padding: 0; margin: 0; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.tablet-page-content { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 1rem; }
.play-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .9rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 1.05rem;
  font-weight: 600;
  flex: 0 0 auto;
}
.conn-ok { color: var(--ok); }
.conn-warn { color: var(--locked); }
.play-layout { display: flex; gap: 1rem; align-items: stretch; padding: 1rem; flex: 1 1 auto; min-height: 0; }
#turn-view {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: .75rem;
}
#turn-view > div, #turn-view > .card { margin-bottom: 0; }
#camera { width: 100%; max-width: 480px; border-radius: var(--radius); }
#discovery-box, #discussion-box, #scan-box, #waiting-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
#hint-box button { width: 100%; }
#hint-box button:disabled { background: var(--surface-3); color: var(--text-muted); cursor: not-allowed; }

#recent-sidebar {
  flex: 0 0 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-y: auto;
}
#recent-sidebar h3 { margin-top: 0; }
#recent-list { list-style: none; padding: 0; margin: 0; }
#recent-list li {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem .85rem;
  margin-bottom: .6rem;
  font-size: .9rem;
}
#recent-list li div { color: var(--text-muted); margin-top: .3rem; }

@media (max-width: 760px) {
  .play-layout { flex-direction: column; }
  #recent-sidebar { flex-basis: auto; width: 100%; }
}

.bottom-tabs {
  flex: 0 0 auto;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.bottom-tabs button, .bottom-tabs a {
  flex: 1;
  text-align: center;
  padding: 1rem;
  color: var(--text-muted);
  text-decoration: none;
  background: none;
  border: none;
  font-size: 1.05rem;
  min-height: 48px;
  border-radius: 0;
  margin: 0;
}
.bottom-tabs .active { color: var(--open); border-top: 2px solid var(--primary); }

.notebook-filters { display: flex; gap: .75rem; margin-bottom: 1rem; flex: 0 0 auto; }
#notebook-list, #notes-list, #timeline-list { list-style: none; padding: 0; }
#notebook-list li, #notes-list li, #timeline-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  margin-bottom: .6rem;
}

/* Screen / projector view --------------------------------------------------------------------------------- */
body.screen { background: #05060a; color: var(--text); }
.screen-view { text-align: center; padding-top: 3rem; }
#screen-title { font-size: 2.5rem; color: var(--open); }
#screen-timer { font-size: 3rem; margin-top: 2rem; font-weight: 700; }
#screen-ending { max-width: 700px; margin: 2rem auto 0; background: var(--surface); border: 1px solid var(--primary); border-radius: var(--radius); padding: 1.5rem; }

