/* BELAY Who? — BELAY brand palette wearing Guess Who's cartoony grin.
   Brand: green #12D678, navy #02293D, secondary web palette for card frames. */

:root {
  --green: #12D678;
  --green-soft: #B4F7D4;
  --navy: #02293D;
  --navy-2: #055C8A;
  --blue-slate: #377DA1;
  --ink: #2D3133;
  --paper: #F4F4F4;
  --red: #D92534;
  --orange: #FF913B;
  --yellow: #F7D822;
  --cyan: #4CE5E1;
  --blue: #3996F6;
  --purple: #814EF8;
  --magenta: #D9399E;
  --pink: #F685F4;
  --title-font: 'Lilita One', 'Roboto Slab', serif;
  --head-font: 'Roboto Slab', serif;
  --sub-font: 'Roboto Condensed', sans-serif;
  --body-font: 'Source Sans 3', 'Source Sans Pro', sans-serif;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--body-font);
  color: var(--paper);
  background:
    /* topographic contour hint (brand pattern), very subtle */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='420' viewBox='0 0 420 420'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='0.05' stroke-width='2'%3E%3Cpath d='M0 60 Q 105 10 210 60 T 420 60'/%3E%3Cpath d='M0 130 Q 105 80 210 130 T 420 130'/%3E%3Cpath d='M0 200 Q 105 150 210 200 T 420 200'/%3E%3Cpath d='M0 270 Q 105 220 210 270 T 420 270'/%3E%3Cpath d='M0 340 Q 105 290 210 340 T 420 340'/%3E%3Ccircle cx='210' cy='205' r='55'/%3E%3Ccircle cx='210' cy='205' r='85'/%3E%3Ccircle cx='210' cy='205' r='115'/%3E%3C/g%3E%3C/svg%3E"),
    linear-gradient(160deg, #02293D 0%, #0B304F 55%, #1267A3 130%);
  background-attachment: fixed;
}

#app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 20px 60px;
}

/* ---------- logo ---------- */

.logo {
  font-family: var(--title-font);
  text-align: center;
  line-height: 0.95;
  margin: 10px 0 4px;
  user-select: none;
}
.logo .belay {
  display: block;
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  letter-spacing: 0.04em;
  color: var(--green);
  -webkit-text-stroke: 2px #fff;
  paint-order: stroke fill;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}
