*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button, input { touch-action: manipulation; }  /* kill iOS double-tap zoom / ghost clicks */

:root {
  --bg: #f5eed8;
  --paper: #ede4c4;
  --paper2: #e4d9b0;
  --ink: #1a1408;
  --ink2: #3a2e1a;
  --faded: #8a7a58;
  --red: #b01a1a;
  --stamp-red: rgba(176,26,26,0.82);
  --stamp-blue: rgba(24,62,120,0.78);
  --accent: #b01a1a;
  --border: #c4b48a;
  --mole: #b01a1a;
  --agent: #183e78;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'DM Mono', monospace;
  font-weight: 300;
}

html { overflow: hidden; }  /* keep iOS bounce/ghost-tap guard on the viewport */

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 24px;
  position: relative;
  overflow-y: auto;            /* body scrolls when a screen is taller than the viewport */
  overflow-x: hidden;
  overscroll-behavior-y: contain;  /* preserve the bounce-kill on the scrollable body */
}

/* Paper texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 28px, rgba(160,140,90,0.06) 28px, rgba(160,140,90,0.06) 29px),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 100;
}

/* Corner marks — classified document feel */
body::after {
  content: '';
  position: fixed;
  inset: 12px;
  border: 1px solid rgba(160,140,90,0.25);
  pointer-events: none;
  z-index: 99;
}

/* Screens */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  margin: auto 0;  /* centers when there's room, scrolls-to-top when taller than viewport */
  animation: fadeIn 0.35s ease;
}
.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── STAMPS ── */
.stamp {
  display: inline-block;
  font-family: 'Special Elite', serif;
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 5px 12px;
  border: 2.5px solid currentColor;
  border-radius: 3px;
  transform: rotate(-4deg);
  opacity: 0.82;
  line-height: 1.3;
}
.stamp-red  { color: var(--stamp-red);  }
.stamp-blue { color: var(--stamp-blue); }

.stamp-big {
  font-family: 'Special Elite', serif;
  font-size: clamp(28px, 8vw, 42px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 10px 20px;
  border: 4px solid currentColor;
  border-radius: 4px;
  transform: rotate(-6deg);
  display: inline-block;
  line-height: 1.2;
}

/* ── TYPOGRAPHY ── */
.classified-header {
  font-family: 'Special Elite', serif;
  font-size: 10px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--faded);
  margin-bottom: 6px;
  text-align: center;
}

h1 {
  font-family: 'Special Elite', serif;
  font-size: clamp(32px, 9vw, 50px);
  line-height: 1;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--ink);
  margin-bottom: 4px;
}

h2 {
  font-family: 'Special Elite', serif;
  font-size: clamp(18px, 5vw, 24px);
  letter-spacing: 0.06em;
  color: var(--ink);
  margin-bottom: 8px;
  text-align: center;
}

.subtitle {
  font-size: 12px;
  color: var(--faded);
  margin-bottom: 32px;
  line-height: 1.6;
  text-align: center;
  letter-spacing: 0.04em;
}

/* ── DOSSIER CARD ── */
.dossier {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 20px;
  width: 100%;
  margin-bottom: 12px;
  position: relative;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.08);
}

.dossier::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: repeating-linear-gradient(90deg, var(--red) 0, var(--red) 8px, transparent 8px, transparent 12px);
  opacity: 0.4;
}

.field-label {
  font-size: 9px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--faded);
  margin-bottom: 8px;
  font-family: 'DM Mono', monospace;
}

/* ── INPUTS ── */
input[type="text"] {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--border);
  padding: 10px 4px;
  color: var(--ink);
  font-family: 'Special Elite', serif;
  font-size: 18px;
  letter-spacing: 0.06em;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
input[type="text"]:focus { border-color: var(--ink); }
input[type="text"]::placeholder { color: var(--faded); font-size: 14px; }

