:root{
  --bg: #17130E;
  --surface: #221B12;
  --surface-2: #2C2317;
  --line: #423523;
  --bone: #EDE3CC;
  --bone-dim: #A99878;
  --ochre: #C9862B;
  --ochre-bright: #E4A94F;
  --rust: #A6412A;
  --rust-bright: #C85535;
  --focus: #E4A94F;

  --font-display: "Fraunces", serif;
  --font-mono: "IBM Plex Mono", monospace;
  --font-body: "Inter", sans-serif;
}

*{ box-sizing: border-box; }

/* the browser's built-in [hidden] rule loses to any author rule that sets
   display on the same element (e.g. .side-panel{display:flex}), so without
   this override, setting the `hidden` attribute from JS silently does nothing */
[hidden]{ display: none !important; }

html,body{
  margin:0; padding:0;
  min-height:100vh;
  background: var(--bg);
  color: var(--bone);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body{
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(201,134,43,0.08), transparent 60%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.012) 0px, rgba(255,255,255,0.012) 1px, transparent 1px, transparent 3px);
}

button{ font-family: inherit; }
input{ font-family: inherit; }

::selection{ background: var(--ochre); color: var(--bg); }

:focus-visible{
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ===== ambient circling vulture ===== */
.sky{
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.circler{
  position: absolute;
  top: 50%; left: 50%;
  width: 620px; height: 620px;
  transform: translate(-50%,-50%);
  opacity: 0.05;
  animation: circle-slow 90s linear infinite;
}
#vulture-shape{ fill: var(--ochre); }
@keyframes circle-slow{
  from{ transform: translate(-50%,-50%) rotate(0deg); }
  to{ transform: translate(-50%,-50%) rotate(360deg); }
}
@media (prefers-reduced-motion: reduce){
  .circler{ animation: none; }
}

#app{ position: relative; z-index: 1; }

/* ===== flying comments (niconico-style) ===== */
.comments-fly{
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 40;
  overflow: hidden;
}
.comment-fly{
  position: absolute;
  white-space: nowrap;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 22px;
  color: var(--bone);
  text-shadow: 0 1px 4px rgba(0,0,0,0.8), 0 0 12px rgba(0,0,0,0.5);
  will-change: transform;
}
.comment-fly.horizontal{
  animation: fly-across linear forwards;
}
@keyframes fly-across{
  from{ transform: translateX(0); }
  to{ transform: translateX(116vw); }
}
.comment-fly.vertical{
  writing-mode: vertical-rl;
  -webkit-writing-mode: vertical-rl;
  text-orientation: upright;
  animation: fly-down linear forwards;
}
@keyframes fly-down{
  from{ transform: translateY(-15vh); }
  to{ transform: translateY(120vh); }
}
@media (prefers-reduced-motion: reduce){
  .comment-fly{ animation: none !important; opacity: 0; }
}

/* ===== shared room header ===== */
.room-header{
  position: sticky; top: 0; z-index: 20;
  display:flex; align-items:center; justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(23,19,14,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.room-header-left{ position: relative; }
.room-code-btn{
  font-family: var(--font-mono);
  font-size: 15px; font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ochre-bright);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 6px 10px;
  cursor: pointer;
}
.room-code-btn:hover{ border-color: var(--ochre); }
.invite-popover{
  position: absolute; top: calc(100% + 6px); left: 0;
  z-index: 30;
  display:flex; gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px;
  box-shadow: 0 12px 24px rgba(0,0,0,0.4);
}
.invite-popover input{
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--bone);
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 3px;
  width: 190px;
}
.header-round{
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--bone-dim);
  letter-spacing: 0.08em;
  flex: 1;
  text-align: center;
}
.room-header-actions{ display:flex; gap: 6px; }
.btn-leave{ color: var(--rust-bright); border-color: var(--rust); }
.btn-leave:hover{ background: rgba(166,65,42,0.12); }

/* ===== side panels (chat / log) ===== */
.side-panel{
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 300px;
  max-width: 86vw;
  background: var(--surface);
  border-left: 1px solid var(--line);
  z-index: 25;
  display:flex; flex-direction: column;
  box-shadow: -12px 0 30px rgba(0,0,0,0.4);
}
.panel-head{
  display:flex; align-items:center; justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2{ font-family: var(--font-display); font-size: 18px; margin:0; }
.chat-log{ flex:1; overflow-y:auto; padding: 12px 14px; font-size: 13.5px; display:flex; flex-direction: column; gap:8px; }
.chat-log .msg-from{ color: var(--ochre-bright); font-weight: 600; margin-right: 4px; }
.log-list{ flex:1; overflow-y:auto; list-style: none; margin:0; padding: 10px 14px; display:flex; flex-direction: column; gap: 8px; }
.log-list li{ font-size: 12.5px; line-height: 1.6; color: var(--bone-dim); border-bottom: 1px dotted var(--line); padding-bottom: 8px; }
.log-list li strong{ color: var(--bone); font-weight: 600; }
.panel-foot{ padding: 10px 14px; border-top: 1px solid var(--line); display:flex; align-items:center; justify-content: space-between; gap: 8px; }
.chk{ display:flex; align-items:center; gap: 6px; font-size: 12px; color: var(--bone-dim); }
.export-hint{ padding: 0 14px 12px; font-size: 11.5px; color: var(--bone-dim); margin: 0; }

/* ===== bottom chat bar ===== */
.chat-bar{
  position: sticky; bottom: 0; z-index: 15;
  display:flex; align-items:center; gap: 8px;
  padding: 10px 14px;
  max-width: 640px;
  margin: 0 auto;
  background: rgba(23,19,14,0.94);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.chat-bar input#chat-input{
  flex:1;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--bone);
  border-radius: 3px;
  padding: 10px 12px;
  font-size: 14px;
}
.chat-vertical{ display:flex; align-items:center; gap: 4px; font-size: 11.5px; color: var(--bone-dim); white-space: nowrap; }

.entry-note{ margin-top: 18px; font-size: 12px; color: var(--bone-dim); }

.screen{
  display:none;
  min-height: 100vh;
  padding: 24px 18px 100px;
  max-width: 640px;
  margin: 0 auto;
  flex-direction: column;
}
.screen[data-active="true"]{ display: flex; }

/* ===== entry ===== */
#screen-entry{ justify-content: center; align-items: center; }
.entry-card{
  width: 100%;
  max-width: 420px;
  text-align: center;
}
.eyebrow{
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.28em;
  color: var(--bone-dim);
  margin: 0 0 10px;
}
.wordmark{
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: 56px;
  line-height: 1.05;
  margin: 0 0 14px;
  color: var(--bone);
}
.wordmark span{ color: var(--ochre-bright); font-style: italic; }
.tagline{
  color: var(--bone-dim);
  font-size: 14.5px;
  line-height: 1.7;
  margin: 0 0 32px;
}

.field{ text-align: left; margin-bottom: 22px; }
.field label{
  display:block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--bone-dim);
  margin-bottom: 8px;
}
.field input, .room-code-input{
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--bone);
  font-size: 16px;
  padding: 13px 14px;
  border-radius: 3px;
}
.field input::placeholder, .room-code-input::placeholder{ color: #6b5f47; }

.entry-actions{ display:flex; flex-direction: column; gap: 14px; }
.join-row{ display:flex; gap: 8px; }
.room-code-input{
  flex: 1;
  text-transform: uppercase;
  font-family: var(--font-mono);
  letter-spacing: 0.15em;
  text-align: center;
}

.entry-error{
  min-height: 18px;
  color: var(--rust-bright);
  font-size: 13px;
  margin-top: 14px;
}

/* ===== buttons ===== */
.btn{
  border: none;
  border-radius: 3px;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease, opacity 0.15s ease;
}
.btn:active{ transform: translateY(1px); }
.btn-primary{
  background: linear-gradient(180deg, var(--ochre-bright), var(--ochre));
  color: #1A1206;
}
.btn-primary:hover{ filter: brightness(1.08); }
.btn-primary:disabled{ opacity: 0.35; cursor: not-allowed; filter: none; }
.btn-ghost{
  background: transparent;
  color: var(--bone);
  border: 1px solid var(--line);
}
.btn-ghost:hover{ border-color: var(--ochre); color: var(--ochre-bright); }
.btn-wide{ width: 100%; }

/* ===== topbar / room badge ===== */
.topbar{
  display:flex; align-items:center; justify-content: space-between;
  margin-bottom: 22px;
}
.room-badge{
  display:flex; flex-direction: column; gap: 2px;
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 3px;
  background: var(--surface);
}
.room-badge.small{ padding: 6px 12px; }
.room-badge-label{ font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.15em; color: var(--bone-dim); }
.room-badge-code{ font-family: var(--font-mono); font-size: 20px; font-weight: 700; letter-spacing: 0.12em; color: var(--ochre-bright); }
.round-counter{
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--bone-dim);
  letter-spacing: 0.08em;
}

