/* Component layer — mirrors the flat production wireframe theme (t3–t6). */

/* ---------- Header / navigation ---------- */
.app-header {
  display: flex;
  align-items: center;
  gap: var(--su-gap-3);
  height: var(--su-header-h);
  padding: 0 var(--su-gap-4);
  background: var(--su-bar);
  border-bottom: 1px solid var(--su-edge);
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand {
  font-family: var(--su-font-heading);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 16px;
  color: var(--su-text);
  white-space: nowrap;
}
.brand b { color: var(--su-gold); font-weight: 600; }
.app-header nav { display: flex; gap: var(--su-gap-2); align-items: center; margin-left: auto; }

.nav-link {
  position: relative;
  background: none;
  border: none;
  color: var(--su-muted);
  padding: 8px 10px;
  font-family: var(--su-font-heading);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 12px;
  cursor: pointer;
  border-radius: var(--su-radius);
}
.nav-link:hover { color: var(--su-text); background: var(--su-raise); }
.nav-link.active { color: var(--su-gold); }

.badge-count {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--su-red);
  color: #fff;
  font: 700 10px/15px var(--su-font-body);
  text-align: center;
}

/* Mobile nav drawer */
.nav-drawer {
  position: fixed;
  inset: var(--su-header-h) 0 0 auto;
  width: min(300px, 85vw);
  background: var(--su-bar);
  border-left: 1px solid var(--su-edge);
  box-shadow: var(--su-shadow-lg);
  display: flex;
  flex-direction: column;
  padding: var(--su-gap-3);
  gap: var(--su-gap-1);
  z-index: 50;
  transform: translateX(100%);
  transition: transform 0.18s ease;
}
.nav-drawer.open { transform: translateX(0); }
.nav-drawer .nav-link { text-align: left; min-height: var(--su-touch); }
.hamburger { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 16px;
  border: none;
  border-radius: 3px;
  background: var(--su-raise);
  color: var(--su-text);
  font-family: var(--su-font-heading);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: #5a5e66; text-decoration: none; }
.btn:active { background: #43464c; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.primary {
  background: linear-gradient(var(--su-red-hi), var(--su-red-lo));
  color: #fff;
}
.btn.primary:hover { background: linear-gradient(#cf4d42, var(--su-red-lo)); }

.btn.gold {
  background: var(--su-gold);
  color: var(--su-game-accent-ink, #1e2124);
}
.btn.gold:hover { background: #f7cd6b; }

.btn.ghost {
  background: transparent;
  border: 1px solid var(--su-raise);
  box-shadow: none;
  color: var(--su-muted);
}
.btn.ghost:hover { color: var(--su-text); border-color: var(--su-muted); background: transparent; }

.btn.danger-ghost {
  background: transparent;
  border: 1px solid var(--su-red);
  color: var(--su-disc);
  box-shadow: none;
}
.btn.danger-ghost:hover { background: rgba(192, 57, 43, 0.15); }

.btn.block { width: 100%; }
.btn.big { min-height: var(--su-touch); font-size: 14px; padding: 10px 24px; }
.btn.small { min-height: 26px; padding: 3px 10px; font-size: 11px; }

/* ---------- Cards & panels ---------- */
.panel {
  background: var(--su-bar);
  border: 1px solid var(--su-edge);
  border-radius: var(--su-radius);
  padding: var(--su-gap-4);
}
.panel > h3:first-child, .panel > h2:first-child { margin-bottom: var(--su-gap-3); }

.panel-deep {
  background: var(--su-deep);
  border: 1px solid var(--su-edge);
  border-radius: var(--su-radius);
  padding: var(--su-gap-3);
}

.game-card {
  display: flex;
  flex-direction: column;
  gap: var(--su-gap-3);
  background: var(--su-bar);
  border: 1px solid var(--su-edge);
  border-radius: var(--su-radius);
  padding: var(--su-gap-4);
  box-shadow: var(--su-shadow-sm);
}
.game-card .art {
  height: 84px;
  border-radius: var(--su-radius);
  background:
    radial-gradient(ellipse at 50% 20%, var(--su-felt-hi) 0%, var(--su-felt-mid) 65%, var(--su-felt-lo) 100%);
  border: 3px solid var(--su-rim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--su-font-heading);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 18px;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.game-card .meta { font-size: 11px; color: var(--su-muted); }
.game-card .links { display: flex; gap: var(--su-gap-3); font-size: 11px; }
.game-card .links a { color: var(--su-muted); }
.game-card .links a:hover { color: var(--su-gold); }

/* ---------- Stat tiles ---------- */
.stat-row { display: flex; gap: var(--su-gap-2); flex-wrap: wrap; }
.stat-tile {
  background: var(--su-deep);
  color: var(--su-text);
  border-radius: var(--su-radius);
  padding: 6px 12px;
  font-size: 10px;
  line-height: 1.35;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--su-muted);
  box-shadow: var(--su-shadow-sm);
}
.stat-tile b {
  display: block;
  color: var(--su-gold);
  font-size: 14px;
  font-family: var(--su-font-heading);
  letter-spacing: 0.03em;
}

/* ---------- Felt table surface ---------- */
.felt {
  background: radial-gradient(ellipse at 50% 35%, var(--su-felt-hi) 0%, var(--su-felt-mid) 65%, var(--su-felt-lo) 100%);
  border: 9px solid var(--su-rim);
  border-radius: 999px;
  box-shadow: var(--su-felt-shadow);
}
.felt.rect { border-radius: var(--su-radius-lg); border-width: 7px; }

.felt-slot {
  width: 38px;
  height: 54px;
  border-radius: var(--su-radius);
  border: 1px dashed var(--su-felt-edge);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

/* ---------- Playing cards ---------- */
.pcard {
  width: 44px;
  height: 62px;
  border-radius: var(--su-radius);
  background: linear-gradient(160deg, var(--su-card-face-a), var(--su-card-face-b));
  border: 1px solid rgba(0, 0, 0, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--su-card-ink);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
  position: relative;
  user-select: none;
}
.pcard[data-r]::before {
  content: attr(data-r) "\A" attr(data-s);
  white-space: pre;
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.05;
  text-align: center;
}
.pcard[data-r]::after {
  content: attr(data-s);
  font-size: 24px;
  line-height: 1;
  margin-top: 8px;
}
.pcard.red { color: var(--su-card-red); }
.pcard.back {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.14) 0 2px, transparent 2px 6px),
    linear-gradient(150deg, var(--su-card-back-a), var(--su-card-back-b));
  border: 2px solid #fff;
}
.pcard.sel { outline: 2px solid var(--su-gold); outline-offset: 1px; transform: translateY(-6px); }
.pcard.small { width: 32px; height: 45px; }
.pcard.small[data-r]::before { font-size: 9px; top: 2px; left: 3px; }
.pcard.small[data-r]::after { font-size: 16px; margin-top: 6px; }
button.pcard { cursor: pointer; font: inherit; padding: 0; }
button.pcard:not(:disabled):hover { transform: translateY(-4px); }

/* ---------- Seat badges (wireframe 5e vocabulary) ---------- */
.seat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 74px;
  text-align: center;
  font-size: 10px;
  color: var(--su-text);
}
.seat .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--su-seat);
  border: 2px solid var(--su-bar);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--su-bar);
  font-size: 17px;
  position: relative;
}
.seat .label { max-width: 74px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .sub { font-size: 9px; color: var(--su-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.seat.host .avatar { border-color: var(--su-gold); box-shadow: 0 0 0 1px var(--su-gold); }
.seat.host .sub { color: var(--su-gold); }
.seat.ready .avatar { border-color: var(--su-ready); }
.seat.ready .sub { color: var(--su-ready); }
.seat.computer .avatar { opacity: 0.55; border-style: solid; }
.seat.computer .sub { color: var(--su-muted); }
.seat.empty .avatar { background: transparent; border: 2px dashed var(--su-muted); color: var(--su-muted); }
.seat.disconnected .avatar { border-color: var(--su-disc); box-shadow: 0 0 0 1px var(--su-disc); }
.seat.disconnected .sub { color: var(--su-disc); }
.seat.reserved .avatar { border: 2px dashed var(--su-warn); }
.seat.reserved .sub { color: var(--su-warn); }
.seat.ai-takeover .avatar { border-color: var(--su-warn); opacity: 0.75; }
.seat.ai-takeover .sub { color: var(--su-warn); }
.seat.turn .avatar { box-shadow: 0 0 0 3px rgba(243, 193, 75, 0.55); }

/* Player list rows (waiting room) */
.player-row {
  display: flex;
  align-items: center;
  gap: var(--su-gap-3);
  padding: 8px 10px;
  border-radius: var(--su-radius);
  background: var(--su-deep);
  min-height: var(--su-touch);
}
.player-row .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--su-muted); flex: none; }
.player-row.ready .dot { background: var(--su-ready); }
.player-row.joined .dot { background: var(--su-text); }
.player-row.disconnected .dot { background: var(--su-disc); }
.player-row.host .name::after {
  content: "HOST";
  color: var(--su-gold);
  font-size: 9px;
  letter-spacing: 0.08em;
  margin-left: 8px;
  vertical-align: 1px;
}
.player-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.player-row .state { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--su-muted); }

