/* ---------------------------------------------------------------
   Word Spies - shared styles (TV + phones)
   --------------------------------------------------------------- */
/* Fonts (included in assets/fonts, free SIL Open Font License) */
@font-face { font-family: 'Barlow Condensed'; font-style: normal; font-weight: 600; font-display: swap; src: url('fonts/barlow-condensed-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/barlow-condensed-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/inter-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('fonts/inter-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/inter-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 800; font-display: swap; src: url('fonts/inter-latin-800-normal.woff2') format('woff2'); }

:root {
  --bg: #0e1120;
  --bg2: #161a2d;
  --panel: #1d2238;
  --panel2: #252b45;
  --line: #2f3654;
  --text: #eef0f8;
  --muted: #98a1c0;

  --red: #e0454b;
  --red-d: #8f2a2e;
  --red-tint: #f2c6c7;
  --blue: #3b7ae0;
  --blue-d: #22498f;
  --blue-tint: #c8d8f6;
  --neutral: #d6c7a1;
  --neutral-d: #7d7259;
  --assassin: #16161a;

  --card: #f5eddc;
  --card-edge: #d9ccb0;
  --card-text: #2a2621;
  --gold: #f4c24f;

  --font-word: 'Barlow Condensed', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 700px at 50% -10%, #1d2442 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.red-text { color: #ff7b80; }
.blue-text { color: #7fa9ff; }

.logo {
  font-family: var(--font-word);
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.logo .a { color: #ff6b70; }
.logo .b { color: #6f9dff; }

/* ---------- buttons & inputs ---------- */
.btn {
  border: 0;
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  background: var(--panel2);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.25);
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.gold { background: var(--gold); color: #2a1f00; }
.btn.red { background: var(--red); }
.btn.blue { background: var(--blue); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); box-shadow: none; }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 9px; }
.btn.block { display: block; width: 100%; }

.input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0b0e1a;
  color: var(--text);
  font-size: 18px;
  font-family: inherit;
  outline: none;
}
.input:focus { border-color: var(--gold); }
.input.code { text-transform: uppercase; letter-spacing: .3em; font-weight: 800; text-align: center; font-size: 26px; }

/* ---------- word cards ---------- */
.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  color: var(--card-text);
  border-radius: 8px;
  border-bottom: 3px solid var(--card-edge);
  box-shadow: 0 3px 8px rgba(0,0,0,.25);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color .35s ease, color .35s ease, transform .15s ease, box-shadow .15s ease;
}
.tile .word {
  display: block;
  width: 100%;
  padding: 0 5px;
  font-family: var(--font-word);
  font-weight: 700;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  line-height: 1.1;
  letter-spacing: .02em;
}

/* revealed cards (everyone sees these) */
.tile.rv-red      { background: var(--red);      border-color: var(--red-d);  color: rgba(255,255,255,.75); }
.tile.rv-blue     { background: var(--blue);     border-color: var(--blue-d); color: rgba(255,255,255,.75); }
.tile.rv-neutral  { background: var(--neutral);  border-color: #b3a37b;       color: rgba(60,50,30,.55); }
.tile.rv-assassin { background: var(--assassin); border-color: #000;          color: rgba(255,255,255,.7); box-shadow: 0 0 0 3px #ff3b3b, 0 3px 8px rgba(0,0,0,.4); }
.tile[class*="rv-"] .word { text-decoration: none; }
.tile[class*="rv-"]::after {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(135deg, rgba(255,255,255,.06) 0 6px, transparent 6px 14px);
  pointer-events: none;
}

/* captain's secret map (unrevealed cards) */
.tile.k-red      { background: #f7d3d4; border-color: var(--red);  box-shadow: inset 0 0 0 3px var(--red), 0 3px 8px rgba(0,0,0,.25); color: #6d1d21; }
.tile.k-blue     { background: #d3e1fa; border-color: var(--blue); box-shadow: inset 0 0 0 3px var(--blue), 0 3px 8px rgba(0,0,0,.25); color: #173b7a; }
.tile.k-neutral  { background: var(--card); color: #6c6352; }
.tile.k-assassin { background: #2a2a30; border-color: #000; color: #fff; box-shadow: inset 0 0 0 3px #ff3b3b, 0 3px 8px rgba(0,0,0,.3); }

/* end of game: show where everything was, faded */
.tile.ghost { opacity: .62; }

/* phone interactions */
.tile.clickable { cursor: pointer; }
.tile.clickable:active { transform: scale(.97); }
.tile.selected { box-shadow: 0 0 0 3px var(--gold), 0 6px 16px rgba(0,0,0,.4); transform: scale(1.04); z-index: 2; }
.tile.myvote::before {
  content: 'LOCKED';
  position: absolute; left: 0; right: 0; bottom: 0;
  font-size: 9px; font-weight: 800; letter-spacing: .12em;
  text-align: center;
  background: var(--gold); color: #2a1f00;
  padding: 1px 0;
}
.tile.myvote { box-shadow: 0 0 0 3px var(--gold), 0 3px 8px rgba(0,0,0,.25); }
.tile.dim { opacity: .55; }

/* who has locked in on this card */
.tile .chips {
  position: absolute;
  top: 3px; right: 3px; left: 3px;
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 3px;
  pointer-events: none;
}
.chip {
  display: inline-block;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px;
  font-size: 10px; font-weight: 800; line-height: 16px;
  text-align: center;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.chip.red { background: var(--red); }
.chip.blue { background: var(--blue); }

/* reveal flip animation */
@keyframes flipIn {
  0% { transform: rotateY(90deg) scale(1.05); }
  100% { transform: rotateY(0) scale(1); }
}
.tile.flip { animation: flipIn .45s ease-out; }

/* ---------- small things ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--panel2); font-size: 13px; font-weight: 600;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #4ade80; }
.dot.away { background: #6b7280; }

.toast {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 50;
  text-align: center;
  padding: 22px 34px;
  border-radius: 18px;
  background: rgba(14,17,32,.94);
  border: 2px solid var(--line);
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.conn-banner {
  position: fixed; top: 0; left: 0; right: 0;
  background: #b45309; color: #fff;
  text-align: center; font-weight: 700; font-size: 14px;
  padding: 6px; z-index: 100;
}

/* ===============================================================
   TV screen
   =============================================================== */
body.tv { height: 100vh; overflow: hidden; }
.tv .screen { height: 100vh; padding: 2.2vh 2.2vw; }

/* lobby */
#lobby { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3.5vh; }
#lobby .logo { font-size: 9vh; line-height: 1; }
.lobby-main { display: flex; gap: 4vw; align-items: stretch; justify-content: center; width: 100%; max-width: 1600px; }
.join-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 2vh;
  padding: 3vh 3vw; display: flex; flex-direction: column; align-items: center; gap: 2vh; text-align: center;
}
#qr { background: #fff; padding: 1.2vh; border-radius: 1.4vh; line-height: 0; }
#qr svg, #qr img { width: 30vh; height: 30vh; display: block; }
.join-steps { font-size: 2.2vh; color: var(--muted); line-height: 1.5; }
.join-steps b { color: var(--text); }
.room-code { font-family: var(--font-word); font-weight: 700; font-size: 10vh; letter-spacing: .25em; color: var(--gold); line-height: 1; padding-left: .25em; }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 2vw; min-width: 50vw; align-content: start; }
.team-col { background: var(--panel); border-radius: 2vh; padding: 2.4vh 2vw; border-top: 1vh solid; min-height: 40vh; }
.team-col.red { border-color: var(--red); }
.team-col.blue { border-color: var(--blue); }
.team-col h2 { margin: 0 0 1.6vh; font-family: var(--font-word); font-size: 4.4vh; text-transform: uppercase; letter-spacing: .05em; }
.team-col.red h2 { color: #ff7b80; }
.team-col.blue h2 { color: #7fa9ff; }
.team-col .cap { font-size: 2.4vh; margin-bottom: 1.6vh; padding-bottom: 1.6vh; border-bottom: 1px solid var(--line); }
.team-col .cap .lbl, .team-col .plbl { color: var(--muted); font-size: 1.8vh; text-transform: uppercase; letter-spacing: .1em; display: block; margin-bottom: .6vh; }
.team-col ul { list-style: none; padding: 0; margin: 0; font-size: 2.4vh; line-height: 1.7; }
.team-col .empty { color: var(--muted); font-style: italic; }
.unassigned { grid-column: 1 / -1; font-size: 2vh; color: var(--muted); text-align: center; }
.lobby-actions { text-align: center; }
.lobby-actions .btn { font-size: 3vh; padding: 2vh 5vw; border-radius: 1.6vh; }
.lobby-actions .hint { margin-top: 1.4vh; font-size: 2vh; color: var(--muted); }

/* game */
#game { display: grid; grid-template-rows: auto 1fr auto; gap: 1.8vh; }
.tv-bar { display: grid; grid-template-columns: 1fr 2.2fr 1fr; gap: 2vw; align-items: stretch; }
.tv-bar .side {
  border-radius: 1.6vh; padding: 1vh 1.5vw; display: flex; align-items: center; gap: 1.2vw;
  background: var(--panel); border: 1px solid var(--line);
}
.tv-bar .side.red { border-left: 1vh solid var(--red); }
.tv-bar .side.blue { border-right: 1vh solid var(--blue); flex-direction: row-reverse; text-align: right; }
.tv-bar .count { font-family: var(--font-word); font-weight: 700; font-size: 7vh; line-height: 1; }
.tv-bar .side.red .count { color: #ff7b80; }
.tv-bar .side.blue .count { color: #7fa9ff; }
.tv-bar .lbl { font-size: 1.9vh; color: var(--muted); line-height: 1.3; }
.tv-bar .lbl b { display: block; color: var(--text); font-size: 2.3vh; }
.turn {
  border-radius: 1.6vh; padding: 1.2vh 2vw; text-align: center;
  display: flex; flex-direction: column; justify-content: center;
  background: var(--panel2); transition: background-color .4s ease;
}
.turn.red { background: linear-gradient(180deg, #ea5a5f, var(--red-d)); }
.turn.blue { background: linear-gradient(180deg, #4f8bf0, var(--blue-d)); }
.turn-title { font-family: var(--font-word); font-weight: 700; font-size: 5.4vh; text-transform: uppercase; letter-spacing: .05em; line-height: 1.05; }
.turn-sub { font-size: 2.2vh; opacity: .92; margin-top: .4vh; }
.turn.win { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.18); } }

.tv-board { gap: 1.3vh; grid-template-rows: repeat(5, minmax(0, 1fr)); min-height: 0; }
.tv-board .tile { border-radius: 1.2vh; border-bottom-width: .6vh; }
.tv-board .tile .word { font-size: min(3.5vw, 6.4vh); padding: 0 .8vw; }
.tv-board .chips { top: .6vh; right: .6vh; left: .6vh; gap: .5vh; }
.tv-board .chip { height: 2.6vh; line-height: 2.6vh; min-width: 2.6vh; font-size: 1.6vh; padding: 0 .8vh; border-radius: 1.3vh; }
.tv-board .tile.myvote::before { display: none; }

.tv-foot { display: flex; align-items: center; justify-content: space-between; gap: 2vw; font-size: 2vh; color: var(--muted); }
.tv-foot b { color: var(--text); }
.tv-foot .code { color: var(--gold); letter-spacing: .15em; }
.team-status { flex: 1; text-align: center; }
.team-status .who { display: inline-block; margin: 0 .8vw; color: var(--text); }
.team-status .who.away { color: var(--muted); }
.team-status .ok { color: #4ade80; font-weight: 800; }
.foot-right { display: flex; align-items: center; gap: 1vw; white-space: nowrap; }
.tv-foot .btn.small { font-size: 1.8vh; padding: .9vh 1.2vw; }
.score { font-weight: 700; color: var(--text); }

.tv .toast { padding: 4vh 5vw; }
.toast .t-word { font-family: var(--font-word); font-weight: 700; font-size: 9vh; line-height: 1; text-transform: uppercase; }
.toast .t-msg { font-size: 3vh; margin-top: 1.4vh; }
.toast.red { border-color: var(--red); }
.toast.blue { border-color: var(--blue); }
.toast.neutral { border-color: var(--neutral); }
.toast.assassin { border-color: #ff3b3b; }
.toast.red .t-word { color: #ff7b80; }
.toast.blue .t-word { color: #7fa9ff; }
.toast.neutral .t-word { color: var(--neutral); }
.toast.assassin .t-word { color: #ff5a5a; }
.team-status .lbl2 { color: var(--muted); margin-right: .4vw; }

.center-msg { height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2vh; text-align: center; padding: 4vw; font-size: 2.6vh; }

/* ===============================================================
   Phone screen
   =============================================================== */
body.phone { min-height: 100vh; }
.phone .wrap { max-width: 620px; margin: 0 auto; padding: 14px 12px 40px; }
.phone .logo { font-size: 40px; text-align: center; margin: 18px 0 6px; }
.phone label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 18px 0 6px; }
.phone .error { color: #ff8a8d; font-weight: 600; margin-top: 12px; min-height: 1.2em; text-align: center; }
.phone h2 { font-size: 22px; margin: 10px 0 14px; text-align: center; }

.role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.role {
  border: 0; border-radius: 14px; padding: 18px 12px; color: #fff; text-align: left;
  display: flex; flex-direction: column; gap: 4px; min-height: 104px;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.25);
}
.role.red { background: linear-gradient(160deg, #ea5a5f, var(--red-d)); }
.role.blue { background: linear-gradient(160deg, #4f8bf0, var(--blue-d)); }
.role b { font-size: 19px; }
.role small { font-size: 13px; opacity: .9; }
.role em { font-size: 12px; font-style: normal; background: rgba(0,0,0,.3); padding: 3px 8px; border-radius: 8px; align-self: flex-start; margin-top: 4px; }
.role:disabled { filter: grayscale(.6); opacity: .55; }
.roster { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 14px; }
.roster > div { background: var(--panel); border-radius: 12px; padding: 10px 12px; }
.roster h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.roster .r h4 { color: #ff7b80; }
.roster .b h4 { color: #7fa9ff; }
.roster div div { line-height: 1.6; }
.row-links { display: flex; justify-content: center; gap: 10px; margin-top: 20px; }

.me-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 14px; margin-bottom: 10px;
  background: var(--panel);
}
.me-bar.red { background: linear-gradient(160deg, #d9474c, var(--red-d)); }
.me-bar.blue { background: linear-gradient(160deg, #3f7ce6, var(--blue-d)); }
.me-bar .who b { font-size: 17px; display: block; }
.me-bar .who span { font-size: 13px; opacity: .9; }
.me-bar .btn.ghost { border-color: rgba(255,255,255,.4); }

.status { background: var(--panel); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; border-left: 6px solid var(--line); }
.status.go { border-left-color: var(--gold); background: #2a2a1c; }
.status.red { border-left-color: var(--red); }
.status.blue { border-left-color: var(--blue); }
.status .s-title { font-size: 18px; font-weight: 800; }
.status .s-sub { font-size: 14px; color: var(--muted); margin-top: 3px; line-height: 1.4; }

.counts { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; margin: 0 2px 8px; }

.phone-board { gap: 5px; }
.phone-board .tile { min-height: 54px; border-radius: 7px; }
.phone-board .tile .word { font-size: 17px; padding: 0 3px; }
@media (min-width: 480px) {
  .phone-board { gap: 7px; }
  .phone-board .tile { min-height: 66px; }
  .phone-board .tile .word { font-size: 20px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .phone-board .tile { min-height: 44px; }
}

.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.actions .btn { font-size: 18px; padding: 16px; }
.progress { text-align: center; font-size: 14px; color: var(--muted); margin-top: 10px; line-height: 1.5; }
.progress b { color: var(--text); }
.team-list { margin-top: 16px; font-size: 14px; color: var(--muted); text-align: center; line-height: 1.6; }
.extra { margin-top: 22px; display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
