@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Libre+Caslon+Display&display=swap");

:root {
  color-scheme: dark;
  --ink: #0a0f25;
  --ink-soft: #111936;
  --panel: rgba(20, 27, 55, 0.78);
  --panel-solid: #151d3b;
  --line: rgba(243, 228, 202, 0.16);
  --line-strong: rgba(243, 228, 202, 0.3);
  --cream: #f5eee3;
  --muted: #abaec1;
  --gold: #efb45e;
  --coral: #e88070;
  --pink: #d58ab1;
  --teal: #6fc2bd;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  font-family: "DM Sans", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--ink); }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--cream);
  background:
    radial-gradient(circle at 8% 4%, rgba(103, 81, 143, 0.22), transparent 34rem),
    radial-gradient(circle at 90% 90%, rgba(29, 112, 117, 0.16), transparent 38rem),
    var(--ink);
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }

button:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 24rem;
  height: 24rem;
  border-radius: 50%;
  filter: blur(100px);
  opacity: .12;
  pointer-events: none;
}

.ambient-one { top: 18%; left: -12rem; background: var(--pink); }
.ambient-two { right: -10rem; bottom: 5%; background: var(--teal); }

.site-header {
  position: sticky;
  z-index: 30;
  top: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 1rem;
  min-height: 72px;
  padding: 0 4vw;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 15, 37, 0.78);
  backdrop-filter: blur(22px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  width: fit-content;
  padding: 0;
  border: 0;
  background: none;
  font-family: "Libre Caslon Display", Georgia, serif;
  font-size: 1.35rem;
  cursor: pointer;
}

.brand-mark {
  position: relative;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(239, 180, 94, .65);
  border-radius: 50%;
  transform: rotate(-14deg);
}

.brand-mark::before, .brand-mark::after, .brand-mark i {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(111, 194, 189, .7);
  border-radius: 55% 45% 50% 50%;
}

.brand-mark::after { inset: 10px 3px; border-color: rgba(213, 138, 177, .65); transform: rotate(55deg); }
.brand-mark i { inset: 3px 12px; border-color: rgba(245, 238, 227, .55); transform: rotate(24deg); }

.mode-nav {
  position: fixed;
  z-index: 50;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: .25rem;
  padding: .3rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.025);
}

.mode-nav button {
  padding: .55rem .9rem;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.mode-nav button:hover, .mode-nav button.active { color: var(--cream); background: rgba(255,255,255,.08); }

.ai-status {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--muted);
  font-size: .78rem;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(239, 180, 94, .1);
}

.ai-status.live .status-dot { background: var(--teal); box-shadow: 0 0 0 4px rgba(111, 194, 189, .1); }

.header-actions { justify-self: end; display: flex; align-items: center; gap: 1.2rem; }
.language-control select {
  min-width: 6.8rem;
  padding: .42rem 1.8rem .42rem .65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--cream);
  background: #121832;
  cursor: pointer;
}
.gallery-link { color: var(--muted); font-size: .82rem; text-decoration: none; }
.gallery-link:hover, .gallery-link:focus-visible { color: var(--cream); }

#app { width: min(1440px, 100%); min-height: calc(100vh - 72px); margin: 0 auto; }

.home { padding: clamp(1.2rem, 4vw, 4rem); }

.hero {
  position: relative;
  min-height: min(620px, 74vh);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  padding: clamp(2rem, 6vw, 5.5rem);
  border: 1px solid var(--line);
  border-radius: 28px;
  background-image:
    linear-gradient(90deg, rgba(7, 12, 31, .96) 0%, rgba(7, 12, 31, .78) 32%, rgba(7, 12, 31, .12) 72%),
    linear-gradient(0deg, rgba(7, 12, 31, .92), transparent 45%),
    url("/assets/veilword-hero.png");
  background-size: cover;
  background-position: center;
  box-shadow: var(--shadow);
}

