:root {
  --ink: #1c1917;
  --ink-soft: #57534e;
  --muted: #8a8178;
  --paper: #fdfaf4;
  --paper-edge: rgba(255, 255, 255, 0.65);
  --gold: #c9a227;
  --gold-soft: #e8c85a;
  --gold-deep: #9a7b1a;
  --burgundy: #8c2f43;
  --bg-1: #0e0b14;
  --bg-2: #1b1426;
  --bg-3: #2a1e38;
  --ring: rgba(201, 162, 39, 0.45);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-lg: 0 30px 60px -15px rgba(0, 0, 0, 0.55);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.12);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1000px 600px at 15% -10%, rgba(201, 162, 39, 0.16), transparent 60%),
    radial-gradient(900px 700px at 90% 0%, rgba(140, 47, 67, 0.22), transparent 55%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
  background-attachment: fixed;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--gold-soft);
  color: var(--ink);
}

.vignette {
  display: none;
}

.topbar,
.page,
.foot {
  position: relative;
  z-index: 1;
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 64rem;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  color: #f5efe4;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  color: inherit;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.brand:hover {
  opacity: 0.85;
}

.brand-mark {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-family: var(--font-display);
  color: #1c1408;
  background: linear-gradient(145deg, var(--gold-soft), var(--gold-deep));
  box-shadow: 0 4px 12px rgba(201, 162, 39, 0.35);
  letter-spacing: 0.02em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
}

.brand-text em {
  font-style: normal;
  opacity: 0.6;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.quit {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin: 0;
}

.player-name {
  color: var(--gold-soft);
  font-weight: 600;
  font-size: 0.9rem;
}

.quit button {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: #f5efe4;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.quit button:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
}

/* ---------- Layout ---------- */

.page {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1rem 1.25rem 4rem;
}

.page:has(.wide) {
  max-width: 60rem;
}

.panel {
  background: linear-gradient(180deg, #fffdf8 0%, var(--paper) 100%);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius);
  padding: 2.25rem 2rem 2.5rem;
  box-shadow: var(--shadow-lg);
  animation: panel-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Typography ---------- */

.kicker {
  margin: 0 0 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--burgundy);
}

h1 {
  margin: 0 0 0.9rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.lead {
  margin: 0 0 1.5rem;
  font-size: 1.02rem;
  color: var(--ink-soft);
  white-space: pre-wrap;
}

.quote {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: rgba(201, 162, 39, 0.08);
  font-family: var(--font-display);
  font-style: italic;
  color: var(--burgundy);
}

/* ---------- Forms ---------- */

.form {
  display: grid;
  gap: 1.1rem;
}

label {
  display: grid;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.9rem;
}

input[type="text"],
input[type="email"],
input[type="password"] {
  font: inherit;
  padding: 0.8rem 1rem;
  border: 1.5px solid #e0d8ca;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 4px var(--ring);
}

input::placeholder {
  color: #b8ae9f;
}

.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.85rem 1.4rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, var(--gold-soft), var(--gold-deep));
  color: #1c1408;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  box-shadow: 0 6px 16px rgba(154, 123, 26, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(154, 123, 26, 0.45);
  filter: brightness(1.05);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-ghost {
  background: #fff;
  color: var(--ink);
  border: 1.5px solid #e0d8ca;
  box-shadow: var(--shadow-sm);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--gold);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.1);
  filter: none;
}

.alert {
  background: #fdeeee;
  border: 1px solid #f0c4c4;
  border-radius: var(--radius-sm);
  color: #a8323e;
  padding: 0.8rem 1rem;
  font-size: 0.92rem;
}

.hint-muted,
.center {
  text-align: center;
}