/* ---------- Status pills / tags ---------- */
.pill {
  background: var(--su-deep);
  color: var(--su-text);
  border-radius: var(--su-radius);
  padding: 3px 8px;
  font-size: 10px;
  line-height: 1.3;
  box-shadow: var(--su-shadow-sm);
  white-space: nowrap;
}
.pill b { color: var(--su-gold); }
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--su-raise);
  color: var(--su-text);
}
.tag.gold { background: rgba(243, 193, 75, 0.16); color: var(--su-gold); }
.tag.green { background: rgba(79, 191, 116, 0.16); color: var(--su-ready); }
.tag.red { background: rgba(192, 57, 43, 0.2); color: var(--su-disc); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--su-muted);
}
.input, select.input, textarea.input {
  background: var(--su-deep);
  border: 1px solid var(--su-raise);
  border-radius: 3px;
  color: var(--su-text);
  padding: 9px 10px;
  min-height: 38px;
  width: 100%;
}
.input:focus { border-color: var(--su-gold); outline: none; }
.input::placeholder { color: var(--su-muted); }

.seg { display: inline-flex; border: 1px solid var(--su-raise); border-radius: 3px; overflow: hidden; }
.seg .seg-opt {
  background: transparent;
  border: none;
  color: var(--su-muted);
  padding: 7px 14px;
  min-height: 34px;
  cursor: pointer;
  font-size: 12px;
}
.seg .seg-opt + .seg-opt { border-left: 1px solid var(--su-raise); }
.seg .seg-opt.active { background: var(--su-raise); color: var(--su-gold); }