.hero-copy { position: relative; max-width: 610px; z-index: 2; }
.eyebrow { margin: 0 0 .8rem; color: var(--gold); font-size: .74rem; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; }

h1, h2, h3, p { margin-top: 0; }
h1, h2, .display { font-family: "Libre Caslon Display", Georgia, serif; font-weight: 400; }
h1 { max-width: 760px; margin-bottom: 1rem; font-size: clamp(3.4rem, 8vw, 7.4rem); line-height: .87; letter-spacing: -.055em; }
.hero h1 span { color: var(--gold); }
.lede { max-width: 520px; margin-bottom: 1.6rem; color: #d2cfda; font-size: clamp(1rem, 2vw, 1.25rem); line-height: 1.6; }

.deck-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .55rem;
  width: min(620px, 100%);
}
.deck-picker button {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  padding: .75rem .85rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  text-align: left;
  background: rgba(7, 12, 31, .5);
  cursor: pointer;
}
.deck-picker button:hover { border-color: var(--line-strong); color: var(--cream); }
.deck-picker button[aria-pressed="true"] { border-color: rgba(239,180,94,.68); color: var(--cream); background: rgba(239,180,94,.11); }
.deck-picker button > span:first-child { font-size: 1.1rem; line-height: 1.25; }
.deck-picker strong, .deck-picker small { display: block; }
.deck-picker strong { margin-bottom: .15rem; font-size: .85rem; }
.deck-picker small { color: var(--muted); font-size: .68rem; line-height: 1.35; }
.hero-deck-picker { margin: 0 0 1rem; }
.deck-picker.compact { width: min(460px, 45vw); }
.deck-picker.compact small { display: none; }

.button-row { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; }
.primary-button, .secondary-button, .danger-button, .text-button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: .8rem 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.primary-button { color: #1c1830; background: var(--gold); }
.primary-button:hover { transform: translateY(-2px); background: #f6c878; }
.secondary-button { border-color: var(--line-strong); background: rgba(255,255,255,.06); }
.secondary-button:hover { transform: translateY(-2px); border-color: rgba(245,238,227,.5); }
.danger-button { border-color: rgba(244, 129, 129, .52); color: #ffe2df; background: rgba(165, 55, 64, .28); }
.danger-button:hover { transform: translateY(-2px); border-color: rgba(255, 185, 177, .8); background: rgba(185, 65, 73, .4); }
.text-button { padding-inline: .5rem; color: var(--muted); background: transparent; }
.text-button:hover { color: var(--cream); }
button:disabled { opacity: .46; cursor: not-allowed; transform: none !important; }

.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 1.2rem; }
.mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 210px;
  overflow: hidden;
  padding: 1.4rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(255,255,255,.055), rgba(255,255,255,.015));
}
.mode-card::after { content: attr(data-index); position: absolute; right: 1rem; bottom: -.8rem; color: rgba(245,238,227,.035); font: 7rem/1 "Libre Caslon Display", serif; }
.mode-card h2 { margin-bottom: .5rem; font-size: 1.65rem; }
.mode-card p { max-width: 32rem; color: var(--muted); line-height: 1.55; }
.mode-card button { position: relative; z-index: 1; align-self: flex-start; margin-top: auto; }

.how-to {
  display: grid;
  grid-template-columns: minmax(240px, .8fr) minmax(0, 1.2fr);
  gap: clamp(1.2rem, 4vw, 4rem);
  align-items: center;
  margin-top: 1.2rem;
  padding: clamp(1.4rem, 3vw, 2.4rem);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,.025);
}
.how-to h2 { margin-bottom: .5rem; font-size: clamp(2rem, 4vw, 3.2rem); }
.how-to-intro > p:last-child { margin-bottom: 0; color: var(--muted); line-height: 1.55; }
.rule-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; margin: 0; padding: 0; list-style: none; }
.rule-grid li { padding: 1rem; border: 1px solid var(--line); border-radius: 14px; background: rgba(5,9,25,.35); }
.rule-grid strong, .rule-grid span { display: block; }
.rule-grid strong { margin-bottom: .35rem; font-family: "Libre Caslon Display", Georgia, serif; font-size: 1.35rem; }
.rule-grid span { color: var(--muted); font-size: .75rem; line-height: 1.45; }
.rule-grid .sweet-spot { border-color: rgba(239,180,94,.55); background: rgba(239,180,94,.08); }
.rule-grid .sweet-spot strong { color: var(--gold); }