/* ── BUTTONS ── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  border-radius: 2px;
  border: 2px solid var(--ink);
  font-family: 'Special Elite', serif;
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s;
  -webkit-tap-highlight-color: transparent;
  background: transparent;
  color: var(--ink);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.3; cursor: not-allowed; }

.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover:not(:disabled) { background: var(--ink2); }
.btn-secondary { background: transparent; color: var(--ink); }
.btn-danger  { background: var(--red); color: #fff; border-color: var(--red); }
.btn-sm { padding: 8px 14px; font-size: 12px; width: auto; }

/* ── AGENT LIST ── */
.agent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-bottom: 16px;
  max-height: 220px;
  overflow-y: auto;
}

.agent-chip {
  display: flex;
  align-items: center;
  background: var(--paper2);
  border: 1px solid var(--border);
  padding: 10px 14px;
  font-size: 13px;
  font-family: 'Special Elite', serif;
  letter-spacing: 0.05em;
  position: relative;
}
.agent-chip .num {
  font-size: 9px;
  color: var(--faded);
  margin-right: 10px;
  letter-spacing: 0.2em;
  min-width: 24px;
}
.agent-chip .name { flex: 1; }
.remove-btn { background: none; border: none; color: var(--faded); cursor: pointer; font-size: 16px; padding: 0 0 0 8px; }

/* ── TOGGLE ── */
.toggle-group {
  display: flex;
  border: 1.5px solid var(--border);
  overflow: hidden;
  width: 100%;
}
.toggle-option {
  flex: 1;
  padding: 10px 8px;
  text-align: center;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--faded);
  transition: all 0.18s;
  -webkit-tap-highlight-color: transparent;
  text-transform: uppercase;
}
.toggle-option.selected { background: var(--ink); color: var(--bg); }

/* ── CATEGORY GRID ── */
.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  margin-bottom: 12px;
}
.category-btn {
  padding: 10px 8px;
  background: var(--paper2);
  border: 1.5px solid var(--border);
  color: var(--ink2);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.18s;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  text-transform: uppercase;
}
.category-btn.selected { border-color: var(--ink); background: var(--ink); color: var(--bg); }

/* ── PASS SCREEN ── */
.pass-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  width: 100%;
}

.codename-display {
  font-family: 'Special Elite', serif;
  font-size: clamp(22px, 6vw, 32px);
  letter-spacing: 0.06em;
  color: var(--ink);
  line-height: 1.2;
  text-align: center;
}

.codename-prefix {
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--faded);
  display: block;
  margin-bottom: 4px;
}

/* ── DRAG TO REVEAL ── */
.reveal-stage {
  position: relative;
  width: 100%;
  border-radius: 2px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  margin-bottom: 16px;
  cursor: grab;
}
.reveal-stage:active { cursor: grabbing; }

.reveal-content {
  padding: 28px 20px 24px;
  text-align: center;
  background: var(--paper);
  border: 1px solid var(--border);
  position: relative;
}

.reveal-content::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: repeating-linear-gradient(90deg, var(--red) 0, var(--red) 8px, transparent 8px, transparent 12px);
  opacity: 0.4;
}

.role-badge {
  display: inline-block;
  font-family: 'Special Elite', serif;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 4px 12px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  margin-bottom: 18px;
  transform: rotate(-2deg);
}
.role-badge.mole  { color: var(--mole); }
.role-badge.agent { color: var(--agent); }

.briefing-label {
  font-size: 9px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--faded);
  margin-bottom: 10px;
}

.secret-word {
  font-family: 'Special Elite', serif;
  font-size: clamp(26px, 8vw, 40px);
  letter-spacing: 0.06em;
  line-height: 1;
  margin-bottom: 14px;
}
.secret-word.mole-word  { color: var(--mole); }
.secret-word.agent-word { color: var(--agent); }

.reveal-hint {
  font-size: 11px;
  color: var(--faded);
  line-height: 1.6;
  letter-spacing: 0.04em;
  font-style: italic;
}

/* REDACTED bars for dramatic effect */
.redacted {
  display: inline-block;
  background: var(--ink);
  color: transparent;
  border-radius: 1px;
  padding: 0 4px;
  font-size: inherit;
  line-height: 1.4;
  letter-spacing: 0.1em;
  user-select: none;
}