.stepper { display: inline-flex; align-items: center; gap: 2px; }
.stepper button {
  width: 34px; height: 34px;
  background: var(--su-raise);
  border: none; border-radius: 3px;
  color: var(--su-text);
  font-size: 16px;
  cursor: pointer;
}
.stepper button:disabled { opacity: 0.4; cursor: not-allowed; }
.stepper .val {
  min-width: 64px;
  text-align: center;
  font-family: var(--su-font-heading);
  font-size: 15px;
  color: var(--su-gold);
}

/* Join-code segmented display / input */
.code-boxes { display: flex; gap: 6px; }
.code-boxes span, .code-boxes input {
  width: 38px;
  height: 48px;
  border-radius: 3px;
  background: var(--su-deep);
  border: 1px solid var(--su-raise);
  color: var(--su-gold);
  font: 600 20px/46px var(--su-font-mono);
  text-align: center;
  text-transform: uppercase;
  padding: 0;
}
.code-boxes input:focus { border-color: var(--su-gold); outline: none; }

.copy-field {
  display: flex;
  gap: var(--su-gap-2);
  align-items: stretch;
}
.copy-field .input { flex: 1; font-family: var(--su-font-mono); font-size: 12px; }

/* ---------- Dialogs ---------- */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--su-gap-4);
  z-index: 100;
}
.dialog {
  background: var(--su-bar);
  border: 1px solid var(--su-edge);
  border-radius: var(--su-radius-lg);
  box-shadow: var(--su-shadow-lg);
  width: min(460px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: var(--su-gap-5);
  display: flex;
  flex-direction: column;
  gap: var(--su-gap-4);
}
.dialog h2 { font-size: 17px; }
.dialog .dialog-actions { display: flex; gap: var(--su-gap-2); justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Toasts ---------- */
.toast-stack {
  position: fixed;
  bottom: var(--su-gap-4);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--su-gap-2);
  z-index: 120;
  width: min(420px, calc(100vw - 32px));
}
.toast {
  background: var(--su-deep);
  border: 1px solid var(--su-raise);
  border-left: 3px solid var(--su-gold);
  border-radius: var(--su-radius);
  box-shadow: var(--su-shadow-md);
  padding: 10px 14px;
  font-size: 13px;
}
.toast.error { border-left-color: var(--su-red); }
.toast.success { border-left-color: var(--su-ready); }

/* ---------- Table chat (t6) ---------- */
.chat-panel {
  display: flex;
  flex-direction: column;
  background: var(--su-bar);
  border: 1px solid var(--su-edge);
  border-radius: var(--su-radius);
  min-height: 0;
}
.chat-head {
  display: flex;
  align-items: center;
  gap: var(--su-gap-2);
  padding: 8px 12px;
  border-bottom: 1px solid var(--su-edge);
}
.chat-head h3 { font-size: 13px; flex: 1; }
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--su-gap-3);
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 120px;
}
.chat-msg { font-size: 13px; overflow-wrap: break-word; }
.chat-msg .who { color: var(--su-gold); font-weight: 600; margin-right: 6px; }
.chat-msg .when { color: var(--su-muted); font-size: 10px; margin-left: 6px; }
.chat-msg.system {
  color: var(--su-muted);
  font-size: 11px;
  font-style: italic;
  text-align: center;
}
.chat-msg.mine .who { color: var(--su-ready); }
.chat-quick { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 12px 8px; }
.chat-quick button {
  background: var(--su-deep);
  border: 1px solid var(--su-raise);
  border-radius: 12px;
  color: var(--su-text);
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
}
.chat-quick button:hover { border-color: var(--su-gold); }
.chat-input-row { display: flex; gap: 6px; padding: 8px 12px 12px; }
.chat-input-row .input { min-height: 36px; }
.chat-closing {
  padding: 6px 12px;
  background: rgba(224, 163, 78, 0.12);
  color: var(--su-warn);
  font-size: 11px;
  text-align: center;
  border-top: 1px solid var(--su-edge);
}

