:root {
  --bg: #070501;
  --panel: #120c02;
  --panel-soft: #1b1203;
  --text: #ffb000;
  --muted: #a87100;
  --line: rgba(255, 176, 0, 0.62);
  --line-soft: rgba(255, 176, 0, 0.22);
  --shadow: rgba(255, 176, 0, 0.14);
  --danger: #ff6b35;
  --overlay-red: rgba(218, 49, 49, 0.16);
  --overlay-green: rgba(112, 159, 115, 0.16);
  --overlay-blue: rgba(40, 129, 206, 0.16);
  --page-width: 960px;
  --panel-height: 272px;
  --font: "Cascadia Mono", Consolas, "Lucida Console", monospace;
}

html[data-theme="green"] {
  --bg: #020805;
  --panel: #06140b;
  --panel-soft: #0b1d11;
  --text: #43ff88;
  --muted: #269854;
  --line: rgba(67, 255, 136, 0.62);
  --line-soft: rgba(67, 255, 136, 0.22);
  --shadow: rgba(67, 255, 136, 0.14);
}

html[data-theme="magenta"] {
  --bg: #101118;
  --panel: #18171f;
  --panel-soft: #24212b;
  --text: #ff4f7d;
  --muted: #bf3d66;
  --line: rgba(255, 79, 125, 0.66);
  --line-soft: rgba(255, 79, 125, 0.24);
  --shadow: rgba(255, 79, 125, 0.17);
}

html[data-theme="white"] {
  --bg: #060606;
  --panel: #101010;
  --panel-soft: #1a1a1a;
  --text: #f0f0dc;
  --muted: #9c9c8d;
  --line: rgba(240, 240, 220, 0.58);
  --line-soft: rgba(240, 240, 220, 0.2);
  --shadow: rgba(240, 240, 220, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  content: "";
  background:
    repeating-linear-gradient(
      var(--overlay-red) 0,
      var(--overlay-green) 2px,
      var(--overlay-blue) 4px
    ),
    repeating-linear-gradient(
      90deg,
      var(--overlay-red) 1px,
      var(--overlay-green) 2px,
      var(--overlay-blue) 3px
    );
  mix-blend-mode: overlay;
  opacity: 0.2;
}

a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px dashed var(--line);
}

a:hover,
a:focus {
  background: var(--text);
  color: var(--bg);
  outline: none;
}

button,
input {
  font: inherit;
}

.page-shell {
  width: min(var(--page-width), calc(100vw - 24px));
  margin: 18px auto;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.34);
  box-shadow: 0 0 28px var(--shadow);
}

.console-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  font-size: 13px;
  text-transform: uppercase;
}

.console-bar strong {
  padding: 2px 8px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
}

.console-bar time {
  justify-self: end;
}

.console-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 12px;
}

.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  height: var(--panel-height);
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-soft), var(--panel));
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.28);
}

.panel--auto {
  height: auto;
  min-height: var(--panel-height);
}

.panel--wide {
  grid-column: 1 / -1;
}

.panel__header {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  min-height: 38px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(0, 0, 0, 0.2);
  text-transform: uppercase;
}

.panel__header span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 20px;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
}

h1,
h2,
p,
dl,
ul {
  margin: 0;
}