.game-shell { padding: clamp(1rem, 3.2vw, 3rem); }
.game-topline { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 1.5rem; }
.game-topline h1 { margin: .1rem 0 0; font-size: clamp(2.4rem, 5vw, 4.7rem); }
.game-title { display: flex; flex-direction: column; align-items: flex-start; }
.reset-button { margin-top: .5rem; padding: .48rem .78rem; color: var(--muted); font-size: .75rem; }
.round-chip { display: inline-flex; gap: .5rem; align-items: center; padding: .5rem .8rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .82rem; }

.scoreboard { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; min-width: min(640px, 56vw); }
.score-person { display: flex; align-items: center; gap: .65rem; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.025); }
.score-person.storyteller { border-color: rgba(239,180,94,.55); background: rgba(239,180,94,.07); }
.score-mark { display: grid; place-items: center; flex: 0 0 32px; height: 32px; border-radius: 50%; color: var(--person-color); background: color-mix(in srgb, var(--person-color) 12%, transparent); }
.score-copy { min-width: 0; }
.score-copy strong, .score-copy small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-copy strong { font-size: .85rem; }
.score-copy small { color: var(--muted); font-size: .67rem; }
.score-value { margin-left: auto; font: 1.25rem "Libre Caslon Display", serif; }

.stage {
  padding: clamp(1.1rem, 3vw, 2.6rem);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.stage-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-end; margin-bottom: 1.4rem; }
.stage-head h2 { margin-bottom: .35rem; font-size: clamp(2rem, 4vw, 3.3rem); }
.stage-head p { margin-bottom: 0; color: var(--muted); line-height: 1.5; }
.clue-display { max-width: 100%; padding: .8rem 1rem; border-left: 2px solid var(--gold); color: var(--cream); font: clamp(1.4rem, 3vw, 2.3rem)/1.25 "Libre Caslon Display", serif; text-wrap: balance; }

.card-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: clamp(.55rem, 1.3vw, 1rem); }
.card-grid.candidates { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 980px; margin-inline: auto; }
.card-button {
  position: relative;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: transparent;
  cursor: pointer;
  transition: transform .2s ease, filter .2s ease;
}
.card-button:hover { transform: translateY(-6px) rotate(-.4deg); filter: brightness(1.08); }
.card-button.revealed:disabled { opacity: 1; }
.card-button.selected { transform: translateY(-9px); }
.card-button.selected::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 2px solid var(--gold);
  border-radius: 22px;
  box-shadow: 0 0 0 5px rgba(239, 180, 94, .12);
}
.card-button.correct::after { border-color: var(--teal); box-shadow: 0 0 0 5px rgba(111,194,189,.12); }
.card-button img { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 18px; box-shadow: 0 14px 34px rgba(0,0,0,.28); }
.card-index { position: absolute; left: .55rem; top: .55rem; z-index: 2; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: var(--cream); background: rgba(8,12,29,.76); font-size: .72rem; font-weight: 700; backdrop-filter: blur(8px); }
.card-owner { position: absolute; inset: auto .5rem .5rem; z-index: 2; padding: .45rem .55rem; border-radius: 10px; color: var(--cream); background: rgba(8,12,29,.84); font-size: .67rem; text-align: left; }