/* Mobile chat bottom sheet */
.chat-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-height: 70vh;
  background: var(--su-bar);
  border-top: 1px solid var(--su-edge);
  border-radius: 12px 12px 0 0;
  box-shadow: var(--su-shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 90;
  transform: translateY(100%);
  transition: transform 0.2s ease;
}
.chat-sheet.open { transform: translateY(0); }
.chat-sheet .grab {
  width: 42px; height: 4px;
  border-radius: 2px;
  background: var(--su-raise);
  margin: 8px auto 4px;
}

/* ---------- Action bar (game controls) ---------- */
.action-bar {
  display: flex;
  gap: var(--su-gap-2);
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--su-bar);
  border-top: 1px solid var(--su-edge);
}

/* Turn timer */
.timer-ring {
  font-family: var(--su-font-mono);
  font-size: 12px;
  color: var(--su-gold);
  background: var(--su-deep);
  border-radius: var(--su-radius);
  padding: 4px 8px;
}
.timer-ring.low { color: var(--su-disc); }

/* ---------- States: loading / error / empty / disconnected ---------- */
.state-block {
  text-align: center;
  padding: var(--su-gap-6) var(--su-gap-4);
  color: var(--su-muted);
}
.state-block h2 { color: var(--su-text); margin-bottom: var(--su-gap-2); }

.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--su-raise);
  border-top-color: var(--su-gold);
  border-radius: 50%;
  animation: su-spin 0.8s linear infinite;
  margin: 0 auto var(--su-gap-3);
}
@keyframes su-spin { to { transform: rotate(360deg); } }

.conn-banner {
  background: var(--su-red-lo);
  color: #fff;
  text-align: center;
  font-size: 12px;
  padding: 6px 12px;
}
.conn-banner.reconnecting { background: #8a6d2a; }

/* ---------- Responsive ---------- */
@media (max-width: 719px) {
  .app-header nav.desktop-nav { display: none; }
  .hamburger { display: inline-flex; }
  .view { padding: var(--su-gap-4) var(--su-gap-3) calc(var(--su-gap-6) * 2); }
  .grid-cards { grid-template-columns: 1fr; }
  .dialog { padding: var(--su-gap-4); }
}
@media (min-width: 720px) {
  .nav-drawer, .chat-sheet { display: none; }
}
