/* ==========================================================================
   PWN BINGO — design notes
   Subject: buzzword bingo for security teams (the meme you play during the
   "AI-powered zero-trust synergy" vendor webinar). Palette is lifted from
   SIEM/vuln-scanner severity coding (slate base, amber = default/attention,
   red = marked/critical, teal = healthy/online) rather than hacker-movie
   neon-green-on-black. Display face is a condensed industrial stencil-ish
   grotesk (stamp/redaction register); UI text is a clean technical sans;
   board terms + all data/log content sit in a monospace to read as
   terminal/log output. Signature moment: marking a square stamps "PWNED"
   across it (ties bingo-marking + hacker slang in one motion) and a
   completed line is announced as "KILL CHAIN COMPLETE" (Lockheed Martin's
   Cyber Kill Chain, reused as the bingo win pun).
   ========================================================================== */

:root {
  --bg: #0a0e14;
  --panel: #10161f;
  --panel-raised: #161d28;
  --rule: #29323f;
  --rule-soft: #1a212c;
  --ink: #e9edf3;
  --ink-dim: #8996a8;
  --ink-faint: #576273;
  --amber: #f2a93b;
  --amber-dim: rgba(242, 169, 59, 0.14);
  --critical: #e5484d;
  --critical-dim: rgba(229, 72, 77, 0.16);
  --ok: #35c48a;
  --ok-dim: rgba(53, 196, 138, 0.14);
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  --display: 'Big Shoulders Display', 'Arial Narrow', sans-serif;
  --body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  /* Not display:flex -- a flex item's default min-width is its content's
     min-content size, not 0, so .app couldn't shrink below its widest
     unwrappable row (the B-I-N-G-O tracker) and the whole page overflowed
     on narrow viewports. Block + margin auto centers just as well without
     that trap. */
  background:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(242, 169, 59, 0.08), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 20%, rgba(229, 72, 77, 0.06), transparent 55%),
    var(--bg);
  font-family: var(--body);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

ul, ol { margin: 0; padding: 0; }
a { color: var(--amber); }

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

/* -- BUTTONS -- */
button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 4px;
  padding: 0.7rem 1.4rem;
  background: var(--amber);
  color: #1a1305;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  transition: transform 0.1s ease, box-shadow 0.15s ease, filter 0.1s ease;
}

button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); filter: brightness(0.95); }

button.ghost {
  background: transparent;
  color: var(--ink-dim);
  border: 1px solid var(--rule);
}

button.ghost:hover {
  color: var(--ink);
  border-color: var(--ink-faint);
  filter: none;
}

/* -- SHARED PANEL LOOK --
 * Every panel gets a flat dark surface, a hairline rule (no glow/shadow
 * halo), and a 2px top accent bar -- reads as an alert/log tile rather than
 * a generic rounded SaaS card.
 */
.header,
.board,
.status,
.how-to,
.panel,
.modal__panel {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-top: 2px solid var(--amber);
  border-radius: 3px;
}

/* -- APP SHELL -- */
.app {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2.5rem);
  display: grid;
  /* grid-template-columns must set a 0 minimum explicitly -- a grid item's
     default min-width is its content's min-content size (same trap flex
     items have), so without this the whole page refused to shrink below
     the widest unwrappable row (the B-I-N-G-O tracker) on narrow viewports. */
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1.25rem, 2.5vw, 2rem);
}

/* -- HEADER / WORDMARK -- */
.header {
  padding: clamp(1.25rem, 2.5vw, 2rem) clamp(1.5rem, 3vw, 2.5rem);
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: space-between;
  align-items: center;
}

.header__kicker {
  margin: 0 0 0.3rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-dim);
}

.wordmark {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  line-height: 0.85;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  color: var(--ink);
}

.wordmark__accent {
  color: var(--amber);
  margin-left: 0.15em;
}

.header__room {
  margin: 0.5rem 0 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink-dim);
}