.clue-form { display: grid; grid-template-columns: 1fr auto; gap: .7rem; max-width: 760px; margin: 1.4rem auto 0; }
.clue-form input, .clue-form textarea {
  width: 100%;
  min-height: 50px;
  padding: .8rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 15px;
  color: var(--cream);
  background: rgba(5,9,25,.6);
}

.thinking { display: grid; place-items: center; min-height: 420px; text-align: center; }
.mind-orbit { position: relative; width: 112px; height: 112px; margin-bottom: 1.4rem; border: 1px solid var(--line-strong); border-radius: 50%; animation: orbit 4s linear infinite; }
.mind-orbit::before, .mind-orbit::after { content: ""; position: absolute; border: 1px solid var(--teal); border-radius: 50%; }
.mind-orbit::before { inset: 16px -8px; transform: rotate(55deg); }
.mind-orbit::after { inset: -8px 16px; border-color: var(--pink); transform: rotate(-55deg); }
@keyframes orbit { to { transform: rotate(360deg); } }
.thinking h2 { margin-bottom: .4rem; font-size: 2.2rem; }
.thinking p { color: var(--muted); }

.reveal-summary { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 1.2rem; align-items: start; margin-top: 1.2rem; }
.round-verdict { padding: 1.4rem; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.025); }
.round-verdict .big-number { color: var(--gold); font: 4rem/1 "Libre Caslon Display", serif; }
.round-verdict p { color: var(--muted); line-height: 1.55; }
.mind-details { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.025); }
.mind-details summary { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: 1.15rem; cursor: pointer; list-style: none; }
.mind-details summary::-webkit-details-marker { display: none; }
.mind-details summary span:first-child, .mind-details summary small { display: block; }
.mind-details summary small { margin-top: .25rem; color: var(--muted); font-weight: 400; }
.mind-details[open] summary { border-bottom: 1px solid var(--line); }
.mind-details[open] summary > span:last-child { transform: rotate(45deg); }
.mind-details .mind-notes { padding: .65rem; }
.mind-notes { display: grid; gap: .65rem; }
.mind-note { display: grid; grid-template-columns: auto 1fr auto; gap: .8rem; align-items: start; padding: .9rem; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.025); }
.mind-note .score-mark { margin-top: .1rem; }
.mind-note p { margin: .25rem 0 0; color: var(--muted); font-size: .86rem; line-height: 1.45; }
.point-pill { padding: .35rem .55rem; border-radius: 999px; color: var(--gold); background: rgba(239,180,94,.1); font-size: .75rem; }
.reveal-actions { display: flex; justify-content: flex-end; margin-top: 1.2rem; }

.training-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.2rem; align-items: start; }
.stats-card { position: sticky; top: 92px; padding: 1.2rem; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.025); }
.stats-card h3 { font-family: "Libre Caslon Display", serif; font-size: 1.5rem; }
.stat-row { display: flex; justify-content: space-between; padding: .6rem 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.stat-row strong { color: var(--cream); }
.calibration { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin: 1rem 0; }
.calibration span { padding: .75rem .5rem; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); text-align: center; font-size: .75rem; }
.calibration span.active { border-color: var(--gold); color: var(--cream); background: rgba(239,180,94,.08); }

.daily-meta { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1.2rem; }
.meta-chip { padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .78rem; }