/* ===== lobby ===== */
.lobby-card{ flex: 1; display:flex; flex-direction: column; }
.section-title{
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 24px;
  margin: 0 0 16px;
}
.roster{ list-style:none; margin:0 0 16px; padding:0; display:flex; flex-direction: column; gap: 8px; }
.roster li{
  display:flex; align-items:center; justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 12px 14px;
  font-size: 14.5px;
}
.roster li .tag{
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--bg);
  background: var(--ochre-bright);
  padding: 2px 7px;
  border-radius: 2px;
  margin-left: 8px;
}
.roster li.offline{ opacity: 0.45; }
.lobby-hint{ color: var(--bone-dim); font-size: 13.5px; line-height: 1.7; margin: 0 0 24px; }
.waiting-note{ text-align:center; color: var(--bone-dim); font-size: 13px; margin-top: 12px; }

/* ===== game: prey stage ===== */
.scoreboard{
  display:flex; gap: 8px; overflow-x: auto;
  padding-bottom: 6px; margin-bottom: 18px;
}
.score-chip{
  flex: 0 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 8px 12px;
  min-width: 84px;
  text-align: center;
}
.score-chip.self{ border-color: var(--ochre); }
.score-chip .sc-name{ font-size: 11.5px; color: var(--bone-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100px; }
.score-chip .sc-score{ font-family: var(--font-mono); font-weight: 700; font-size: 18px; }
.score-chip .sc-score.pos{ color: var(--ochre-bright); }
.score-chip .sc-score.neg{ color: var(--rust-bright); }
.score-chip .sc-picked{ font-size: 10px; color: var(--bone-dim); margin-top: 2px; }
.score-chip .sc-hand{ font-size: 10px; color: var(--bone-dim); margin-top: 4px; font-family: var(--font-mono); word-break: break-word; }

.prey-stage{
  display:flex; flex-direction: column; align-items: center;
  padding: 20px 0 8px;
}
.prey-card{
  width: 148px; height: 200px;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  display:flex; flex-direction: column; align-items:center; justify-content:center;
  position: relative;
  box-shadow: 0 12px 30px rgba(0,0,0,0.4);
}
.prey-card::before{
  content:"";
  position:absolute; inset: 8px;
  border: 1px dashed var(--line);
  border-radius: 6px;
}
.prey-card-label{
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--bone-dim);
  margin-bottom: 6px;
}
.prey-card-value{
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 56px;
  line-height: 1;
}
.prey-card-value.positive{ color: var(--ochre-bright); }
.prey-card-value.negative{ color: var(--rust-bright); }
.prey-status{ margin-top: 14px; color: var(--bone-dim); font-size: 13.5px; }