.header__room span {
  color: var(--amber);
  font-weight: 600;
}

.actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

/* -- LAYOUT -- */
/* The card is the page's center of gravity: full-width, single column,
   everything else (players, chat) stacks around it instead of sharing a
   row with it. Capped narrower than .app and centered so cells stay a
   sane size instead of stretching into oversized tiles. */
.board-wrapper {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1rem, 2vw, 1.5rem);
}

.board-wrapper--main {
  width: min(760px, 100%);
  margin: 0 auto;
}

.board-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
}

.section-title {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

/* -- BINGO LETTER TRACKER --
 * Lights up left to right as the local player completes lines; sits next
 * to the section title instead of buried lower on the page.
 */
.tracker {
  list-style: none;
  display: flex;
  gap: 0.4rem;
}

.tracker li {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-faint);
  border: 1px solid var(--rule);
  border-radius: 3px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tracker li.active {
  background: var(--ok-dim);
  border-color: var(--ok);
  color: var(--ok);
}

/* -- BOARD -- */
.board {
  padding: clamp(1.25rem, 2.5vw, 2rem);
}

.cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
}

.cards__empty {
  margin: 0;
  padding: 2rem;
  text-align: center;
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 0.9rem;
  border: 1px dashed var(--rule);
  border-radius: 3px;
}

.card-wrapper {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.6rem;
}

.card-wrapper__title {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.bingo-letters {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  text-align: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.4rem;
}

.card {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(0.35rem, 0.8vw, 0.55rem);
}

/* -- CELLS --
 * Unmarked: flat slate tile, mono term text.
 * .called (1s pulse class from script.js on the just-marked cell): the
 * PWNED stamp animation -- a diagonal stamp scales/rotates in like a rubber
 * stamp hitting paper, with a brief flash on the tile itself.
 * .marked (persistent state): settles into a critical-red tinted tile with
 * the PWNED stamp left in place, quieter than the entrance moment.
 * .winning: the completed line gets the amber "confirmed" treatment so it
 * reads distinctly from an in-progress critical mark.
 */
.cell {
  position: relative;
  min-height: clamp(64px, 11vw, 108px);
  padding: 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--rule-soft);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--mono);
  font-size: clamp(0.72rem, 1.6vw, 0.88rem);
  font-weight: 500;
  line-height: 1.3;
  text-transform: uppercase;
  cursor: pointer;
  overflow: hidden;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.cell:hover {
  border-color: var(--ink-faint);
}

.cell.free {
  background: var(--amber-dim);
  border-style: dashed;
  border-color: var(--amber);
  color: var(--amber);
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: none;
  font-size: clamp(0.7rem, 1.4vw, 0.82rem);
  cursor: default;
}

.cell.marked {
  background: var(--critical-dim);
  border-color: var(--critical);
  color: var(--ink-dim);
}

.cell.marked::after {
  content: 'PWNED';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1rem, 2.4vw, 1.4rem);
  letter-spacing: 0.08em;
  color: var(--critical);
  background: rgba(10, 14, 20, 0.72);
  transform: rotate(-8deg);
  border: 2px solid var(--critical);
  border-radius: 2px;
  margin: 8%;
}

/* Free space is pre-marked server-side by default (see createPlayerBoard in
   server.js) so it always carries .marked alongside .free -- it should
   never get the PWNED stamp, just its own calm treatment. */
.cell.free.marked {
  background: var(--amber-dim);
  border-color: var(--amber);
}

.cell.free.marked::after {
  content: none;
}

.cell.called::after {
  animation: stamp-hit 0.42s cubic-bezier(0.2, 1.6, 0.4, 1);
}

@keyframes stamp-hit {
  0% { opacity: 0; transform: rotate(-8deg) scale(2.4); }
  55% { opacity: 1; transform: rotate(-10deg) scale(0.92); }
  75% { transform: rotate(-7deg) scale(1.05); }
  100% { opacity: 1; transform: rotate(-8deg) scale(1); }
}

