/* Mystery Ghar
   Two worlds: the setting (Bodoni, an accent colour, a dark room) and the case file (Courier, manila paper).
   Each case sets its own room colours through the custom properties below.
   Paper surfaces are only for things you've found. Red is only for finality. */

:root {
  --green: #14271f;
  --green-deep: #0c1813;
  --green-raised: #1a3128;
  --green-line: #2d4a3d;
  --brass: #c9a24a;
  --brass-dim: #7d6a3f;
  --brass-wash: rgba(201, 162, 74, 0.13);
  --manila: #e4cf9c;
  --manila-light: #efe3c3;
  --manila-edge: #c6ad74;
  --ink: #221c14;
  --ink-soft: #5b4c33;
  --ivory: #efe7d6;
  --sage: #a9b9ac;
  --oxblood: #8e2430;
  --alarm: #e5808a;
  --good: #a6d9ae;
  --serif: 'Bodoni Moda', 'Bodoni 72', Didot, 'Libre Bodoni', Georgia, serif;
  --type: 'Courier Prime', 'Courier New', Courier, monospace;
  --paper-shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 16px 30px -18px rgba(0, 0, 0, 0.75);
  --tabbar: 62px;
  --glow: #23432f;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ivory);
  background: var(--green-deep);
  font-family: var(--type);
  font-size: 16.5px;
  line-height: 1.55;
}
/* lamp-lit room: a warm pool of light from above */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(130% 75% at 50% -12%, var(--glow) 0%, var(--green) 46%, var(--green-deep) 100%);
}
[hidden] { display: none !important; }
a { color: var(--brass); }
p { margin: 0 0 0.85em; }
strong { font-weight: 700; }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }
.muted { color: var(--sage); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- type ---------- */
.title {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(42px, 13vw, 68px);
  line-height: 0.98;
  letter-spacing: -0.015em;
  color: var(--ivory);
}
.subtitle { margin: 10px 0 0; font-family: var(--serif); font-size: 18px; color: var(--sage); }
.h2 {
  margin: 36px 0 12px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 25px;
  line-height: 1.15;
  color: var(--brass);
}
.prose p { max-width: 62ch; }

/* ---------- controls ---------- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  padding: 13px 20px;
  border: 1px solid transparent;
  border-radius: 6px;
  font: 700 16.5px/1.2 var(--type);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-brass { background: var(--brass); color: var(--green-deep); }
.btn-brass:hover:not(:disabled) { filter: brightness(1.07); }
.btn-ghost { background: transparent; color: var(--ivory); border-color: var(--green-line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brass-dim); }
.btn-seal { background: var(--oxblood); color: var(--ivory); }
.btn-seal:hover:not(:disabled) { filter: brightness(1.12); }
.btn-wide { width: 100%; }
.linklike {
  appearance: none; border: 0; padding: 0; background: none; cursor: pointer;
  font: inherit; color: var(--brass); text-decoration: underline; text-underline-offset: 3px;
}

input, textarea, select {
  width: 100%;
  padding: 12px 14px;
  font: 400 17px/1.35 var(--type);
  color: var(--ink);
  background: var(--manila-light);
  border: 1px solid var(--manila-edge);
  border-radius: 6px;
}
input::placeholder, textarea::placeholder { color: #8a7a5b; }
label { display: block; }
.field-label { display: block; margin: 16px 0 6px; font-weight: 700; }
.field-label small { font-weight: 400; color: var(--sage); }
.form-msg { min-height: 1.4em; margin: 12px 0 0; color: var(--alarm); }

/* ======================================================================
   PLAYER APP
   ====================================================================== */
.view { padding: 0 18px; }

/* ---------- join: the gala invitation, stamped cancelled ---------- */
.join { max-width: 460px; margin: 0 auto; padding-bottom: 40px; }
.invitation {
  position: relative;
  margin: max(6vh, 28px) 0 30px;
  padding: 34px 24px 30px;
  text-align: center;
  border: 1px solid var(--brass);
  outline: 1px solid var(--brass-dim);
  outline-offset: 5px;
  background: rgba(12, 24, 19, 0.55);
}
.inv-host { margin: 0 0 4px; font-family: var(--serif); font-size: 17px; color: var(--brass); }
.inv-line { margin: 0 0 22px; font-family: var(--serif); font-style: italic; font-size: 16px; line-height: 1.45; color: var(--sage); }
.inv-sub { margin: 18px 0 0; color: var(--sage); }
.stamp {
  position: absolute;
  right: -10px;
  bottom: -16px;
  padding: 6px 12px;
  border: 3px double #c84b55;
  border-radius: 4px;
  color: #d45b64;
  font: 700 17px/1 var(--type);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transform: rotate(-11deg);
  background: rgba(12, 24, 19, 0.85);
  opacity: 0.95;
  pointer-events: none;
}
.join-form { padding: 0 2px; }
.join-status { margin: 18px 0 0; color: var(--sage); text-align: center; }
.join-note { margin: 22px 0 0; font-size: 14px; color: var(--sage); text-align: center; }
.rejoin { margin: 26px 0 0; padding: 12px 14px; border: 1px solid var(--green-line); border-radius: 6px; }
.rejoin summary { cursor: pointer; color: var(--brass); }
.rejoin[open] summary { margin-bottom: 4px; }
.rejoin .btn { margin-top: 4px; }
.badge-card { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 16px; margin: 18px 0 6px; padding: 14px 16px; border: 1px dashed var(--brass-dim); border-radius: 6px; }
.badge-card p { margin: 0; font-size: 14.5px; color: var(--sage); }
.badge-code, .code-inline { font-weight: 700; letter-spacing: 0.14em; color: var(--brass); }
.badge-code { font-size: 26px; }

/* ---------- lobby ---------- */
.lobby { max-width: 560px; margin: 0 auto; padding-top: max(5vh, 22px); padding-bottom: 48px; }
.lobby-greet { margin: 26px 0 10px; font-family: var(--serif); font-weight: 500; font-size: 27px; line-height: 1.2; }
.waiting { display: flex; align-items: center; gap: 12px; margin: 22px 0 8px; color: var(--brass); }
.pulse { width: 11px; height: 11px; border-radius: 50%; background: var(--brass); animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.35; transform: scale(0.85); } 50% { opacity: 1; transform: scale(1.1); } }

.rules { margin: 0; padding: 0; list-style: none; counter-reset: none; }
.rules li { position: relative; padding: 0 0 12px 22px; }
.rules li::before { content: ''; position: absolute; left: 2px; top: 0.62em; width: 8px; height: 8px; border: 1px solid var(--brass); transform: rotate(45deg); }