.hint-muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.back {
  color: var(--gold-deep);
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.back:hover {
  border-color: var(--gold-deep);
}

/* ---------- Board tiles ---------- */

.tiles {
  list-style: none;
  padding: 0;
  margin: 1.75rem 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 9rem;
  padding: 1rem 0.5rem;
  text-decoration: none;
  color: inherit;
  background: #fff;
  border: 1.5px solid #e6ddcc;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

a.tile:hover {
  transform: translateY(-4px);
  border-color: var(--gold);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.14);
}

.tile.solved {
  background: linear-gradient(160deg, #fdf6dd, #f6e6ae);
  border-color: var(--gold);
}

.tile-n,
.tile-kind {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted);
}

.tile.solved .tile-n,
.tile.solved .tile-kind {
  color: var(--gold-deep);
}

.tile-letter {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1;
}

.tile-letter.mystery {
  opacity: 0.3;
}

/* ---------- Puzzle widgets ---------- */

.scrambled {
  font-family: var(--font-display);
  font-size: 1.8rem;
  letter-spacing: 0.4em;
  text-align: center;
  font-weight: 600;
  margin: 0 0 1.25rem;
  padding: 0.9rem;
  background: rgba(201, 162, 39, 0.08);
  border-radius: var(--radius-sm);
}

.choices {
  border: 0;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.7rem;
}

.choices legend {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.hints {
  margin-top: 1.6rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.hints ol {
  padding-left: 1.2rem;
  margin-top: 0.6rem;
}

.slider {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  width: 100%;
  max-width: 18rem;
  margin: 0 auto 1.25rem;
}

.slider button {
  aspect-ratio: 1;
  font: inherit;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  border: 1.5px solid #e0d8ca;
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.slider button:hover:not(.empty) {
  border-color: var(--gold);
  transform: scale(1.04);
}

.slider button.empty {
  background: transparent;
  border-style: dashed;
  box-shadow: none;
  cursor: default;
}

.seq-show {
  min-height: 4.5rem;
  display: grid;
  place-items: center;
  font-size: 3rem;
  margin-bottom: 1rem;
}

.seq-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.seq-buttons button {
  font-size: 1.7rem;
  width: 3.5rem;
  height: 3.5rem;
  border: 1.5px solid #e0d8ca;
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.seq-buttons button:hover {
  border-color: var(--gold);
  transform: scale(1.06);
}

.seq-status {
  text-align: center;
  font-style: italic;
  color: var(--muted);
}

.rebus {
  letter-spacing: 0.12em;
  font-size: 2.2rem;
}

.cipher {
  letter-spacing: 0.18em;
  font-size: 1.15rem;
  font-family: var(--font-body);
}

.phone {
  max-width: 17rem;
  margin: 0 auto 1.4rem;
  padding: 1.1rem 1rem 1.2rem;
  border-radius: 28px;
  background: linear-gradient(180deg, #2a2433, #16121c);
  box-shadow: var(--shadow-lg);
}

.phone-screen {
  min-height: 2.6rem;
  margin-bottom: 0.9rem;
  padding: 0.55rem 0.8rem;
  border-radius: 10px;
  background: #1a3328;
  color: #9fe8b8;
  font-family: ui-monospace, Menlo, monospace;
  letter-spacing: 0.28em;
  text-align: center;
  font-size: 1.15rem;
}

.phone-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  min-height: 12rem;
}

.phone-pad button {
  aspect-ratio: 1;
  min-height: 3.1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.05rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #4a4158, #2b2534);
  color: #f5efe4;
  cursor: pointer;
  box-shadow: 0 4px 0 #0c0a10;
  transition: transform 0.1s ease, filter 0.1s ease, box-shadow 0.1s ease;
}

.phone-pad button:hover {
  filter: brightness(1.12);
}

.phone-pad button:active,
.phone-pad button.lit {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #0c0a10;
  filter: brightness(1.35);
  border-color: var(--gold-soft);
}

.phone-digit {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}

.phone-letters {
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  opacity: 0.7;
  min-height: 0.7rem;
}

.mm-history {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.mm-row,
.mm-current {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.mm-peg,
.mm-peg-btn {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  border: 1.5px solid #d7ccb8;
  background: #f4eee3;
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.12);
}

.mm-peg.mark {
  width: 0.85rem;
  height: 0.85rem;
  border-color: #1c1917;
  box-shadow: none;
}

.mm-peg.pale {
  background: #fff;
  border: 2px solid #1c1917;
}

.mm-peg.empty {
  background: transparent;
  border: 1.5px dashed #cfc5b2;
}

.mm-marks {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.6rem;
  flex-wrap: nowrap;
}

.mm-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.mm-legend-peg {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  vertical-align: middle;
}

.mm-legend-well {
  background: #1c1917;
  border: 1.5px solid #1c1917;
}

.mm-legend-misplaced {
  background: #fff;
  border: 2px solid #1c1917;
}

.mm-status {
  color: var(--ink);
  font-style: normal;
  font-weight: 600;
}

.mm-peg-btn {
  padding: 0;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.mm-peg-btn.selected {
  box-shadow: 0 0 0 3px var(--ring);
  border-color: var(--gold);
}

.mm-palette {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.9rem 0 0.6rem;
}

.mm-palette .mm-peg-btn {
  width: 2.4rem;
  height: 2.4rem;
}

/* ---------- Guess & victory ---------- */

.revealed {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 1.4rem 0 1.7rem;
}

.revealed span {
  width: 2.8rem;
  height: 3.3rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: linear-gradient(160deg, #fdf6dd, #f6e6ae);
  border: 1.5px solid var(--gold);
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.victory h1 {
  font-size: clamp(2.1rem, 5vw, 2.8rem);
}

.hall-of-fame {
  margin: 2rem auto;
  max-width: 26rem;
}

.hall-of-fame h2 {
  font-family: var(--font-display);
  text-align: center;
  font-size: 1.3rem;
  margin-bottom: 0.75rem;
}

.winners {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
}

.winners li {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.55rem 0.9rem;
  background: rgba(201, 162, 39, 0.08);
  border: 1px solid rgba(201, 162, 39, 0.25);
  border-radius: var(--radius-sm);
}

.winners li:first-child {
  background: rgba(201, 162, 39, 0.18);
  border-color: var(--gold);
}

.winner-rank {
  font-family: var(--font-display);
  color: var(--gold-deep);
  font-weight: 700;
  min-width: 1.4rem;
}

.winner-name {
  font-weight: 600;
  flex: 1;
}

.winner-hints {
  color: var(--burgundy);
  font-size: 0.8rem;
  white-space: nowrap;
}

.winner-time {
  color: var(--muted);
  font-size: 0.85rem;
}

.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* ---------- Admin table ---------- */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid #ece4d4;
}

.register {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 0.94rem;
}

.register th {
  text-align: left;
  padding: 0.75rem 0.9rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  background: #faf6ee;
  border-bottom: 1px solid #ece4d4;
}

.register td {
  text-align: left;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid #f2ecdf;
}

.register tbody tr:last-child td {
  border-bottom: 0;
}

.register tbody tr {
  transition: background 0.15s ease;
}

.register tbody tr:hover {
  background: #fbf8f0;
}

.register tr.done {
  background: #f2f7e6;
}

.register tr.done:hover {
  background: #ecf3dc;
}

.letters {
  font-family: var(--font-display);
  letter-spacing: 0.25em;
  font-weight: 700;
}

/* ---------- Footer ---------- */

.foot {
  text-align: center;
  color: rgba(245, 239, 228, 0.45);
  padding: 0 1rem 2.5rem;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
}

/* ---------- Responsive & motion ---------- */

@media (max-width: 640px) {
  .tiles {
    grid-template-columns: repeat(2, 1fr);
  }

  .panel {
    padding: 1.6rem 1.25rem 1.9rem;
  }
}

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