/* The sliding cover */
.reveal-cover {
  position: absolute;
  inset: 0;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.38s cubic-bezier(0.32, 0, 0.67, 0);
  will-change: transform;
  transform: translateY(0%);
}
.reveal-cover.dragging   { transition: none; }
.reveal-cover.snapping-back { transition: transform 0.48s cubic-bezier(0.22, 1, 0.36, 1); }

.cover-eyebrow {
  font-size: 9px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: rgba(245,238,216,0.35);
  margin-bottom: 4px;
}

.cover-stamp {
  font-family: 'Special Elite', serif;
  font-size: 20px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 8px 18px;
  border: 3px solid rgba(176,26,26,0.7);
  border-radius: 3px;
  color: rgba(176,26,26,0.7);
  transform: rotate(-5deg);
  line-height: 1.3;
  text-align: center;
}

.cover-instruction {
  font-size: 11px;
  color: rgba(245,238,216,0.45);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 8px;
  text-align: center;
}

.drag-caret {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 6px;
  animation: bob 1.6s ease-in-out infinite;
  opacity: 0.35;
}
.drag-caret i {
  display: block;
  width: 14px;
  height: 2px;
  background: var(--bg);
  border-radius: 2px;
}
.drag-caret i:nth-child(2) { width: 9px; }
.drag-caret i:nth-child(3) { width: 5px; }

@keyframes bob {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(5px); }
}

/* ── DESCRIPTION STAGE ── */
.stage-direction {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
}

.round-pip-row { display: flex; gap: 8px; margin-bottom: 28px; justify-content: center; }
.round-pip {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: transparent;
  transition: all 0.3s;
}
.round-pip.done   { background: var(--faded); border-color: var(--faded); }
.round-pip.active { background: var(--ink); border-color: var(--ink); }

.stage-round-label {
  font-size: 9px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--faded);
  margin-bottom: 10px;
}

.stage-codename {
  font-family: 'Special Elite', serif;
  font-size: clamp(26px, 7vw, 38px);
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  line-height: 1.1;
}

.stage-codename-prefix {
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--faded);
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}

.stage-instruction {
  font-size: 12px;
  color: var(--faded);
  line-height: 1.7;
  margin-bottom: 36px;
  max-width: 300px;
  letter-spacing: 0.03em;
}

/* ── VOTING ── */
.vote-option {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--paper2);
  border: 1.5px solid var(--border);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.18s;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
  margin-bottom: 8px;
}
.vote-option:active { transform: scale(0.98); }
.vote-option.selected { border-color: var(--red); background: rgba(176,26,26,0.06); }

.vote-num {
  font-size: 11px;
  color: var(--faded);
  letter-spacing: 0.15em;
  min-width: 28px;
}
.vote-codename { font-family: 'Special Elite', serif; font-size: 16px; letter-spacing: 0.04em; flex: 1; }

/* ── RESULT ── */
.result-block { text-align: center; padding: 20px 0 16px; width: 100%; }

.result-stamp-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.result-verdict {
  font-family: 'Special Elite', serif;
  font-size: 13px;
  color: var(--faded);
  line-height: 1.7;
  margin-bottom: 20px;
  letter-spacing: 0.03em;
}

.tally-wrap { width: 100%; display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.tally-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--paper2);
  border: 1px solid var(--border);
  font-size: 13px;
  font-family: 'Special Elite', serif;
  letter-spacing: 0.04em;
}
.tally-row.is-mole { border-color: var(--red); background: rgba(176,26,26,0.06); }
.tally-row .t-name { flex: 1; }
.tally-row .t-votes { font-size: 11px; color: var(--faded); letter-spacing: 0.1em; }
.tally-row.is-mole .t-votes { color: var(--red); }

.divider { width: 100%; height: 1px; background: var(--border); margin: 14px 0; }
.spacer  { height: 16px; }

.secret-reveal-box {
  background: var(--ink);
  color: var(--bg);
  padding: 18px 20px;
  text-align: center;
  margin-bottom: 14px;
  position: relative;
}
.secret-reveal-label {
  font-size: 9px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(245,238,216,0.45);
  margin-bottom: 8px;
}
.secret-reveal-word {
  font-family: 'Special Elite', serif;
  font-size: 28px;
  letter-spacing: 0.08em;
  color: var(--bg);
}
