:root {
  color-scheme: dark;
  --bg: #0d100c;
  --panel: rgba(24, 28, 21, 0.92);
  --panel-2: rgba(34, 39, 29, 0.9);
  --line: rgba(229, 221, 184, 0.18);
  --line-strong: rgba(229, 221, 184, 0.34);
  --text: #f4efd9;
  --muted: #aaa88f;
  --gold: #d9b85b;
  --gold-soft: #f0dda2;
  --green: #7fb66b;
  --red: #d47465;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -10%, rgba(91, 114, 68, 0.25), transparent 32rem),
    radial-gradient(circle at 90% 12%, rgba(129, 85, 41, 0.18), transparent 34rem),
    linear-gradient(145deg, #0a0d09 0%, #11150f 50%, #0c0f0b 100%);
}

button, input, select { font: inherit; }
button { color: inherit; }

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.4;
  background-image:
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, black, transparent 75%);
}

.shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 60px;
  position: relative;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 24px;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(2.1rem, 4vw, 4.2rem); letter-spacing: -0.055em; line-height: 0.95; }
h2 { margin-bottom: 10px; font-size: clamp(1.35rem, 2.2vw, 2.15rem); letter-spacing: -0.035em; }

.eyebrow, .section-kicker, .label, .seat-label, .life-caption {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--gold-soft);
}

.eyebrow { margin-bottom: 10px; }
.section-kicker { margin-bottom: 7px; }

.connection {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(14, 17, 12, 0.78);
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #747567;
  box-shadow: 0 0 0 5px rgba(116,117,103,0.08);
}

body[data-voice-state="connecting"] .status-dot { background: var(--gold); animation: pulse 1s infinite alternate; }
body[data-voice-state="listening"] .status-dot,
body[data-voice-state="active"] .status-dot { background: var(--green); box-shadow: 0 0 0 5px rgba(127,182,107,0.1); }
body[data-voice-state="ended"] .status-dot { background: var(--red); }

.mic-level {
  display: inline-flex;
  width: 36px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}

.mic-level span {
  width: 100%;
  height: 100%;
  transform: scaleX(0.03);
  transform-origin: left;
  background: var(--green);
  transition: transform 80ms linear;
}

.setup-panel, .game-table, .control-deck, .panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.setup-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(520px, 1.5fr);
  gap: 34px;
  align-items: end;
  padding: 24px;
  border-radius: 22px;
  margin-bottom: 18px;
}

.setup-copy p:last-child { color: var(--muted); line-height: 1.55; margin-bottom: 0; max-width: 64ch; }

.setup-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1.25fr auto;
  gap: 10px;
  align-items: end;
}

.setup-form label, .text-fallback label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

input, select {
  width: 100%;
  color: var(--text);
  background: rgba(9, 12, 8, 0.72);
  border: 1px solid var(--line);
  border-radius: 11px;
  min-height: 45px;
  padding: 0 12px;
  outline: none;
}

input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(217,184,91,0.12); }
input:disabled, select:disabled { opacity: 0.55; }

button {
  border: 0;
  cursor: pointer;
}
button:disabled { cursor: not-allowed; opacity: 0.36; }

.primary-button, .action-button, .text-fallback button {
  min-height: 45px;
  border-radius: 11px;
  padding: 0 17px;
  font-weight: 850;
  letter-spacing: -0.01em;
}

.primary-button {
  background: var(--gold);
  color: #17140a;
  white-space: nowrap;
}
.primary-button:hover:not(:disabled) { filter: brightness(1.08); }

.game-table {
  border-radius: 26px;
  padding: 20px;
  overflow: hidden;
  position: relative;
}

.game-table::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 35%, rgba(109, 128, 82, 0.16), transparent 45%);
}

.turn-ribbon {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  margin: -4px 0 18px;
  padding: 0 2px 15px;
}

.turn-ribbon > div { display: flex; gap: 10px; align-items: baseline; }
.turn-ribbon strong { font-size: 1.05rem; }

.life-card {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(30, 36, 27, 0.96), rgba(15, 18, 13, 0.96));
  display: grid;
  justify-items: center;
  align-content: center;
  padding: 18px;
  box-shadow: inset 0 1px rgba(255,255,255,0.03);
}

.player-card {
  min-height: clamp(245px, 31vw, 430px);
  border-color: rgba(217,184,91,0.38);
  background:
    radial-gradient(circle at 50% 50%, rgba(217,184,91,0.08), transparent 44%),
    linear-gradient(145deg, rgba(35, 39, 27, 0.98), rgba(14, 17, 12, 0.98));
}

.life-total {
  font-size: clamp(7rem, 20vw, 18rem);
  line-height: 0.76;
  letter-spacing: -0.09em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 10px 50px rgba(0,0,0,0.35);
}

.player-card .seat-label { font-size: 0.85rem; margin-bottom: 23px; }
.player-card .life-caption { margin-top: 25px; color: var(--muted); }