/* ===== reveal ===== */
.reveal-strip{ margin-top: 10px; padding: 16px 0; border-top: 1px solid var(--line); }
.reveal-cards{
  display:flex; flex-wrap: wrap; gap: 8px; justify-content:center;
  margin-bottom: 14px;
}
.reveal-card{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  min-width: 72px;
  text-align:center;
}
.reveal-card.winner{ border-color: var(--ochre-bright); box-shadow: 0 0 0 1px var(--ochre-bright) inset; }
.reveal-card.tied{ opacity: 0.5; }
.reveal-card .rc-name{ font-size: 11px; color: var(--bone-dim); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 92px; }
.reveal-card .rc-card{ font-family: var(--font-mono); font-weight: 700; font-size: 20px; }
.reveal-result{ text-align:center; font-size: 15px; line-height: 1.7; }
.reveal-result .winner-name{ color: var(--ochre-bright); font-weight: 700; }
#btn-next-round{ display:block; margin: 14px auto 0; }

/* ===== hand ===== */
.hand-wrap{ margin-top: auto; padding-top: 18px; }
.hand-label{
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em;
  color: var(--bone-dim); margin: 0 0 10px;
}
.hand{ display:flex; flex-wrap: wrap; gap: 8px; }
.hand-card{
  width: 46px; height: 62px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--bone);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 17px;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
}
.hand-card:hover:not(:disabled){ transform: translateY(-4px); border-color: var(--ochre); }
.hand-card:disabled{ opacity: 0.25; cursor: not-allowed; }
.hand-card.selected{ background: var(--ochre); color: #1A1206; border-color: var(--ochre-bright); transform: translateY(-4px); }

/* ===== finished ===== */
#screen-finished{ justify-content: center; }
.ranking{ list-style: none; margin: 0 0 26px; padding:0; counter-reset: rank; display:flex; flex-direction: column; gap:10px; }
.ranking li{
  display:flex; align-items:center; justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 14px 16px;
}
.ranking li:first-child{ border-color: var(--ochre-bright); }
.rank-left{ display:flex; align-items:center; gap: 12px; }
.rank-num{ font-family: var(--font-mono); color: var(--bone-dim); font-size: 13px; width: 20px; }
.rank-name{ font-size: 15px; }
.rank-score{ font-family: var(--font-mono); font-weight: 700; font-size: 20px; }
.rank-score.pos{ color: var(--ochre-bright); }
.rank-score.neg{ color: var(--rust-bright); }
#restart-wait{ text-align:center; color: var(--bone-dim); font-size: 13px; }
.cancelled-note{ text-align:center; color: var(--rust-bright); font-size: 13.5px; margin: -8px 0 18px; }

/* ===== toast notification (visible on every screen) ===== */
.toast{
  position: fixed;
  left: 50%; bottom: 96px;
  transform: translateX(-50%) translateY(20px);
  z-index: 60;
  max-width: 90vw;
  background: var(--surface-2);
  border: 1px solid var(--rust);
  color: var(--bone);
  font-size: 13.5px;
  padding: 12px 18px;
  border-radius: 6px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show{ opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast.info{ border-color: var(--ochre); }

/* ===== spectator consent banner ===== */
.consent-banner{
  position: fixed;
  top: 70px; left: 50%;
  transform: translateX(-50%);
  z-index: 55;
  background: var(--surface-2);
  border: 1px solid var(--ochre);
  border-radius: 6px;
  padding: 12px 16px;
  display:flex; align-items:center; gap: 12px;
  flex-wrap: wrap;
  max-width: 90vw;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  font-size: 13.5px;
}

/* ===== spectator entry checkboxes ===== */
.spectator-check{
  display:flex; align-items:flex-start; gap: 8px;
  font-size: 13px;
  color: var(--bone-dim);
  margin-top: 14px;
  text-align: left;
  cursor: pointer;
  line-height: 1.5;
}
.spectator-check input{ margin-top: 3px; flex-shrink: 0; }
.spectator-sub{ margin-top: 8px; margin-left: 18px; color: var(--rust-bright); font-size: 12px; }

/* ===== countdown overlay on the prey card ===== */
.countdown-overlay{
  position: absolute;
  inset: 0;
  display:flex; flex-direction: column; align-items:center; justify-content:center;
  gap: 6px;
  background: rgba(23,19,14,0.7);
  border-radius: 10px;
  z-index: 5;
}
.countdown-word{ font-family: var(--font-display); font-size: 16px; color: var(--bone-dim); letter-spacing: 0.1em; }
.countdown-num{
  font-family: var(--font-mono); font-weight: 700; font-size: 64px;
  color: var(--ochre-bright);
  animation: countdown-pulse 1s ease-out infinite;
}
@keyframes countdown-pulse{
  0%{ transform: scale(1.3); opacity: 0.4; }
  40%{ transform: scale(1); opacity: 1; }
  100%{ transform: scale(1); opacity: 1; }
}
.prey-card{ position: relative; }

.spectator-note{ text-align:center; color: var(--bone-dim); font-size: 12.5px; margin-top: 8px; }

@media (max-width: 400px){
  .wordmark{ font-size: 44px; }
  .prey-card{ width: 128px; height: 172px; }
  .prey-card-value{ font-size: 46px; }
}