h1,
h2 {
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel__body,
.data-list,
.chat-layout {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px;
}

.panel__body {
  overflow: hidden;
  line-height: 1.48;
}

.panel__body--center {
  display: grid;
  align-content: center;
  gap: 18px;
  text-align: center;
}

.brand-body {
  display: grid;
  align-content: start;
  gap: 12px;
}

.brand-logo {
  display: block;
  width: min(230px, 100%);
  height: auto;
  opacity: 0.92;
}

.slogan {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.16;
  text-transform: uppercase;
}

.status-line {
  color: var(--muted);
  font-size: 13px;
}

.data-list {
  display: grid;
  gap: 10px;
  overflow: hidden;
}

.data-list div {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  min-width: 0;
  border-bottom: 1px dotted var(--line-soft);
  padding-bottom: 8px;
}

.data-list--compact {
  gap: 7px;
  font-size: 12px;
  line-height: 1.18;
}

.data-list--compact div {
  grid-template-columns: 96px minmax(0, 1fr);
  padding-bottom: 3px;
}

.data-list--contact div,
.data-list--visitor div,
.data-list--legal div,
.data-list--privacy div {
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 8px;
}

.data-list--contact a {
  white-space: nowrap;
}

.data-list--legal,
.data-list--privacy {
  gap: 7px;
  font-size: 12px;
  line-height: 1.22;
}

.data-list--legal div,
.data-list--privacy div {
  padding-bottom: 4px;
}

dt {
  color: var(--muted);
  text-transform: uppercase;
}

dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

.terminal-list {
  display: grid;
  gap: 10px;
  padding: 0;
  list-style: none;
}

.terminal-list li::before {
  content: "> ";
  color: var(--muted);
}

.chat-layout {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 10px;
  overflow: hidden;
}

.chat-log {
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  padding: 10px;
  background: rgba(0, 0, 0, 0.22);
}

.message {
  margin: 0 0 9px;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.message:last-child {
  margin-bottom: 0;
}

.message__role {
  color: var(--muted);
  text-transform: uppercase;
}

.command-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  text-transform: uppercase;
}

.command-row button,
.chat-form button {
  min-height: 32px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.command-row button {
  padding: 5px 9px;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px;
  gap: 8px;
}

.chat-form input {
  min-width: 0;
  min-height: 36px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  padding: 7px 9px;
  text-transform: uppercase;
}

.chat-form input::placeholder {
  color: var(--muted);
}

.command-row button:hover,
.command-row button:focus,
.chat-form button:hover,
.chat-form button:focus {
  background: var(--text);
  color: var(--bg);
  outline: none;
}

.chat-form button:disabled,
.chat-form input:disabled {
  opacity: 0.58;
  cursor: wait;
}

.chat-form button {
  text-transform: uppercase;
}

[hidden] {
  display: none !important;
}

.brave-grid {
  align-items: start;
}

.brave-rats-page {
  text-transform: uppercase;
}

.brave-intro {
  display: grid;
  gap: 12px;
}

.join-form,
.lobby-layout,
.game-layout {
  display: grid;
  gap: 14px;
}

.join-form label,
.mini-heading {
  color: var(--muted);
  font-size: 13px;
}

.join-form__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 8px;
}

.join-form input,
.join-form button,
.brave-actions button,
.lobby-player button,
.rat-card {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  font: inherit;
  text-transform: uppercase;
}

.join-form input {
  min-width: 0;
  min-height: 40px;
  padding: 8px 10px;
}

.join-form button,
.brave-actions button,
.lobby-player button {
  min-height: 40px;
  padding: 8px 10px;
  cursor: pointer;
}

.join-form button:hover,
.join-form button:focus,
.brave-actions button:hover,
.brave-actions button:focus,
.lobby-player button:hover,
.lobby-player button:focus,
.rat-card:hover,
.rat-card:focus {
  background: var(--text);
  color: var(--bg);
  outline: none;
}

.lobby-list {
  display: grid;
  gap: 8px;
}

.lobby-player {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px dotted var(--line-soft);
}

.lobby-player div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.lobby-player span,
.empty-state {
  color: var(--muted);
  font-size: 13px;
}

.brave-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.score-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.score-board div,
.played-card {
  min-width: 0;
  border: 1px solid var(--line-soft);
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
}

.score-board span,
.played-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.score-board strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.round-status {
  display: grid;
  gap: 5px;
  padding: 10px;
  border-left: 3px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
}

.choice-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.played-card {
  display: grid;
  gap: 5px;
  min-height: 96px;
}

.played-card strong {
  font-size: 16px;
}

.played-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.hand-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.rat-card {
  display: grid;
  gap: 5px;
  min-height: 132px;
  padding: 9px;
  text-align: left;
  cursor: pointer;
}

.rat-card:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.rat-card--revealed-pick {
  border-style: dashed;
}

.rat-card__number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 22px;
  border: 1px solid currentColor;
  font-size: 13px;
}

.rat-card strong {
  font-size: 14px;
}

.rat-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.28;
}

.rat-card:hover p,
.rat-card:focus p {
  color: var(--bg);
}

.round-log {
  display: grid;
  gap: 6px;
  border-top: 1px dotted var(--line-soft);
  padding-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.rules-grid p {
  border-left: 2px solid var(--line);
  padding-left: 9px;
}

.system-message {
  min-height: 34px;
  padding: 8px 12px 12px;
  color: var(--muted);
  font-size: 12px;
}

.system-message[data-state="error"] {
  color: var(--danger);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  :root {
    --page-width: 360px;
    --panel-height: 300px;
  }

  .page-shell {
    margin: 8px auto;
  }

  .console-bar {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .console-bar time {
    justify-self: start;
  }

  .console-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }

  .panel--wide {
    grid-column: auto;
  }

  .slogan {
    font-size: 20px;
  }

  .data-list div {
    grid-template-columns: 86px minmax(0, 1fr);
  }

  .data-list--contact div,
  .data-list--visitor div,
  .data-list--legal div,
  .data-list--privacy div {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 7px;
  }

  .data-list--privacy {
    gap: 6px;
    font-size: 11px;
    line-height: 1.16;
  }

  .join-form__row,
  .lobby-player,
  .choice-row,
  .rules-grid {
    grid-template-columns: 1fr;
  }

  .score-board {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .hand-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rat-card {
    min-height: 146px;
  }

}