/* ---------- game chrome ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding: calc(env(safe-area-inset-top) + 9px) 18px 9px;
  background: rgba(12, 24, 19, 0.94);
  border-bottom: 1px solid var(--brass-dim);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.brand { font-family: var(--serif); font-style: italic; font-size: 21px; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter { display: grid; justify-items: end; line-height: 1.1; }
.meter b { font-size: 19px; font-variant-numeric: tabular-nums; }
.meter small { font-size: 12px; color: var(--sage); }
.meter.urgent b { color: var(--alarm); }

.game main {
  max-width: 680px;
  margin: 0 auto;
  padding: 18px 18px calc(var(--tabbar) + env(safe-area-inset-bottom) + 30px);
}
.tabs {
  position: fixed;
  z-index: 30;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--green-deep);
  border-top: 1px solid var(--brass-dim);
}
.tabs button {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 3px;
  min-height: var(--tabbar);
  padding: 9px 2px 7px;
  border: 0;
  background: none;
  color: var(--sage);
  font: 400 12.5px/1 var(--type);
  cursor: pointer;
}
.tabs svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-selected='true'] { color: var(--brass); box-shadow: inset 0 2px 0 var(--brass); }
.badge {
  position: absolute;
  top: 5px;
  left: calc(50% + 11px);
  padding: 1px 5px;
  border-radius: 9px;
  background: var(--brass);
  color: var(--green-deep);
  font-size: 11px;
  font-weight: 700;
  font-style: normal;
}
.badge.dot { width: 9px; height: 9px; padding: 0; top: 8px; left: calc(50% + 10px); background: var(--alarm); }

.banner {
  margin: 0 0 22px;
  padding: 14px 16px;
  border: 1px solid var(--brass-dim);
  border-left: 4px solid var(--brass);
  background: var(--brass-wash);
}
.banner.closing { border-left-color: var(--alarm); }
.banner p:last-child { margin-bottom: 0; }

/* ---------- case file ---------- */
.case-head { padding: 8px 0 18px; border-bottom: 1px solid var(--green-line); margin-bottom: 22px; }
.paper {
  color: var(--ink);
  background: var(--manila);
  border-radius: 3px;
  box-shadow: var(--paper-shadow);
}
.report { padding: 18px 18px 6px; }
.timeline { margin: 0; padding: 0; list-style: none; border-left: 1px solid var(--brass-dim); }
.timeline li { display: grid; grid-template-columns: 5.4em 1fr; gap: 10px; padding: 0 0 12px 14px; position: relative; }
.timeline li::before { content: ''; position: absolute; left: -4px; top: 0.55em; width: 7px; height: 7px; background: var(--brass); border-radius: 50%; }
.timeline time { color: var(--brass); font-weight: 700; white-space: nowrap; }

.suspects { display: grid; gap: 10px; }
.suspect { border: 1px solid var(--green-line); border-radius: 6px; background: rgba(26, 49, 40, 0.6); }
.suspect[open] { border-color: var(--brass-dim); }
.suspect summary { display: flex; align-items: center; gap: 14px; padding: 12px 14px; cursor: pointer; list-style: none; }
.suspect summary::-webkit-details-marker { display: none; }
.suspect summary::after { content: '+'; margin-left: auto; font-size: 22px; color: var(--brass); }
.suspect[open] summary::after { content: '\2212'; }
.monogram {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border: 1px solid var(--brass);
  border-radius: 50%;
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  color: var(--brass);
}
.who b { display: block; font-size: 17px; }
.who small { color: var(--sage); font-size: 14px; }
.suspect-body { padding: 0 16px 14px; }
.suspect-body blockquote { margin: 12px 0 4px; padding: 12px 14px; color: var(--ink); background: var(--manila-light); border-left: 3px solid var(--manila-edge); }
.suspect-body blockquote p { margin: 0; }
.suspect-body .said { display: block; margin-bottom: 4px; font-size: 13.5px; color: var(--ink-soft); }

/* ---------- clue list ---------- */
.panel-head { margin-bottom: 14px; }
.panel-head .h2 { margin-top: 4px; }
.clue-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.clue-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  color: var(--ivory);
  background: rgba(26, 49, 40, 0.7);
  border: 1px solid var(--green-line);
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}
.clue-row:hover { border-color: var(--brass-dim); }
.ex {
  display: grid; place-items: center;
  width: 42px; height: 42px;
  border: 1px solid var(--brass-dim);
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 20px;
  color: var(--brass);
}
.clue-row.solved .ex { background: var(--brass); color: var(--green-deep); border-color: var(--brass); }
.clue-title { display: grid; font-weight: 700; line-height: 1.25; }
.clue-title small { font-weight: 400; color: var(--sage); font-size: 13.5px; }
.pts { font-weight: 700; color: var(--brass); white-space: nowrap; text-align: right; }
.pts.got { color: var(--good); }
.pts small { display: block; font-weight: 400; font-size: 12px; color: var(--sage); }

/* ---------- clue sheet ---------- */
body.sheet-open { overflow: hidden; }
.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--green-deep);
}
.sheet-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  border-bottom: 1px solid var(--brass-dim);
}
.sheet-bar .back { min-height: 42px; padding: 8px 12px; }
.sheet-exhibit { color: var(--sage); font-size: 14px; }
.sheet-worth { font-weight: 700; color: var(--brass); }
.sheet-scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-body { max-width: 640px; margin: 0 auto; padding: 18px 18px calc(env(safe-area-inset-bottom) + 60px); }
.sheet-title { margin: 0 0 14px; font-family: var(--serif); font-weight: 500; font-style: italic; font-size: 34px; line-height: 1.05; }
.prompt { margin-bottom: 22px; }

.answer-form { padding: 16px; border: 1px solid var(--brass-dim); border-radius: 6px; background: rgba(26, 49, 40, 0.7); }
.answer-form label { margin-bottom: 10px; font-weight: 700; }
.answer-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.answer-row .btn { min-height: 48px; }
.feedback { min-height: 1.3em; margin: 10px 0 0; }
.feedback.bad { color: var(--alarm); }
.feedback.good { color: var(--good); }
.shake { animation: shake 0.36s ease; }
@keyframes shake { 20% { transform: translateX(-7px); } 45% { transform: translateX(6px); } 70% { transform: translateX(-3px); } }

.hints { margin-top: 18px; }
.hint { margin: 0 0 10px; padding: 12px 14px; border-left: 3px solid var(--brass); background: var(--brass-wash); }
.hint b { display: block; margin-bottom: 2px; color: var(--brass); font-size: 14px; }
.hint-btn { width: 100%; }
.hint-btn.armed { border-color: var(--brass); color: var(--brass); }
.solved-note { padding: 14px 16px; border: 1px solid var(--good); border-radius: 6px; color: var(--good); }

/* ---------- puzzle material ---------- */
.speechcard { margin: 18px 0; padding: 22px 18px 14px; background: var(--manila-light); transform: rotate(-0.6deg); }
.cipher { margin: 0 0 10px; font-weight: 700; font-size: 20px; line-height: 1.8; letter-spacing: 0.14em; word-spacing: 0.35em; overflow-wrap: anywhere; }
.speechcard figcaption, .photo figcaption { font-size: 13.5px; color: var(--ink-soft); }
.alphabet { display: grid; grid-template-columns: repeat(13, 1fr); gap: 4px; margin: 14px 0 0; }
.alphabet span { padding: 5px 0; text-align: center; font-weight: 700; font-size: 15px; border: 1px solid var(--green-line); border-radius: 4px; color: var(--ivory); }