.logo .who {
  display: block;
  font-size: clamp(3.4rem, 9.5vw, 6rem);
  letter-spacing: 0.03em;
  color: var(--red);
  -webkit-text-stroke: 2.5px #fff;
  paint-order: stroke fill;
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
  transform: rotate(-2deg);
}
.logo .who .qmark { color: var(--yellow); display: inline-block; transform: rotate(8deg); }
.logo.small { display: flex; gap: 10px; justify-content: center; margin: 2px 0 10px; }
.logo.small .belay, .logo.small .who { font-size: 1.7rem; text-shadow: 0 2px 0 rgba(0,0,0,0.35); -webkit-text-stroke: 1px #fff; transform: none; }
.tagline {
  text-align: center;
  font-family: var(--sub-font);
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: var(--green-soft);
  font-size: 0.8rem;
  margin: 0 0 26px;
}

/* ---------- shared bits ---------- */

.panel {
  background: rgba(2, 41, 61, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
}
.panel h2 {
  font-family: var(--head-font);
  font-weight: 600;
  margin: 0 0 14px;
  font-size: 1.25rem;
}
.panel h3 {
  font-family: var(--sub-font);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.82rem;
  color: var(--green-soft);
  margin: 18px 0 8px;
}

.btn {
  font-family: var(--sub-font);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.95rem;
  border: none;
  border-radius: 12px;
  padding: 12px 22px;
  cursor: pointer;
  color: var(--navy);
  background: var(--green);
  box-shadow: 0 4px 0 #0da35b;
  transition: transform 0.06s ease, box-shadow 0.06s ease, filter 0.15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #0da35b; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.btn.secondary { background: var(--blue-slate); color: #fff; box-shadow: 0 4px 0 #275d79; }
.btn.danger { background: var(--red); color: #fff; box-shadow: 0 4px 0 #a01824; }
.btn.ghost { background: transparent; color: var(--green-soft); box-shadow: none; border: 2px solid rgba(180, 247, 212, 0.4); }
.btn.big { font-size: 1.15rem; padding: 16px 34px; border-radius: 16px; }

.field { display: block; margin: 12px 0; }
.field span { display: block; font-family: var(--sub-font); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.75rem; color: var(--green-soft); margin-bottom: 6px; }
input[type="text"] {
  width: 100%;
  font-family: var(--body-font);
  font-size: 1.05rem;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
}
input[type="text"]:focus { outline: 3px solid var(--green); border-color: transparent; }
input.code-input { text-transform: uppercase; letter-spacing: 0.3em; font-family: var(--sub-font); font-weight: 700; }

.muted { color: rgba(244, 244, 244, 0.65); font-size: 0.92rem; }
.spacer { flex: 1; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ---------- home ---------- */

.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; max-width: 820px; margin: 0 auto; }
@media (max-width: 720px) { .home-grid { grid-template-columns: 1fr; } }

/* ---------- lobby ---------- */

.lobby-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
@media (max-width: 860px) { .lobby-grid { grid-template-columns: 1fr; } }

.invite-code {
  font-family: var(--sub-font);
  font-weight: 700;
  font-size: 1.9rem;
  letter-spacing: 0.28em;
  background: rgba(255, 255, 255, 0.1);
  border: 2px dashed rgba(180, 247, 212, 0.5);
  color: var(--green-soft);
  border-radius: 12px;
  padding: 10px 16px;
  text-align: center;
  user-select: all;
}

.company-block { margin-bottom: 6px; }
.dept {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent;
}
.dept:hover { background: rgba(255, 255, 255, 0.07); }
.dept input { accent-color: var(--green); width: 18px; height: 18px; }
.dept .count { margin-left: auto; font-family: var(--sub-font); color: var(--green-soft); font-size: 0.85rem; }

.pool-meter { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: rgba(18, 214, 120, 0.12); border: 1px solid rgba(18, 214, 120, 0.4); font-size: 0.95rem; }
.pool-meter.warn { background: rgba(247, 216, 34, 0.12); border-color: rgba(247, 216, 34, 0.5); }
.pool-meter b { color: var(--green); font-size: 1.2rem; }
.pool-meter.warn b { color: var(--yellow); }

.toggle-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; cursor: pointer; }
.toggle-row input { accent-color: var(--green); width: 18px; height: 18px; margin-top: 2px; }
.toggle-row small { display: block; color: rgba(244,244,244,0.6); }

.presence { display: flex; align-items: center; gap: 8px; padding: 8px 0; font-size: 1.02rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #888; }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }

/* ---------- status bar (picking / playing) ---------- */

.status-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 18px; margin-bottom: 16px;
  border-radius: 14px;
  background: rgba(2, 41, 61, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.turn-chip {
  font-family: var(--sub-font); font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  padding: 8px 16px; border-radius: 999px; font-size: 0.9rem;
}
.turn-chip.you { background: var(--green); color: var(--navy); animation: pulse 1.8s infinite; }
.turn-chip.them { background: rgba(255, 255, 255, 0.14); color: var(--paper); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(18,214,120,0.6); } 50% { box-shadow: 0 0 0 9px rgba(18,214,120,0); } }

/* ---------- board ---------- */

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 10px;
}
@media (max-width: 980px) { .board { grid-template-columns: repeat(6, 1fr); } }
@media (max-width: 700px) { .board { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 460px) { .board { grid-template-columns: repeat(3, 1fr); } }

.card {
  perspective: 700px;
  aspect-ratio: 3 / 4.5;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.card-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.4, 1.4, 0.6, 1);
}
.card.down .card-inner { transform: rotateX(180deg); }
.card-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  border-radius: 10px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.card-front {
  background: #fff;
  border: 3px solid var(--frame, var(--blue));
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}
.card-front img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #e8f4fb; }
.card-front .no-photo {
  width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-family: var(--title-font); font-size: 1.8rem; color: #fff; background: var(--frame, var(--blue));
}
.card-name {
  background: var(--navy); color: #fff; text-align: center;
  font-family: var(--sub-font); font-weight: 700; font-size: 0.78rem;
  padding: 3px 4px; line-height: 1.15;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex-shrink: 0;
}
.card-meta {
  font-size: 0.62rem; color: var(--ink); text-align: center; line-height: 1.3;
  padding: 2px 4px 3px; background: #fff; flex: 1; min-height: 0;
  display: flex; flex-direction: column; justify-content: center; gap: 0;
  overflow: hidden;
}
.card-meta span {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.card-meta .dept-tag { color: var(--blue-slate); font-family: var(--sub-font); text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.56rem; }
.card-back {
  transform: rotateX(180deg);
  background: linear-gradient(150deg, #084256, #02293D);
  border: 3px solid rgba(255, 255, 255, 0.25);
  align-items: center; justify-content: center;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.4);
}
.card-back .qm { font-family: var(--title-font); font-size: 2.4rem; color: var(--green); opacity: 0.9; text-shadow: 0 2px 0 rgba(0,0,0,0.4); }

.card.secret .card-front { outline: 3px solid var(--yellow); outline-offset: 2px; }
.card.selectable:hover .card-inner { transform: translateY(-4px) scale(1.03); }
.card.guess-target:hover .card-front { outline: 3px solid var(--red); outline-offset: 2px; }

/* Board shrinks a bit when the roster is small so cards don't balloon */
.board.small-roster { max-width: 760px; margin: 0 auto; }

/* ---------- game layout ---------- */

.game-grid { display: grid; grid-template-columns: 1fr 250px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .game-grid { grid-template-columns: 1fr; } }

.side-panel { display: flex; flex-direction: column; gap: 14px; }

.opp-board {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
}
.opp-card {
  aspect-ratio: 3 / 4; border-radius: 4px;
  background: linear-gradient(150deg, #0a5c74, #084256);
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--title-font); font-size: 0.7rem; color: rgba(18, 214, 120, 0.85);
  transition: transform 0.4s, opacity 0.4s, background 0.4s, border-color 0.4s, color 0.4s;
}
.opp-card.down {
  transform: rotateX(180deg);
  background: #171c21;
  border-color: rgba(255, 255, 255, 0.1);
  color: transparent;
  opacity: 0.75;
}
.opp-remaining { text-align: center; font-size: 1.05rem; margin-top: 10px; }
.opp-remaining b { color: var(--green); font-size: 1.5rem; font-family: var(--head-font); }

.mini-secret { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.07); border-radius: 12px; padding: 8px 10px; }
.mini-secret img { width: 46px; height: 46px; border-radius: 8px; border: 2px solid var(--yellow); object-fit: cover; background:#e8f4fb; }
.mini-secret .who-label { font-family: var(--sub-font); text-transform: uppercase; font-size: 0.68rem; letter-spacing: 0.12em; color: var(--yellow); }
.mini-secret .who-name { font-weight: 600; font-size: 0.95rem; }

.game-log {
  max-height: 220px; overflow-y: auto;
  font-size: 0.84rem; line-height: 1.45;
  display: flex; flex-direction: column-reverse;
}
.game-log div { padding: 4px 0; border-bottom: 1px dashed rgba(255,255,255,0.08); }

.guess-banner {
  border-radius: 12px; padding: 10px 16px; font-weight: 600; text-align: center;
  background: rgba(217, 37, 52, 0.18); border: 1px solid rgba(217, 37, 52, 0.5);
}
.guess-banner.good { background: rgba(18, 214, 120, 0.15); border-color: rgba(18, 214, 120, 0.5); }

.guess-mode-hint {
  background: rgba(217, 37, 52, 0.2); border: 2px dashed var(--red);
  border-radius: 12px; padding: 10px 16px; text-align: center; font-weight: 600;
}

/* ---------- game over ---------- */

.gameover { text-align: center; padding: 30px 20px; }
.gameover .headline { font-family: var(--title-font); font-size: clamp(2.2rem, 6vw, 3.6rem); margin: 8px 0; -webkit-text-stroke: 1.5px #fff; paint-order: stroke fill; text-shadow: 0 4px 0 rgba(0,0,0,0.35); }
.gameover .headline.win { color: var(--green); }
.gameover .headline.lose { color: var(--red); }
.reveal-row { display: flex; gap: 26px; justify-content: center; flex-wrap: wrap; margin: 22px 0; }
.reveal-card { width: 150px; }
.reveal-card .label { font-family: var(--sub-font); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.75rem; color: var(--green-soft); margin-bottom: 8px; }
.reveal-card img { width: 100%; border-radius: 12px; border: 4px solid var(--yellow); background:#e8f4fb; }
.reveal-card .name { font-weight: 600; margin-top: 6px; }

/* ---------- toast ---------- */

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; border: 2px solid var(--green);
  padding: 12px 22px; border-radius: 12px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 50; max-width: 90vw; text-align: center;
}

/* ---------- footer ---------- */
.footer-bar {
  margin-top: 40px; text-align: center;
  font-family: var(--sub-font); text-transform: uppercase; letter-spacing: 0.2em;
  font-size: 0.7rem; color: rgba(244, 244, 244, 0.4);
}
