:root {
  /* Palette extracted from the physical game's art (box cover, tablet, word card) */
  --bg: #000000;
  --bg-card: #241d15;
  --surface: #17130d;
  --surface-2: #362718;
  --bronze: #9c6530;
  --gold: #d8c090;
  --tan: #e0b080;
  --tan-dark: #c09060;
  --ink: #26190e;
  --red: #7a2a12;
  --red-bright: #a83d1c;
  --text: #f0e4cf;
  --text-dim: #b7a488;
  --border: #4a3420;
  --success: #5c8a3d;
  --danger: #b23a24;
  --font-title: 'Diogenes', Georgia, serif;
  --font-body: 'League Spartan', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

@font-face {
  font-family: 'Diogenes';
  src: url('assets/fonts/Diogenes.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'League Spartan';
  src: url('assets/fonts/LeagueSpartan-Bold.woff2') format('woff2'),
       url('assets/fonts/LeagueSpartan-Bold.woff') format('woff');
  font-weight: 400 700;
  font-display: swap;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 1.3rem 1.2rem 0.7rem;
}
.app-header img.publisher-logo {
  justify-self: start;
  width: 52px;
  height: 52px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
  transform: translateY(-5px); /* logo art sits low within its square canvas */
}
.app-header h1 {
  justify-self: center;
  margin: 0;
  font-family: var(--font-title);
  letter-spacing: 0.03em;
  color: var(--gold);
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
  font-size: 1.7rem;
  line-height: 52px;
  font-weight: 400;
  white-space: nowrap;
}
.rules-btn {
  justify-self: end;
  background: transparent;
  border: 1px solid var(--bronze);
  color: var(--gold);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.rules-btn:active { transform: scale(0.96); }

/* ---------- Rules modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 200;
}
.modal-backdrop.hidden { display: none !important; }
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.3rem 1.4rem 1.6rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.6rem;
  position: sticky;
  top: -1.3rem;
  background: var(--bg-card);
  padding-top: 0.2rem;
}
.modal-header h2 { margin: 0; text-align: left; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.9rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.2rem;
  flex-shrink: 0;
}
.modal-close:active { color: var(--gold); }
.modal-body h3 {
  color: var(--bronze);
  font-size: 1rem;
  margin: 1.1rem 0 0.4rem;
}
.modal-body h3:first-child { margin-top: 0; }
.modal-body ul {
  padding-left: 1.2rem;
  margin: 0.3rem 0;
}
.modal-body ul ul { margin-top: 0.3rem; }
.modal-body li {
  margin-bottom: 0.45rem;
  line-height: 1.5;
  font-size: 0.92rem;
}
.modal-credit {
  margin: 1.3rem 0 0;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.modal-credit a { color: var(--text-dim); text-decoration: underline; }
.modal-credit a:hover { color: var(--gold); }

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 1rem 2rem;
}

.screen { display: none; width: 100%; max-width: 480px; }
.screen.active { display: block; }
.screen-wide { max-width: 620px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

h2 { font-family: var(--font-title); font-weight: 400; letter-spacing: 0.02em; color: var(--gold); margin-top: 0; text-align: center; font-size: 1.5rem; }
h3 { color: var(--bronze); border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }

label {
  display: block;
  margin: 0.8rem 0 0.3rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

input, textarea, select {
  width: 100%;
  padding: 0.7rem;
  font-size: 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}
textarea { resize: vertical; }

.btn {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.85rem;
  font-size: 1.05rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: bold;
  transition: transform 0.05s ease-in-out, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: linear-gradient(180deg, var(--red-bright), var(--red)); color: #fff2e6; }
.btn-secondary { background: var(--surface-2); color: var(--gold); border: 1px solid var(--bronze); }
.btn-link { background: none; color: var(--text-dim); text-decoration: underline; font-weight: normal; }

.hint { color: var(--text-dim); font-size: 0.9rem; text-align: center; }
.hidden { display: none !important; }

.room-code {
  font-size: 2.6rem;
  letter-spacing: 0.3em;
  text-align: center;
  color: var(--gold);
  font-weight: bold;
  margin: 0.5rem 0;
}

.player-list, .status-list, .clue-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
}
.player-list li, .status-list li {
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  border-radius: 8px;
  margin-bottom: 0.4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.player-list.selectable li { cursor: pointer; border: 1px solid var(--border); }
.player-list.selectable li:active { background: var(--surface-2); }

.tag { font-size: 0.75rem; color: var(--bronze); border: 1px solid var(--bronze); border-radius: 20px; padding: 0.1rem 0.5rem; }
.tag.locked { color: var(--success); border-color: var(--success); }
.tag.unsure { color: var(--danger); border-color: var(--danger); }

.secret-word {
  text-align: center;
  font-size: 1.7rem;
  color: #fff;
  background: var(--surface);
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 1.2rem 0.6rem;
  margin: 0.6rem 0;
  font-weight: bold;
}
.other-words { text-align: center; font-size: 0.85rem; color: var(--text-dim); }

.big-emoji { font-size: 3rem; text-align: center; margin: 0.5rem 0; }
.progress-text { text-align: center; font-size: 1.1rem; color: var(--bronze); }

.feedback { min-height: 1.2rem; font-size: 0.85rem; color: var(--danger); margin-top: 0.3rem; }
.feedback .warn { color: var(--bronze); display: block; }
.feedback .err { color: var(--danger); display: block; }

.host-panel {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}

.winner-line { text-align: center; font-size: 1.2rem; color: var(--gold); font-weight: bold; }

.clue-list li {
  background: var(--surface);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.4rem;
}
.clue-list .clue-author { color: var(--bronze); font-size: 0.8rem; display: block; }

#toast {
  position: fixed;
  top: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: white;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  z-index: 100;
  display: none;
  max-width: 90vw;
  text-align: center;
}
#toast.toast-info { background: var(--bronze); color: var(--bg); }

.scoreboard-strip {
  width: 100%;
  max-width: 480px;
  margin-bottom: 0.75rem;
  overflow-x: auto;
}
#scoreboard-strip-inner {
  display: flex;
  gap: 0.5rem;
  padding: 0 0.1rem 0.2rem;
}
.player-chip {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.3rem 0.5rem 0.3rem 0.8rem;
  font-size: 0.85rem;
  white-space: nowrap;
  color: var(--text);
  flex-shrink: 0;
}
.player-chip.offline { opacity: 0.5; }
.player-chip.offline .chip-name::after { content: ' (offline)'; font-size: 0.7rem; color: var(--danger); }

.big-alert {
  background: var(--danger);
  color: #fff;
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  font-weight: bold;
  font-size: 1.05rem;
  margin-bottom: 1rem;
  animation: pulse-alert 1.4s ease-in-out infinite;
}
@keyframes pulse-alert {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.6); }
  50% { box-shadow: 0 0 0 10px rgba(192, 57, 43, 0); }
}

.first-guesser-banner {
  background: var(--surface);
  border: 1px solid var(--gold);
  color: var(--gold);
  border-radius: 10px;
  padding: 0.7rem;
  text-align: center;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.chip-score {
  background: var(--gold);
  color: var(--bg);
  border-radius: 50%;
  min-width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.8rem;
}

/* ---------- Hero cover (landing) ---------- */
.hero-cover {
  display: block;
  width: 100%;
  max-width: 260px;
  margin: 0 auto 1rem;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

/* ---------- Word card (front, HTML) ---------- */
.word-card {
  background: linear-gradient(180deg, var(--tan), var(--tan-dark));
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
}
.word-card ol {
  list-style: none;
  counter-reset: word-card-counter;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 0.8rem;
}
.word-card li {
  counter-increment: word-card-counter;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
}
.word-card li::before {
  content: counter(word-card-counter) ". ";
  font-weight: 700;
}
.word-card li.active {
  color: var(--danger);
  position: relative;
  display: inline;
  border: 2px solid var(--danger);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  transform: rotate(-1.5deg);
  box-shadow: 0 0 0 1px rgba(184, 40, 26, 0.15);
}
.word-card.selectable li { cursor: pointer; }
.word-card.selectable li:active { opacity: 0.7; }

/* ---------- Tablet (image-backed component) ---------- */
.tablet {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background-size: cover;
  background-position: center;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.45);
  margin: 0 auto;
  container-type: inline-size;
}
.tablet-front { background-image: url('assets/tablet-front.png'); }
.tablet-back { background-image: url('assets/tablet-back.png'); }

.tablet-lg { max-width: 480px; }
.tablet-md { max-width: 220px; }
.tablet-sm { max-width: 130px; flex-shrink: 0; }

.tablet-writing-area {
  position: absolute;
  left: 8%;
  top: 17%;
  width: 84%;
  height: 76%;
  border: none;
  background: transparent;
  resize: none;
  color: var(--ink);
  font-family: 'Segoe Print', 'Bradley Hand', Georgia, cursive;
  font-size: clamp(0.85rem, 8.5cqw, 1.6rem);
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  padding: 0.5rem;
}
.tablet-writing-area:focus { outline: none; }
.tablet-writing-area::placeholder { color: rgba(42, 28, 14, 0.45); }

.tablet-reveal-text {
  position: absolute;
  left: 8%;
  top: 17%;
  width: 84%;
  height: 76%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--ink);
  font-family: 'Segoe Print', 'Bradley Hand', Georgia, cursive;
  font-size: clamp(0.9rem, 10cqw, 1.7rem);
  font-weight: 700;
  line-height: 1.3;
  padding: 0.5rem;
}

.tablet-count {
  position: absolute;
  top: 37%;
  transform: translate(-50%, -50%);
  font-weight: 800;
  font-size: clamp(0.9rem, 13cqw, 1.6rem);
  color: var(--ink);
  font-family: Georgia, serif;
}
.tablet-count-left { left: 20%; }
.tablet-count-right { left: 85%; }
.tablet-count.blank::after { content: '?'; opacity: 0.35; }

.mini-tablet-row {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding: 0.5rem 0.1rem 1rem;
}

/* ---------- Word card back, propped in a stand ---------- */
.card-stand-wrap {
  display: flex;
  justify-content: center;
  padding: 0.5rem 0 1.5rem;
}
.card-stand {
  width: 150px;
  transform: rotate(-2deg);
  filter: drop-shadow(0 12px 18px rgba(0,0,0,0.5));
}
.card-stand img { width: 100%; display: block; border-radius: 6px; }
.card-stand::after {
  content: '';
  display: block;
  width: 70%;
  height: 10px;
  margin: 0 auto;
  background: linear-gradient(180deg, var(--border), var(--bg-card));
  border-radius: 0 0 6px 6px;
  transform: perspective(30px) rotateX(25deg);
}

/* ---------- Round-end clue cards ---------- */
.round-end-clue-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  margin: 0.5rem 0 1rem;
}
.round-end-clue-card { width: 100%; max-width: 260px; text-align: center; margin-bottom: 0.8rem; }
.round-end-clue-card .clue-author { color: var(--gold); font-weight: bold; margin-bottom: 0.3rem; }
.round-end-clue-card .clue-meta { color: var(--text-dim); font-size: 0.8rem; margin-top: 0.3rem; }

/* ---------- Footer ---------- */
.app-footer {
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}
.app-footer a {
  color: var(--text-dim);
  text-decoration: underline;
}
.app-footer a:hover { color: var(--gold); }
.app-footer-sep { margin: 0 0.5rem; opacity: 0.6; }