.cell.called {
  animation: cell-flash 0.5s ease;
}

@keyframes cell-flash {
  0% { background: var(--critical); }
  100% { background: var(--critical-dim); }
}

.cell.winning {
  border-color: var(--amber);
  box-shadow: inset 0 0 0 1px var(--amber);
}

.cell.winning::after {
  color: var(--amber);
  border-color: var(--amber);
  background: rgba(10, 14, 20, 0.8);
}

/* -- STATUS / CALL HISTORY -- */
.status {
  padding: clamp(1rem, 2vw, 1.5rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
}

.status p {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink-dim);
}

.status p strong {
  color: var(--ink);
  font-weight: 600;
}

.call-history {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.call-history li {
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-dim);
  background: var(--rule-soft);
}

.call-history li.latest {
  border-color: var(--critical);
  color: var(--ink);
  background: var(--critical-dim);
}

/* -- HOW IT WORKS -- */
.how-to {
  padding: clamp(1rem, 2vw, 1.5rem);
}

.how-to h3 {
  margin: 0 0 0.75rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.how-to ol {
  padding-left: 1.1rem;
  display: grid;
  gap: 0.5rem;
  color: var(--ink-dim);
  font-size: 0.9rem;
  line-height: 1.55;
}

.how-to li::marker {
  color: var(--amber);
  font-family: var(--mono);
}


.panel {
  padding: clamp(1rem, 2vw, 1.4rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.85rem;
  align-content: start;
}

.panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.panel__header h2 {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 0.15rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  border-radius: 3px;
  background: var(--ok-dim);
  border: 1px solid var(--ok);
  color: var(--ok);
}

/* -- ENCRYPTION BADGE --
 * Honest, specific labeling (not "secure!" marketing fluff) -- exact
 * primitive is in the title attribute for anyone who wants it.
 */
.crypto-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--amber);
  border: 1px solid var(--amber-dim);
  background: var(--amber-dim);
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  white-space: nowrap;
}

.crypto-badge svg {
  width: 11px;
  height: 11px;
  fill: currentColor;
}

.players__list {
  display: grid;
  gap: 0.4rem;
  list-style: none;
}

/* Players moved out of a sidebar into a full-width strip above the card --
   read as a horizontal row of pills instead of a stacked list. */
.players--strip .players__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.players--strip .players__item {
  flex: 0 1 auto;
}

.players__item {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--rule-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.players__item::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
  box-shadow: 0 0 6px var(--ok);
}

.players__item {
  padding-left: 0.55rem;
}

.players__item button {
  padding: 0.25rem 0.65rem;
  font-size: 0.7rem;
}

/* -- CHAT -- */
.chat__log {
  max-height: 300px;
  overflow-y: auto;
  display: grid;
  gap: 0.55rem;
  padding-right: 0.2rem;
  font-size: 0.85rem;
}

/* Chat lives at the very bottom of the page now, full-width panel -- but
   long message lines are still capped to a comfortable reading measure and
   centered, rather than stretching edge to edge. */
.chat--footer {
  width: min(680px, 100%);
  margin: 0 auto;
}

.chat--footer .chat__log {
  max-height: 220px;
}

.chat__log-entry {
  display: grid;
  gap: 0.1rem;
}

.chat__log-entry strong {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  font-weight: 500;
}

.chat__log-entry span {
  color: var(--ink);
}

.chat__form,
.dm__form {
  display: flex;
  gap: 0.5rem;
}

.chat__form input,
.dm__form input,
.field input {
  flex: 1;
  /* Inputs have a sizeable browser-default intrinsic min-width in flex
     layout (same min-content trap as grid items) -- without this override
     they refuse to shrink and force the "Send" button past the viewport
     edge on narrow screens. */
  min-width: 0;
  font: inherit;
  font-family: var(--body);
  padding: 0.6rem 0.8rem;
  border-radius: 3px;
  border: 1px solid var(--rule);
  background: var(--rule-soft);
  color: var(--ink);
}