.photo { margin: 18px 0; }
.photo .desk-photo { display: block; width: 100%; height: auto; border: 8px solid #f2eee5; border-bottom-width: 26px; box-shadow: var(--paper-shadow); }
.photo figcaption { margin-top: 10px; color: var(--sage); }

.riddle { margin: 18px 0; padding: 20px 20px 8px; font-family: var(--serif); font-style: italic; font-size: 19px; line-height: 1.5; }

.device { margin: 18px 0; border-radius: 14px; padding: 14px; background: linear-gradient(160deg, #273029, #121714); border: 1px solid #3a463e; }
.watchlog table { width: 100%; border-collapse: collapse; color: #bfe8c9; font-variant-numeric: tabular-nums; }
.watchlog th { padding: 6px 10px; text-align: left; font-weight: 400; font-size: 13.5px; color: #7fa88a; border-bottom: 1px solid #2f3d33; }
.watchlog td { padding: 7px 10px; font-weight: 700; font-size: 17px; border-bottom: 1px solid #1f2a23; }
.watchlog td:last-child, .watchlog th:last-child { text-align: right; }

.pager { margin: 18px 0 14px; padding: 16px; border-radius: 20px; background: linear-gradient(170deg, #3b4148, #1b1f23); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), var(--paper-shadow); }
.pager-screen {
  padding: 16px 12px;
  border-radius: 6px;
  background: #a6bd8b;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
  color: #1b2915;
  font-weight: 700;
  font-size: 21px;
  line-height: 1.5;
  letter-spacing: 0.06em;
  word-spacing: 0.4em;
  text-align: center;
}
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 360px; margin: 0 auto; }
.keypad span { padding: 8px 4px; text-align: center; font-size: 13px; letter-spacing: 0.12em; color: var(--sage); border: 1px solid var(--green-line); border-radius: 10px; background: var(--green-raised); }
.keypad b { display: block; font-size: 21px; letter-spacing: 0; color: var(--ivory); }

.letter { margin: 18px 0; padding: 22px 20px 12px; background: #f1e7cc; }
.letter { font-size: 15.5px; }
.letter p { margin: 0 0 0.55em; padding-left: 1.4em; text-indent: -1.4em; }
.letterhead { text-indent: 0 !important; padding-left: 0 !important; font-variant: small-caps; letter-spacing: 0.04em; color: var(--ink-soft); padding-bottom: 8px; border-bottom: 1px solid var(--manila-edge); margin-bottom: 14px !important; }
.salutation { font-style: italic; text-indent: 0 !important; padding-left: 0 !important; }

.sticky { margin: 20px 4px; padding: 16px 16px 8px; color: #2b2410; background: #f0dc74; transform: rotate(-0.8deg); box-shadow: var(--paper-shadow); }
.lockrow { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 14px; margin-bottom: 10px; }
.digits { display: flex; gap: 4px; }
.digits b { display: grid; place-items: center; width: 30px; height: 38px; font-size: 21px; background: #fff8d2; border: 1px solid #c6ae45; border-radius: 3px; }

.clues { margin: 0 0 16px; padding: 0; list-style: none; counter-reset: c; }
.clues li { counter-increment: c; position: relative; padding: 0 0 10px 34px; }
.clues li::before { content: counter(c); position: absolute; left: 0; top: 0; width: 24px; height: 24px; display: grid; place-items: center; font-family: var(--serif); font-size: 15px; color: var(--green-deep); background: var(--brass); border-radius: 50%; }
.lineup { padding: 14px; border: 1px dashed var(--green-line); border-radius: 6px; }
.lineup-label { margin: 0 0 10px; font-size: 14px; color: var(--sage); }
.slots { display: grid; gap: 6px; }
.slot { display: grid; grid-template-columns: minmax(2em, 6.5em) 1fr; align-items: center; gap: 8px; font-family: var(--serif); font-size: 17px; color: var(--brass); }
.slot select { padding: 9px 10px; font-size: 16px; }

.log { width: 100%; border-collapse: collapse; margin: 0 0 14px; font-size: 15px; }
.log td { padding: 6px 0; border-bottom: 1px dashed var(--manila-edge); vertical-align: top; }
.log td:first-child { width: 5.6em; font-weight: 700; white-space: nowrap; }

/* ---------- evidence ---------- */
.exhibits { display: grid; gap: 16px; }
.exhibit { padding: 18px 18px 8px; }
.exhibit header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--manila-edge); }
.ex-tag { flex: none; color: var(--oxblood); font-weight: 700; font-size: 14px; }
.exhibit h3 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 21px; line-height: 1.15; }
.not-cracked { font-size: 14px; color: var(--ink-soft); font-style: italic; }
.exhibit.locked { display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 14px; padding: 12px 14px; color: var(--sage); border: 1px dashed var(--green-line); border-radius: 6px; }
.exhibit.locked p { margin: 0; }
.just-unlocked { animation: unfold 0.55s cubic-bezier(0.2, 0.8, 0.2, 1); transform-origin: top center; }
@keyframes unfold { from { opacity: 0; transform: translateY(10px) rotate(-1.5deg) scaleY(0.92); } to { opacity: 1; transform: none; } }
.notebook textarea { min-height: 160px; resize: vertical; line-height: 1.5; }

/* ---------- accusation ---------- */
.lede { color: var(--sage); }
.choice-group { margin: 0 0 22px; padding: 0; border: 0; }
.choice-group legend { display: flex; justify-content: space-between; width: 100%; margin-bottom: 10px; font-family: var(--serif); font-weight: 600; font-size: 21px; color: var(--ivory); }
.choice-group legend span { font-family: var(--type); font-weight: 400; font-size: 14px; color: var(--brass); align-self: center; }
.choice { position: relative; display: block; margin-bottom: 7px; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span { display: block; padding: 12px 14px 12px 44px; border: 1px solid var(--green-line); border-radius: 6px; background: rgba(26, 49, 40, 0.7); position: relative; }
.choice span::before { content: ''; position: absolute; left: 14px; top: 50%; width: 16px; height: 16px; margin-top: -8px; border: 1.5px solid var(--sage); border-radius: 50%; }
.choice input:checked + span { border-color: var(--brass); background: var(--brass-wash); }
.choice input:checked + span::before { border-color: var(--brass); background: radial-gradient(circle, var(--brass) 45%, transparent 50%); }
.choice input:focus-visible + span { outline: 3px solid var(--brass); outline-offset: 2px; }
.wax { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #c2434e, #6f1520 70%); box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.18); }

/* the envelope: the one bold object in the game */
.envelope { position: relative; margin: 8px 0 18px; padding: 142px 18px 18px; color: var(--ink); background: var(--manila); border-radius: 4px; box-shadow: var(--paper-shadow); overflow: hidden; }
.env-flap { position: absolute; left: 0; right: 0; top: 0; height: 96px; background: var(--manila-edge); clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top center; transition: transform 0.6s ease; }
.envelope.open { margin-top: 64px; overflow: visible; }
.envelope.open .env-flap { top: -56px; height: 56px; clip-path: polygon(0 100%, 50% 0, 100% 100%); animation: flap-open 0.7s ease both; }
@keyframes flap-open { from { transform: scaleY(-1); transform-origin: bottom center; } to { transform: none; transform-origin: bottom center; } }
.env-seal {
  position: absolute; left: 50%; top: 62px; z-index: 2;
  display: grid; place-items: center;
  width: 64px; height: 64px; margin-left: -32px;
  border-radius: 47% 53% 50% 50% / 52% 48% 52% 48%;
  background: radial-gradient(circle at 35% 30%, #c0414c, #7a1a24 62%, #5c1019);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35), inset 0 0 0 5px rgba(0, 0, 0, 0.14);
  font-family: var(--serif); font-style: italic; font-size: 28px; color: rgba(255, 220, 210, 0.75);
  transform: rotate(-8deg);
}
.envelope.open .env-seal { opacity: 0; }
.just-sealed .env-seal { animation: stamp 0.5s cubic-bezier(0.3, 1.5, 0.5, 1); }
@keyframes stamp { from { transform: scale(1.8) rotate(-30deg); opacity: 0; } to { transform: scale(1) rotate(-8deg); opacity: 1; } }
.env-label { margin: 0 0 14px; text-align: center; font-family: var(--serif); font-size: 19px; }
.envelope.open { padding-top: 22px; }
.picks { margin: 0; display: grid; gap: 10px; }
.pick { padding: 10px 12px; color: var(--ink); background: var(--manila-light); border-radius: 3px; }
.pick dt { font-size: 13.5px; color: var(--ink-soft); }
.pick dd { margin: 2px 0 0; font-weight: 700; }
.pick .verdict { display: block; margin-top: 4px; font-weight: 400; font-size: 14px; }
.pick.right { box-shadow: inset 4px 0 0 #3f7a4c; }
.pick.wrong { box-shadow: inset 4px 0 0 var(--oxblood); }
.pick.right .verdict { color: #2f6a3c; }
.pick.wrong .verdict { color: var(--oxblood); }

/* ---------- solution ---------- */
.solution { padding: 20px 18px 8px; margin-bottom: 26px; }
.solution h2 { margin: 0 0 12px; font-family: var(--serif); font-weight: 600; font-style: italic; font-size: 27px; line-height: 1.15; color: var(--oxblood); }
.solution dl { margin: 0 0 14px; display: grid; gap: 6px; }
.solution dt { font-size: 13.5px; color: var(--ink-soft); }
.solution dd { margin: 0 0 6px; font-weight: 700; }
.solution h3 { margin: 18px 0 6px; font-family: var(--serif); font-size: 19px; }
.solution ul { margin: 0 0 12px; padding-left: 20px; }

/* ---------- ranks ---------- */
.my-rank { margin: 0 0 14px; font-family: var(--serif); font-size: 22px; }
.board { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.board li { display: grid; grid-template-columns: 2.4em 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--green-line); border-radius: 6px; background: rgba(26, 49, 40, 0.6); }
.board li.me { border-color: var(--brass); background: var(--brass-wash); }
.board .rk { font-family: var(--serif); font-size: 21px; color: var(--brass); text-align: center; }
.board .nm { min-width: 0; }
.board .nm b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .nm small { color: var(--sage); font-size: 13.5px; }
.board .sc { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.board .sc small { display: block; font-weight: 400; font-size: 12.5px; color: var(--sage); }

/* ---------- modal + toasts ---------- */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 18px; background: rgba(5, 10, 8, 0.72); }
.modal-card { width: min(440px, 100%); padding: 22px 20px 18px; border: 1px solid var(--brass-dim); border-radius: 8px; background: var(--green-raised); }
.modal-card h2 { margin: 0 0 10px; font-family: var(--serif); font-weight: 600; font-size: 24px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.toasts { position: fixed; z-index: 90; left: 12px; right: 12px; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 12px); display: grid; gap: 8px; justify-items: center; pointer-events: none; }
body:not(.in-game) .toasts, body.sheet-open .toasts { bottom: calc(env(safe-area-inset-bottom) + 16px); }
.toast { max-width: 520px; padding: 11px 16px; border: 1px solid var(--brass-dim); border-radius: 6px; background: var(--green-deep); color: var(--ivory); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45); animation: toast-in 0.25s ease; }
.toast.good { border-color: var(--good); color: var(--good); }
.toast.warn { border-color: var(--alarm); color: var(--alarm); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.boot { display: grid; place-items: center; min-height: 70vh; color: var(--sage); }

/* ======================================================================
   BIG SCREEN (project this)
   ====================================================================== */
body.screen { height: 100vh; overflow: hidden; font-size: 1.25vw; }
.scr { display: grid; grid-template-rows: auto 1fr; height: 100vh; padding: 3.2vh 3.4vw 3vh; gap: 3.2vh; }
.scr-head { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 3vw; padding-bottom: 2.4vh; border-bottom: 1px solid var(--brass-dim); }
.scr-title { font-size: 5.6vw; }
.scr-sub { margin: 1vh 0 0; font-family: var(--serif); font-size: 1.7vw; color: var(--sage); }
.scr-clock { text-align: right; }
.scr-clock b { display: block; font-family: var(--serif); font-weight: 500; font-size: 7.6vw; line-height: 0.9; font-variant-numeric: lining-nums tabular-nums; }
.scr-clock small { font-size: 1.3vw; color: var(--sage); }
.scr-clock.urgent b { color: var(--alarm); }
.scr-main { display: grid; grid-template-columns: 1.65fr 1fr; gap: 3.2vw; min-height: 0; }
.scr-col { min-height: 0; overflow: hidden; display: grid; align-content: start; gap: 2.4vh; }
.scr-h { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 2vw; color: var(--brass); }
.scr-board { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.9vh; }
.scr-board li { display: grid; grid-template-columns: 3vw 1fr 6.5vw 7vw; align-items: center; gap: 1.2vw; padding: 1.05vh 1.2vw; border-bottom: 1px solid var(--green-line); font-size: 1.55vw; }
.scr-board li:nth-child(-n+3) { background: var(--brass-wash); border-bottom-color: var(--brass-dim); }
.scr-board .rk { font-family: var(--serif); font-size: 2.2vw; color: var(--brass); text-align: center; }
.scr-board .nm { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 700; }
.scr-board .nm small { font-weight: 400; color: var(--sage); margin-left: 0.8vw; }
.scr-board .cl { color: var(--sage); text-align: right; font-size: 1.25vw; }
.scr-board .sc { font-family: var(--serif); font-size: 2vw; text-align: right; font-variant-numeric: lining-nums tabular-nums; }
.scr-empty { font-size: 1.6vw; color: var(--sage); }
.join-card { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 1.6vw; padding: 1.6vw; }
.join-card .qr { width: 13vw; aspect-ratio: 1; background: #fff; border-radius: 4px; }
.join-card .qr svg { display: block; width: 100%; height: 100%; }
.join-card .qr img, .join-card .qr canvas { display: block; width: 100% !important; height: auto !important; }
.join-card h3 { margin: 0 0 0.6vh; font-family: var(--serif); font-size: 2.2vw; font-weight: 600; }
.join-card p { margin: 0; font-size: 1.35vw; overflow-wrap: anywhere; }
.qr-fallback { font-size: 1.1vw; color: var(--ink); overflow-wrap: anywhere; }
.feed { margin: 0; padding: 0; list-style: none; display: grid; gap: 1vh; }
.feed li { display: grid; grid-template-columns: 1fr auto; gap: 1vw; font-size: 1.3vw; padding-bottom: 1vh; border-bottom: 1px dashed var(--green-line); }
.feed li.first { color: var(--brass); }
.feed time { color: var(--sage); font-size: 1.1vw; }
.scr-stat { font-size: 1.4vw; color: var(--sage); margin: 0; }

/* lobby layout on the big screen */
.scr-lobby { display: grid; grid-template-columns: auto 1fr; gap: 4vw; align-items: center; }
.scr-lobby .join-card { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 2.2vw; }
.scr-lobby .join-card .qr { width: 24vw; }
.scr-lobby .join-card h3 { font-size: 2.8vw; }
.scr-lobby .join-card p { font-size: 1.6vw; }
.guest-count { margin: 0; font-family: var(--serif); font-size: 7vw; line-height: 1; }
.guest-label { margin: 1vh 0 3vh; font-size: 1.8vw; color: var(--sage); }
.guests { display: flex; flex-wrap: wrap; gap: 0.8vw; }
.scr-warn { margin: 3vh 0 0; padding: 1.2vh 1.2vw; border-left: 0.35vw solid var(--alarm); background: rgba(229, 128, 138, 0.1); font-size: 1.3vw; }
.guests span { padding: 0.5vh 1vw; border: 1px solid var(--green-line); border-radius: 999px; font-size: 1.35vw; }

/* the reveal */
.reveal-name { margin: 0; font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 5.4vw; line-height: 1; color: var(--alarm); }
.reveal-kicker { margin: 0 0 0.6vh; font-family: var(--serif); font-size: 2.2vw; color: var(--sage); }
.reveal-facts { margin: 1.8vh 0 0; display: grid; grid-template-columns: auto 1fr; gap: 0.7vh 1.4vw; font-size: 1.3vw; line-height: 1.4; }
.reveal-facts dt { color: var(--brass); }
.reveal-facts dd { margin: 0; }
.votes { display: grid; gap: 0.6vh; }
.vote { display: grid; grid-template-columns: 12vw 1fr 3vw; align-items: center; gap: 1vw; font-size: 1.2vw; }
.vote .bar { height: 1.7vh; background: var(--green-line); border-radius: 2px; overflow: hidden; }
.vote .bar i { display: block; height: 100%; background: var(--sage); }
.vote.correct .bar i { background: var(--alarm); }
.vote.correct { color: var(--alarm); font-weight: 700; }
.vote b { text-align: right; }
.scr-col.reveal { gap: 1.8vh; }
.drumroll { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: var(--green-deep); }
.drumroll p { font-family: var(--serif); font-style: italic; font-size: 6vw; margin: 0; animation: pulse 1.4s ease-in-out infinite; }
.reveal-in { animation: reveal-in 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes reveal-in { from { opacity: 0; letter-spacing: 0.2em; filter: blur(6px); } to { opacity: 1; letter-spacing: normal; filter: none; } }
.fs-btn { position: fixed; right: 1vw; bottom: 1vh; z-index: 20; min-height: 36px; padding: 6px 12px; font-size: 13px; background: var(--green-deep); opacity: 0.85; transition: opacity 0.4s ease; }
body.idle .fs-btn { opacity: 0; pointer-events: none; }
body.idle { cursor: none; }

@media (min-width: 720px) {
  .view { padding: 0 24px; }
  .game main { padding-left: 24px; padding-right: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ======================================================================
   HOME, CREATE, JOIN, LOBBY
   ====================================================================== */
.home { max-width: 640px; margin: 0 auto; padding-bottom: 60px; }
.home .invitation { margin-bottom: 34px; }
.home .title { font-size: clamp(44px, 13vw, 72px); }
.home .inv-line { margin: 18px 0 0; }
.home-actions { display: grid; gap: 10px; }
.home-actions small { font-weight: 400; font-size: 13px; color: var(--sage); }
.home-block { margin-top: 12px; }
.narrow { max-width: 520px; margin: 0 auto; padding-top: 18px; padding-bottom: 60px; }
.title.small { font-size: clamp(32px, 9vw, 44px); }
.back-link { min-height: 40px; padding: 6px 14px; margin-bottom: 14px; font-size: 15px; }
.small-note { font-size: 14px; margin-top: 10px; }
.field-set { margin: 0; padding: 0; border: 0; min-width: 0; }
.field-set .choice span b { display: block; }

.case-grid { display: grid; gap: 10px; }
.case-card {
  display: grid; grid-template-columns: 52px 1fr; gap: 14px; align-items: start;
  width: 100%; padding: 14px; text-align: left; font: inherit; color: var(--ivory); cursor: pointer;
  background: var(--card-bg, var(--green-raised)); border: 1px solid var(--green-line); border-left: 4px solid var(--card-accent, var(--brass)); border-radius: 6px;
}
.case-card:hover { border-color: var(--card-accent, var(--brass)); }
.case-text { display: grid; gap: 4px; min-width: 0; }
.case-text b { font-family: var(--serif); font-size: 20px; line-height: 1.15; color: var(--card-accent, var(--brass)); }
.case-text small { color: var(--sage); font-size: 13.5px; }
.case-text span { font-size: 15px; }
.case-meta { margin-top: 2px; }
.case-emoji { font-size: 34px; line-height: 1; text-align: center; }
.case-emoji.big { font-size: 54px; }

.open-rooms { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.open-rooms li:not(.muted) { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--green-line); border-radius: 6px; background: rgba(0, 0, 0, 0.18); }
.open-rooms .case-emoji { font-size: 28px; }
.or-text { display: grid; min-width: 0; }
.or-text small { color: var(--sage); font-size: 13.5px; }
.open-rooms .btn { min-height: 42px; padding: 8px 14px; }

.case-pick { display: grid; gap: 8px; }
.case-option { position: relative; display: block; cursor: pointer; }
.case-option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.case-option > span { display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--green-line); border-radius: 6px; background: rgba(0, 0, 0, 0.18); }
.case-option .case-emoji { grid-row: 1 / 3; font-size: 28px; }
.case-option b { font-family: var(--serif); font-size: 18px; line-height: 1.2; }
.case-option small { color: var(--sage); font-size: 13px; }
.case-option input:checked + span { border-color: var(--card-accent, var(--brass)); background: var(--brass-wash); box-shadow: inset 4px 0 0 var(--card-accent, var(--brass)); }
.case-option input:focus-visible + span { outline: 3px solid var(--brass); outline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span { display: block; padding: 9px 14px; border: 1px solid var(--green-line); border-radius: 999px; font-size: 15px; }
.chip input:checked + span { border-color: var(--brass); background: var(--brass); color: var(--green-deep); font-weight: 700; }
.chip input:focus-visible + span { outline: 3px solid var(--brass); outline-offset: 2px; }
.chip input:disabled + span { opacity: 0.5; }

.stepper { display: grid; grid-template-columns: 54px 1fr 54px; gap: 8px; max-width: 260px; }
.stepper input { text-align: center; font-weight: 700; }
.stepper .btn { padding: 0; font-size: 24px; }
.code-input { font-size: 30px; font-weight: 700; letter-spacing: 0.35em; text-align: center; text-transform: uppercase; }
.toggle { display: flex; align-items: center; gap: 12px; margin-top: 16px; cursor: pointer; }
.toggle input { width: 22px; height: 22px; accent-color: var(--brass); }

.lobby .room-card { margin: 0 0 20px; padding: 18px; text-align: center; border: 1px solid var(--brass); border-radius: 8px; background: rgba(0, 0, 0, 0.22); }
.room-label { margin: 0; color: var(--sage); font-size: 14px; letter-spacing: 0.1em; text-transform: uppercase; }
.room-code { margin: 2px 0 12px; font-weight: 700; font-size: clamp(44px, 14vw, 64px); letter-spacing: 0.22em; color: var(--brass); line-height: 1.05; }
.room-share { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; text-align: left; }
.room-share p { margin: 0 0 8px; overflow-wrap: anywhere; font-size: 14px; }
.room-share .btn { min-height: 42px; padding: 8px 14px; }
.qr.small { width: 112px; aspect-ratio: 1; background: #fff; border-radius: 4px; padding: 2px; }
.qr.small svg { display: block; width: 100%; height: 100%; }
.case-banner { display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: start; padding: 16px; border: 1px solid var(--green-line); border-left: 4px solid var(--card-accent, var(--brass)); border-radius: 6px; background: rgba(0, 0, 0, 0.18); }
.case-banner p { margin: 6px 0 0; }
.case-banner .muted { margin: 0 0 4px; font-size: 14px; }
.settings-list { margin: 0; display: grid; gap: 8px; }
.settings-list div { display: grid; grid-template-columns: 7.5em 1fr; gap: 10px; padding-bottom: 8px; border-bottom: 1px dashed var(--green-line); }
.settings-list dt { color: var(--sage); }
.settings-list dd { margin: 0; font-weight: 700; }
.owner-settings select { font-size: 16px; }
.owner-settings .field-label:first-child { margin-top: 0; }
.players { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.players li { display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; align-items: center; padding: 8px 12px; border: 1px solid var(--green-line); border-radius: 6px; }
.players li.me { border-color: var(--brass-dim); background: var(--brass-wash); }
.players .monogram { width: 34px; height: 34px; font-size: 14px; }
.players small { color: var(--sage); }
.owner-tag { padding: 2px 8px; border: 1px solid var(--brass-dim); border-radius: 999px; color: var(--brass) !important; font-size: 12px; }
.h2 .count { font-family: var(--type); font-size: 16px; font-weight: 400; color: var(--sage); }
#lobby-start { margin: 22px 0 8px; }

/* ---------- results ---------- */
.h3 { margin: 26px 0 10px; font-family: var(--serif); font-weight: 600; font-size: 21px; color: var(--brass); }
.reveal-card { padding: 18px 18px 8px; }
.reveal-card h3 { margin: 0 0 12px; font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 30px; line-height: 1.1; color: var(--oxblood); }
.reveal-card dl { margin: 0 0 12px; display: grid; gap: 4px; }
.reveal-card dt { font-size: 13.5px; color: var(--ink-soft); }
.reveal-card dd { margin: 0 0 6px; font-weight: 700; }
.reveal-card .reveal-kicker { margin: 0; font-size: 14px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.08em; }
.muted-ink { color: var(--ink-soft); font-size: 14px; }
.player .votes { display: grid; gap: 6px; margin-bottom: 8px; }
.player .vote { display: grid; grid-template-columns: minmax(7em, 40%) 1fr 2em; align-items: center; gap: 10px; font-size: 14.5px; }
.player .vote .bar { height: 10px; background: var(--green-line); border-radius: 2px; overflow: hidden; }
.player .vote .bar i { display: block; height: 100%; background: var(--sage); }
.player .vote.correct { color: var(--alarm); font-weight: 700; }
.player .vote.correct .bar i { background: var(--alarm); }
.player .vote b { text-align: right; }
.board li.podium { border-color: var(--brass-dim); }
.board li.p1 { background: var(--brass-wash); border-color: var(--brass); }
.board li.podium .rk { font-size: 24px; }
.after-actions { display: grid; gap: 10px; margin: 22px 0 16px; }

/* ---------- more puzzle material ---------- */
.alphabet.numbered span, .alphabet.mirror span { display: grid; line-height: 1.15; }
.alphabet.numbered small { font-weight: 400; font-size: 11.5px; color: var(--sage); }
.alphabet.mirror { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }
.morse-key, .glyph-key { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 4px; margin: 14px 0 0; }
.morse-key span, .glyph-key span { display: grid; grid-template-columns: 1.4em 1fr; gap: 6px; padding: 5px 8px; border: 1px solid var(--green-line); border-radius: 4px; font-size: 14px; color: var(--sage); }
.glyph-key span { grid-template-columns: 1.6em 1fr; font-size: 17px; color: var(--ivory); }
.morse-key b, .glyph-key b { color: var(--ivory); }
.cipher.morse { font-size: 18px; letter-spacing: 0.06em; word-spacing: 0.15em; }
.cipher.glyphs { font-size: 26px; letter-spacing: 0.08em; word-spacing: 0.1em; line-height: 1.6; }
.device.terminal { background: #07110f; border-color: #1d3b33; }
.device.terminal .cipher { margin: 0; color: #7df0c0; font-size: 18px; line-height: 1.8; }
.hex, .polybius { border-collapse: collapse; margin: 14px 0 0; font-size: 14px; }
.hex { display: block; columns: 3; column-gap: 18px; }
.hex tbody { display: block; }
.hex tr { display: flex; gap: 10px; padding: 3px 0; border-bottom: 1px dashed var(--green-line); break-inside: avoid; }
.hex td:first-child { color: var(--sage); width: 2.2em; }
.hex td:last-child { font-weight: 700; }
.polybius th, .polybius td { width: 44px; height: 36px; text-align: center; border: 1px solid var(--green-line); }
.polybius th { color: var(--brass); font-weight: 700; }
.two-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.two-lists .paper { padding: 12px 12px 4px; font-size: 14px; }
.two-lists ol { margin: 0 0 8px; padding-left: 20px; }
.two-lists li { margin-bottom: 3px; }
.shelf { display: flex; flex-wrap: wrap; gap: 4px; align-items: flex-end; margin: 18px 0 10px; padding: 10px 10px 0; border-bottom: 8px solid #4a2e1a; }
.spine { display: grid; justify-items: center; width: 46px; height: 118px; padding: 10px 0; border-radius: 3px 3px 0 0; background: linear-gradient(90deg, #5b1f24, #7a2d31 45%, #5b1f24); color: #e8cf94; font-size: 11px; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.2); }
.spine:nth-child(odd) { background: linear-gradient(90deg, #1f3b2d, #2b5540 45%, #1f3b2d); height: 110px; }
.spine b { align-self: end; font-family: var(--serif); font-size: 21px; }
.map-grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 2px; max-width: 380px; margin: 18px auto 8px; padding: 10px; background: #d9c08a; border-radius: 4px; color: var(--ink); box-shadow: var(--paper-shadow); }
.map-grid b { display: grid; place-items: center; font-size: 13px; }
.map-grid i { aspect-ratio: 1; display: grid; place-items: center; border: 1px solid rgba(90, 60, 20, 0.35); font-style: normal; font-size: 18px; }
.map-grid i.skull { background: rgba(142, 36, 48, 0.2); }
.qwerty { display: grid; gap: 4px; margin: 14px 0 0; }
.qwerty div { display: flex; justify-content: center; gap: 4px; }
.qwerty div:nth-child(2) { padding-left: 14px; }
.qwerty div:nth-child(3) { padding-left: 40px; }
.qwerty span { display: grid; place-items: center; width: 30px; height: 36px; border: 1px solid var(--green-line); border-radius: 4px; font-weight: 700; font-size: 15px; background: var(--green-raised); }

@media (max-width: 380px) {
  .two-lists { grid-template-columns: 1fr; }
  .qwerty span { width: 26px; }
  .room-share { grid-template-columns: 1fr; justify-items: center; text-align: center; }
}

/* big screen: room picker */
.scr-pick { max-width: 460px; margin: 10vh auto; padding: 0 18px; font-size: 16.5px; }
.scr-pick .scr-sub { font-size: 17px; margin-bottom: 20px; }
.guest-count small { font-size: 0.4em; color: var(--sage); }

/* ======================================================================
   SOLO CASES (offline)
   ====================================================================== */
.offline-mode { --green: #161c2e; --green-deep: #0c101c; --green-raised: #1d2540; --green-line: #2e3a5c; --brass: #d6b56b; --brass-dim: #7f6f4a; --brass-wash: rgba(214, 181, 107, 0.13); --glow: #27315a; }
.offline-head { padding-top: 18px; }
.offline-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 22px 0 16px; }
.offline-stats div { display: grid; justify-items: center; padding: 12px 6px; border: 1px solid var(--green-line); border-radius: 6px; background: rgba(0, 0, 0, 0.18); }
.offline-stats b { font-family: var(--serif); font-size: 26px; color: var(--brass); line-height: 1.1; }
.offline-stats small { color: var(--sage); font-size: 13px; }
.offline-list { margin-top: 16px; }
.o-choices { margin: 10px 0 12px; }
.answer-form .q { margin: 0 0 8px; font-weight: 700; }
.give-up { display: block; margin: 16px auto 0; color: var(--sage); }

/* difficulty, scratch grid, shift table */
.level { white-space: nowrap; }
.level.l3 { color: #e8b86a; }
.level.l4 { color: var(--alarm); font-weight: 700; }
#library-filter { margin: 4px 0 12px; }
.gridpad { margin-top: 16px; padding: 12px; border: 1px dashed var(--green-line); border-radius: 6px; overflow-x: auto; }
.gridpad table { width: 100%; border-collapse: collapse; }
.gridpad th { padding: 4px 6px; text-align: left; font-size: 14px; color: var(--brass); white-space: nowrap; }
.gridpad td { padding: 3px; }
.gridpad select { padding: 7px 6px; font-size: 14px; min-width: 7em; }
.tabula { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 4px; margin: 14px 0 0; }
.tabula span { padding: 5px 0; text-align: center; font-size: 13px; color: var(--sage); border: 1px solid var(--green-line); border-radius: 4px; }
.tabula b { color: var(--ivory); margin-right: 2px; }
.textblock { font-size: 15.5px; line-height: 1.7; }
.textblock .ln { color: var(--ink-soft); margin-right: 8px; font-size: 13px; }
.vgrid { display: inline-grid; gap: 2px; margin: 12px 0; font-weight: 700; font-size: 20px; }
.vgrid span { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--manila-edge); background: var(--manila-light); color: var(--ink); }
.cards { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.card { display: grid; place-items: center; width: 46px; height: 64px; border-radius: 6px; background: #fbf7ee; color: #1b1b1b; font-weight: 700; font-size: 18px; box-shadow: var(--paper-shadow); }
.card.red { color: #b3202d; }
.board8 { display: grid; grid-template-columns: 22px repeat(8, 1fr); max-width: 360px; margin: 14px auto; font-size: 13px; }
.board8 b { display: grid; place-items: center; color: var(--sage); }
.board8 i { aspect-ratio: 1; display: grid; place-items: center; font-style: normal; font-weight: 700; font-size: 16px; color: #2a2016; background: #efe0bd; }
.board8 i.dk { background: #b58863; color: #fff6e6; }

/* leaving early, your games */
.topbar { grid-template-columns: 1fr auto auto auto; }
.exit-btn { min-height: 34px; padding: 4px 10px; border: 1px solid var(--green-line); border-radius: 6px; background: none; color: var(--sage); font: 400 13px/1 var(--type); cursor: pointer; }
.exit-btn:hover { color: var(--ivory); border-color: var(--brass-dim); }
.done-card { margin: 18px 0; padding: 14px 16px; border: 1px dashed var(--brass-dim); border-radius: 6px; }
.done-card p { margin: 0 0 12px; }
#my-games li.done .my-status { color: var(--good); }
#my-games li.closed { opacity: 0.55; }


/* developer credit */
.credit { margin: 28px 0 8px; text-align: center; font-size: 14px; color: var(--sage); }
.credit a { color: var(--brass); }
.scr-credit { position: fixed; left: 1.2vw; bottom: 1vh; margin: 0; font-size: 0.9vw; color: var(--sage); opacity: 0.8; }
.scr-credit a { color: var(--brass); }

/* ---------- plans, unlock codes ---------- */
.in-app .web-only { display: none !important; }
.free-note { margin: 16px 0 0; padding: 12px 14px; border: 1px dashed var(--brass-dim); border-radius: 6px; font-size: 14.5px; color: var(--sage); text-align: center; }
.free-note b { color: var(--ivory); }
.tag-free { color: var(--good); white-space: nowrap; }
.tag-lock { color: var(--brass); white-space: nowrap; }
.case-option.locked > span { opacity: 0.55; }
.case-option.locked input { cursor: not-allowed; }
.unlock-box { margin-top: 4px; }
.unlock-input { font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.unlock-msg { min-height: 1.3em; margin: 8px 0 0; font-size: 14px; color: var(--sage); }
.unlock-msg.good { color: var(--good); }
.unlock-msg .bad, .bad { color: var(--alarm); }
.plan-line { margin: 0 0 8px; color: var(--sage); }
.plan-line b { color: var(--ivory); }
.lobby-unlock { margin: 0 0 6px; }
.plan-grid { display: grid; gap: 14px; margin: 18px 0 8px; }
@media (min-width: 760px) { .plan-grid.three { grid-template-columns: repeat(3, 1fr); } .plan-grid.four { grid-template-columns: repeat(2, 1fr); } }
.plan-card { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 18px 16px 16px; border: 1px solid var(--green-line); border-radius: 8px; background: rgba(0, 0, 0, 0.2); }
.plan-card.best { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass) inset; }
.plan-card h3 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 24px; }
.plan-card .price { margin: 2px 0 4px; font-family: var(--serif); font-size: 30px; color: var(--brass); }
.plan-card .price small { font-family: var(--type); font-size: 14px; color: var(--sage); }
.plan-card ul { margin: 4px 0 10px; padding-left: 1.1em; font-size: 14.5px; }
.plan-card .buy { display: grid; gap: 8px; margin-top: auto; }
.ribbon { position: absolute; top: -11px; right: 12px; padding: 2px 10px; border-radius: 999px; background: var(--brass); color: var(--green-deep); font-size: 12px; font-weight: 700; }
.email-row { max-width: 520px; margin: 0 auto; }
.code-reveal { margin: 18px 0; padding: 18px; border: 2px dashed var(--good); border-radius: 8px; text-align: center; }
.code-reveal .big-code { display: block; margin: 8px 0 12px; font-size: clamp(26px, 8vw, 38px); font-weight: 700; letter-spacing: 0.12em; color: var(--good); }
.wide { max-width: 980px; margin: 0 auto; padding-top: 18px; padding-bottom: 60px; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th, .data-table td { padding: 7px 8px; border-bottom: 1px solid var(--green-line); text-align: left; vertical-align: top; }
.data-table td .btn { min-height: 32px; padding: 4px 9px; font-size: 13px; }
.st-ready, .st-active { color: var(--good); }
.st-expired, .st-used, .st-revoked { color: var(--alarm); }
.legal h2 { margin-top: 26px; }
.legal li { margin-bottom: 6px; }
.o-nav { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; }

/* ---------- home, redesigned: everything important on the first screen ---------- */
.home { padding-top: 14px; }
.home-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.home .home-top .title { margin: 0; font-size: clamp(32px, 9vw, 44px); text-align: left; }
.home .home-top .inv-line { margin: 4px 0 0; font-size: 15px; }
.pill { flex: none; margin-top: 8px; padding: 6px 14px; border: 1px solid var(--brass-dim); border-radius: 999px; color: var(--brass); text-decoration: none; font-size: 14px; font-weight: 700; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { display: grid; align-content: start; gap: 2px; min-height: 104px; padding: 14px 12px; border: 1px solid var(--green-line); border-radius: 10px; background: rgba(0, 0, 0, 0.22); color: var(--ivory); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.tile:hover, .tile:focus-visible { border-color: var(--brass); }
.tile b { font-family: var(--serif); font-size: 18px; line-height: 1.15; }
.tile small { color: var(--sage); font-size: 13px; line-height: 1.3; }
.tile-ico { font-size: 26px; line-height: 1; margin-bottom: 4px; }
.tile-main { background: var(--brass); border-color: var(--brass); color: var(--green-deep); }
.tile-main small { color: #2b3a24; }
.tile-magic { border-color: #6b5aa8; background: linear-gradient(160deg, rgba(76, 58, 150, 0.45), rgba(0, 0, 0, 0.2)); }
.home .free-note { margin: 12px 0 0; padding: 9px 12px; font-size: 13.5px; }
.seg { display: flex; gap: 6px; margin: 18px 0 12px; padding: 4px; border: 1px solid var(--green-line); border-radius: 999px; overflow-x: auto; scrollbar-width: none; }
.seg button { flex: 1 0 auto; padding: 8px 12px; border: 0; border-radius: 999px; background: transparent; color: var(--sage); font: 700 14px var(--type); cursor: pointer; white-space: nowrap; }
.seg button[aria-selected='true'] { background: var(--brass-wash); color: var(--brass); box-shadow: inset 0 0 0 1px var(--brass-dim); }
.hpanel .chips { margin-bottom: 10px; }
.hpanel .small-note { margin-top: 0; }

/* compact case cards: two per row on phones */
.case-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.case-grid.compact .case-card { grid-template-columns: 1fr; gap: 6px; padding: 10px; border-left-width: 3px; }
.case-grid.compact .case-emoji { font-size: 26px; text-align: left; }
.case-grid.compact .case-text b { font-size: 16px; }
.case-grid.compact .case-text > span, .case-grid.compact .case-text > small:not(.case-meta) { display: none; }
.case-grid.compact .case-meta { font-size: 12px; line-height: 1.5; }
@media (min-width: 640px) { .case-grid.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* create: shorter case list, Create button always in reach */
.create-filter { margin-bottom: 8px; }
.case-pick { gap: 6px; }
.case-option > span { padding: 7px 10px; column-gap: 10px; grid-template-columns: 32px 1fr; }
.case-option .case-emoji { font-size: 22px; }
.case-option b { font-size: 16px; }
.case-option small { font-size: 12.5px; }
.sticky-cta { position: sticky; bottom: 0; z-index: 5; margin: 14px -18px 0; padding: 10px 18px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--green-deep) 70%, transparent); }
.hpanel .chips, .create-filter { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px; }
.hpanel .chip span, .create-filter .chip span { padding: 6px 12px; font-size: 13.5px; white-space: nowrap; }

/* what's free, spelled out */
.home .free-note { text-align: left; padding: 12px 14px; }
.free-note .fn-title { display: block; margin-bottom: 4px; color: var(--ivory); font-size: 14.5px; }
.free-note ul { margin: 0; padding-left: 1.1em; }
.free-note li { margin: 3px 0; }
.free-note .fn-more { display: inline-block; margin-top: 6px; font-weight: 700; }
.tag-trial { color: #f0b3ff; white-space: nowrap; }
.trial-note { margin: 8px 0 0; padding: 9px 12px; border: 1px dashed #b98bd6; border-radius: 6px; font-size: 14px; color: #f0d9ff; }

/* ---------- sound buttons ---------- */
.sound-toggle { width: 40px; height: 40px; border: 1px solid var(--green-line); border-radius: 50%; background: rgba(12, 24, 19, 0.8); color: var(--ivory); font-size: 17px; cursor: pointer; }
.sound-toggle[aria-pressed='true'] { border-color: var(--brass); box-shadow: 0 0 12px rgba(201, 162, 74, 0.45); }
.sound-fab { position: fixed; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 40; width: 46px; height: 46px; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4); }
.in-game-view .sound-fab { display: none; }
.sound-in-bar { width: 34px; height: 34px; font-size: 15px; }
.topbar { grid-template-columns: 1fr auto auto auto auto; }

/* ---------- atmosphere: drifting dust in lamplight, a flickering lamp ---------- */
.fog { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.fog i { position: absolute; bottom: -10px; width: 3px; height: 3px; border-radius: 50%; background: #f3d98e; box-shadow: 0 0 6px 2px rgba(201, 162, 74, 0.5); opacity: 0; animation: dust 22s linear infinite; }
.fog i:nth-child(1) { left: 12%; } .fog i:nth-child(2) { left: 30%; animation-delay: 5s; animation-duration: 26s; }
.fog i:nth-child(3) { left: 47%; animation-delay: 11s; } .fog i:nth-child(4) { left: 63%; animation-delay: 3s; animation-duration: 28s; }
.fog i:nth-child(5) { left: 79%; animation-delay: 15s; } .fog i:nth-child(6) { left: 92%; animation-delay: 8s; animation-duration: 24s; }
@keyframes dust { 0% { transform: translate(0, 0); opacity: 0; } 15% { opacity: 0.55; } 50% { transform: translate(24px, -50vh); } 85% { opacity: 0.35; } 100% { transform: translate(-16px, -104vh); opacity: 0; } }
body::before { animation: lamp 7s ease-in-out infinite alternate; }
@keyframes lamp { 0%, 100% { opacity: 1; } 45% { opacity: 0.93; } 50% { opacity: 0.97; } 55% { opacity: 0.9; } }

/* entrances */
.tiles .tile { animation: rise-in 0.45s ease both; }
.tiles .tile:nth-child(2) { animation-delay: 0.06s; } .tiles .tile:nth-child(3) { animation-delay: 0.12s; } .tiles .tile:nth-child(4) { animation-delay: 0.18s; }
.home-top, .free-note, .seg, .hpanel:not([hidden]), .narrow > *, .lobby-cols > * { animation: rise-in 0.45s ease both; }
@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.tile { transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s; }
.tile:hover { transform: translateY(-3px); box-shadow: 0 12px 26px -12px rgba(0, 0, 0, 0.7); }
.case-card { transition: transform 0.18s, border-color 0.18s; }
.case-card:hover { transform: translateY(-2px); }
.tile-magic .tile-ico { animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-6deg); } }
.room-code { animation: glow-text 3s ease-in-out infinite alternate; }
@keyframes glow-text { from { text-shadow: 0 0 0 transparent; } to { text-shadow: 0 0 18px rgba(201, 162, 74, 0.45); } }
.burst { position: fixed; z-index: 95; width: 0; height: 0; pointer-events: none; }
.burst span { position: absolute; left: 0; top: 0; color: #f3d98e; font-size: 16px; text-shadow: 0 0 8px var(--brass); animation: spark 1s ease-out forwards; }
@keyframes spark { from { transform: translate(-50%, -50%) scale(0.4); opacity: 1; } to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.1) rotate(140deg); opacity: 0; } }

/* ---------- desktop: use the width, no empty sides ---------- */
@media (min-width: 960px) {
  .home { max-width: 1180px; padding-top: 28px; }
  .home-cols { display: grid; grid-template-columns: minmax(360px, 440px) 1fr; gap: 36px; align-items: start; }
  .home-left { position: sticky; top: 20px; }
  .home-right .seg { margin-top: 0; }
  .case-grid.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tile { min-height: 118px; }

  #v-create.narrow { max-width: 1100px; }
  .create-grid { display: grid; grid-template-columns: minmax(340px, 420px) 1fr; column-gap: 36px; align-items: start; }
  .create-grid .cf-a { grid-column: 1; grid-row: 1; }
  .create-grid .cf-b { grid-column: 1; grid-row: 2; }
  .create-grid .cf-case { grid-column: 2; grid-row: 1 / span 2; }
  .create-grid .cf-case .case-pick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .create-grid .sticky-cta { position: static; margin: 14px 0 0; padding: 0; background: none; }

  .lobby { max-width: 1100px; }
  .lobby-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; align-items: start; }

  .game main { max-width: 920px; }
  .clue-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1300px) {
  .case-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .fog { display: none; }
}