.opponents {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.opponent-card { min-height: 165px; }
.opponent-card .life-total { font-size: clamp(4rem, 8vw, 7.5rem); line-height: 0.85; }
.opponent-card .seat-label { margin-bottom: 17px; }
.opponent-card .life-caption { margin-top: 14px; color: var(--muted); }
.life-card.eliminated { opacity: 0.42; filter: grayscale(1); }
.life-card.eliminated::after {
  content: "ELIMINATED";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 900;
  letter-spacing: 0.14em;
  transform: rotate(-8deg);
  color: var(--red);
  text-shadow: 0 2px 16px #000;
}

.table-stats {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.table-stats > div {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(8, 11, 7, 0.48);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}
.table-stats span { color: var(--muted); font-size: 0.78rem; }
.table-stats strong { font-size: 1.8rem; line-height: 1; font-variant-numeric: tabular-nums; }

.latest-pressure {
  position: relative;
  display: grid;
  gap: 5px;
  margin-top: 12px;
  padding: 16px 18px;
  border-left: 3px solid var(--gold);
  background: rgba(217,184,91,0.07);
  border-radius: 4px 14px 14px 4px;
}
.latest-pressure span { color: var(--gold-soft); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.68rem; font-weight: 800; }
.latest-pressure strong { font-size: clamp(1rem, 2vw, 1.35rem); font-weight: 720; }

.control-deck {
  display: grid;
  grid-template-columns: auto auto auto minmax(280px, 1fr);
  gap: 10px;
  align-items: end;
  border-radius: 18px;
  padding: 14px;
  margin-top: 18px;
}

.action-button { background: var(--panel-2); border: 1px solid var(--line); }
.action-button:hover:not(:disabled) { border-color: var(--line-strong); background: #343b2d; }
.action-button.danger { color: #f0b1a8; }

.text-fallback { display: grid; gap: 6px; }
.text-fallback > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.text-fallback button { background: var(--gold-soft); color: #17140a; }

.information-grid {
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: 18px;
  margin-top: 18px;
}

.panel { border-radius: 20px; padding: 20px; min-height: 330px; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.panel-heading h2 { margin: 0; }
.text-button { background: transparent; color: var(--muted); padding: 7px; }
.text-button:hover { color: var(--text); }

.event-log {
  margin: 0;
  padding: 14px 0 0;
  list-style: none;
  display: grid;
  gap: 8px;
  max-height: 440px;
  overflow: auto;
}
.event-log li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 11px 12px;
  border: 1px solid rgba(255,255,255,0.055);
  border-radius: 11px;
  background: rgba(5,8,5,0.28);
}
.event-log .event-turn { color: var(--gold-soft); font-weight: 850; font-size: 0.75rem; min-width: 44px; }
.event-log .event-text { color: #d8d5c2; line-height: 1.42; }
.event-log .event-type { display: block; margin-top: 4px; color: #767968; text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.61rem; }

.transcript {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-top: 14px;
  max-height: 440px;
  overflow: auto;
}
.transcript:empty::before { content: "Live captions will appear here."; color: #727666; }
.transcript-line {
  max-width: 88%;
  border-radius: 14px;
  padding: 10px 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.transcript-line.user { align-self: flex-end; background: rgba(217,184,91,0.14); border: 1px solid rgba(217,184,91,0.2); }
.transcript-line.assistant { align-self: flex-start; background: rgba(127,182,107,0.1); border: 1px solid rgba(127,182,107,0.16); }
.transcript-role { display: block; text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.61rem; font-weight: 850; color: var(--muted); margin-bottom: 4px; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: min(390px, calc(100% - 44px));
  padding: 13px 16px;
  border-radius: 12px;
  background: #efe4bb;
  color: #1a180f;
  font-weight: 750;
  box-shadow: var(--shadow);
  transform: translateY(140%);
  transition: transform 180ms ease;
}
.toast.visible { transform: translateY(0); }

@keyframes pulse { to { transform: scale(1.25); filter: brightness(1.3); } }

@media (max-width: 1040px) {
  .setup-panel { grid-template-columns: 1fr; }
  .setup-form { grid-template-columns: 1fr 1fr; }
  .control-deck { grid-template-columns: repeat(3, 1fr); }
  .text-fallback { grid-column: 1 / -1; }
  .information-grid { grid-template-columns: 1fr; }
}

@media (max-width: 690px) {
  .shell { width: min(100% - 18px, 1500px); padding-top: 15px; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 14px; }
  .connection { width: 100%; justify-content: center; }
  .setup-panel, .game-table, .panel { border-radius: 17px; }
  .setup-panel { padding: 17px; }
  .setup-form { grid-template-columns: 1fr; }
  .turn-ribbon { grid-template-columns: 1fr; gap: 6px; }
  .life-total { font-size: clamp(7rem, 40vw, 12rem); }
  .player-card { min-height: 280px; }
  .opponents { grid-template-columns: 1fr; }
  .opponent-card { min-height: 135px; grid-template-columns: auto 1fr auto; justify-items: start; align-items: center; align-content: center; column-gap: 18px; }
  .opponent-card .seat-label, .opponent-card .life-caption { margin: 0; }
  .opponent-card .life-total { font-size: 5.4rem; }
  .table-stats { grid-template-columns: 1fr 1fr; }
  .control-deck { grid-template-columns: 1fr 1fr; }
  .control-deck .danger { grid-column: 1 / -1; }
  .panel { padding: 16px; }
}