.chat__form input::placeholder,
.dm__form input::placeholder,
.field input::placeholder {
  color: var(--ink-faint);
}

.chat__form button,
.dm__form button {
  padding: 0.6rem 1.1rem;
  font-size: 0.8rem;
}

/* -- DIRECT MESSAGE PANEL --
 * .dm[hidden] must win over .dm's own `display: grid` -- an attribute
 * selector and a class selector are equal specificity, so without this the
 * later same-specificity rule (ours) would beat the browser's default
 * [hidden] { display: none } and the panel would show even when hidden.
 */
.dm[hidden] {
  display: none;
}

.dm {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: min(360px, calc(100% - 2rem));
  background: var(--panel-raised);
  border: 1px solid var(--rule);
  border-top: 2px solid var(--amber);
  border-radius: 3px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  animation: dm-pop 0.18s ease;
  z-index: 40;
}

@keyframes dm-pop {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.dm__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--rule);
}

.dm__header h2 {
  margin: 0 0 0.3rem;
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 600;
}

.dm__status {
  margin: 0;
}

.dm__log {
  padding: 0.9rem 1.1rem;
  display: grid;
  gap: 0.55rem;
  max-height: 240px;
  overflow-y: auto;
  font-size: 0.82rem;
}

.dm__log-entry strong {
  display: block;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-faint);
  font-weight: 500;
}

.dm__form {
  padding: 0.85rem 1.1rem 1rem;
}

/* -- BINGO WIN BANNER -- */
.bingo-banner[hidden] {
  display: none;
}

.bingo-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  padding: 1.25rem 1rem 0;
  z-index: 80;
  pointer-events: none;
}

.bingo-banner__panel {
  pointer-events: auto;
  width: min(560px, 100%);
  background: var(--panel-raised);
  border: 1px solid var(--critical);
  border-top: 3px solid var(--critical);
  border-radius: 3px;
  box-shadow: 0 24px 60px rgba(229, 72, 77, 0.25);
  padding: 1rem 1.3rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transform: translateY(-16px);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.2, 1.4, 0.4, 1), opacity 0.25s ease;
}

.bingo-banner--show .bingo-banner__panel {
  transform: translateY(0);
  opacity: 1;
}

.bingo-banner__eyebrow {
  margin: 0 0 0.15rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--critical);
}

.bingo-banner__name {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.3rem;
  text-transform: uppercase;
  color: var(--ink);
  flex: 1;
}

/* -- JOIN MODAL -- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 12, 0.88);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
  z-index: 100;
}

.modal__panel {
  width: min(420px, 100%);
  padding: 2rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.1rem;
  box-shadow: var(--shadow);
}

.modal__kicker {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--amber);
}

.modal__panel h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.9rem;
  text-transform: uppercase;
}

.modal__panel > p {
  margin: 0;
  color: var(--ink-dim);
  font-size: 0.9rem;
  line-height: 1.5;
}

.field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.35rem;
}

.field span {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.field__hint {
  font-size: 0.74rem;
  color: var(--ink-faint);
  line-height: 1.4;
}

.modal__link {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-faint);
  word-break: break-all;
}

.modal__link a {
  color: var(--amber);
}

/* -- RESPONSIVE -- */
@media (max-width: 900px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .actions {
    width: 100%;
  }

  .actions button {
    flex: 1;
  }

  .dm {
    right: 1rem;
    left: 1rem;
    width: auto;
  }
}

@media (max-width: 560px) {
  .card {
    gap: 0.3rem;
  }

  .cell {
    font-size: 0.62rem;
    min-height: 58px;
    padding: 0.35rem;
  }

  .cell.marked::after,
  .cell.free {
    font-size: 0.6rem;
  }

  .bingo-letters {
    font-size: 0.85rem;
  }
}