.complete { max-width: 780px; margin: 0 auto; text-align: center; }
.complete h2 { font-size: clamp(3rem, 7vw, 6rem); line-height: .95; }
.final-standings { display: grid; gap: .6rem; margin: 2rem 0; text-align: left; }
.final-row { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 14px; }
.final-row:first-child { border-color: rgba(239,180,94,.55); background: rgba(239,180,94,.07); }
.final-rank { color: var(--muted); font: 1.3rem "Libre Caslon Display", serif; }
.final-score { color: var(--gold); font: 1.4rem "Libre Caslon Display", serif; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: 1.4rem; transform: translate(-50%, 120px); padding: .75rem 1rem; border: 1px solid var(--line-strong); border-radius: 999px; background: #18203f; box-shadow: var(--shadow); opacity: 0; transition: .25s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.confirm-dialog { width: min(92vw, 460px); padding: 0; border: 1px solid var(--line-strong); border-radius: 22px; color: var(--cream); background: #111832; box-shadow: 0 28px 90px rgba(0,0,0,.65); }
.confirm-dialog::backdrop { background: rgba(3, 6, 18, .76); backdrop-filter: blur(6px); }
.confirm-dialog-card { padding: clamp(1.3rem, 4vw, 2rem); }
.confirm-dialog h2 { margin-bottom: .65rem; font-size: clamp(2rem, 6vw, 3rem); }
.confirm-dialog p:not(.eyebrow) { margin-bottom: 1.4rem; color: var(--muted); line-height: 1.55; }
.confirm-dialog-actions { justify-content: flex-end; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

@media (max-width: 980px) {
  .mode-nav { top: auto; bottom: 14px; background: rgba(10,15,37,.92); box-shadow: 0 8px 30px rgba(0,0,0,.45); }
  .ai-status span:last-child { display: none; }
  .header-actions { gap: .65rem; }
  .how-to { grid-template-columns: 1fr; gap: 1rem; }
  .mode-grid { grid-template-columns: 1fr; }
  .game-topline { display: block; }
  .deck-picker.compact { width: min(620px, 100%); margin-top: 1rem; }
  .deck-picker.compact small { display: block; }
  .scoreboard { min-width: 0; margin-top: 1rem; }
  .training-layout, .reveal-summary { grid-template-columns: 1fr; }
  .stats-card { position: static; }
}

@media (max-width: 720px) {
  .site-header { min-height: 62px; padding-inline: 1rem; }
  .brand { font-size: 1.15rem; }
  .brand-mark { width: 25px; height: 25px; }
  .language-control select { min-width: 0; max-width: 7.2rem; }
  #app { min-height: calc(100vh - 62px); padding-bottom: 74px; }
  .home, .game-shell { padding: .8rem; }
  .hero { min-height: 560px; padding: 1.4rem; border-radius: 20px; background-position: 62% center; }
  .hero h1 { font-size: clamp(3.2rem, 18vw, 5.2rem); }
  .deck-picker { grid-template-columns: 1fr; }
  .how-to { padding: 1.1rem; }
  .rule-grid { grid-template-columns: 1fr; }
  .rule-grid li { display: grid; grid-template-columns: 90px 1fr; align-items: center; padding: .75rem .9rem; }
  .rule-grid strong { margin: 0; font-size: 1.1rem; }
  .stage { padding: .9rem; border-radius: 18px; }
  .stage-head { display: block; }
  .reveal-head { margin-bottom: 1rem; }
  .clue-display { padding: .55rem .7rem; font-size: clamp(1.35rem, 7vw, 1.9rem); overflow-wrap: normal; }
  .scoreboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .score-person { padding: .55rem .65rem; }
  .score-copy strong { font-size: .78rem; }
  .score-copy small { font-size: .6rem; }
  .score-value { font-size: 1.1rem; }
  .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card-grid.candidates { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-button img { border-radius: 12px; }
  .card-owner { inset: auto .35rem .35rem; padding: .35rem .4rem; font-size: .58rem; line-height: 1.25; }
  .clue-form { grid-template-columns: 1fr; }
  .score-person { border-radius: 10px; }
  .calibration { grid-template-columns: 1fr; }
  .mind-details summary { padding: .9rem; }
  .mind-note { grid-template-columns: auto minmax(0, 1fr) auto; gap: .55rem; padding: .75rem; }
  .mind-note p { font-size: .78rem; }
  .reveal-actions { position: static; }
  .reveal-actions .primary-button { width: 100%; box-shadow: 0 12px 32px rgba(0,0,0,.42); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
