/* Protan safe palette: blue anchors, amber accents, neutral grays. */
:root {
  --blue: #0072b2;
  --blue-dark: #2e2585;
  --sky: #94cbec;
  --amber: #ffb000;
  --teal: #5da899;
  --ink: #1f2933;
  --muted: #52606d;
  --line: #d9dee3;
  --paper: #ffffff;
  --ground: #f4f6f8;
  --card-face: #fffdf5;
}

* {
  box-sizing: border-box;
}

/* Keep the hidden attribute winning over display rules on classes. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--ground);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: #eef1f4;
  padding: 0 4px;
  border-radius: 4px;
}

h1,
h2 {
  margin: 0 0 8px;
  line-height: 1.2;
}

h2 {
  font-size: 1.25rem;
}

/* Header and navigation. */
.site-header {
  padding: 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.site-title {
  font-size: 1.5rem;
}

.site-tagline {
  margin: 0 0 16px;
  color: var(--muted);
}

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

.tab {
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.tab.is-active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

main {
  padding: 16px;
}

.panel {
  max-width: 960px;
  margin: 0 auto;
}

.hint {
  margin: 0 0 16px;
  color: var(--muted);
}

/* Forms and controls. */
.seat-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 16px;
}

.seats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 0;
  padding: 8px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.seats legend {
  padding: 0 4px;
  color: var(--muted);
}

.seat {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
}

.seat-name {
  font-weight: 600;
}

.seat select,
.seat input {
  min-height: 44px;
  min-width: 0;
  padding: 8px;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.seat input {
  width: 80px;
}

.seat-remove {
  min-height: 44px;
  padding: 8px 12px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control input[type="number"],
.control select {
  min-height: 44px;
  padding: 8px;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.control input[type="number"] {
  width: 112px;
}

.btn {
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: var(--paper);
  color: var(--blue);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn:disabled {
  border-color: var(--line);
  color: var(--muted);
  cursor: default;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
}

.btn-primary:disabled {
  background: var(--line);
  border-color: var(--line);
}

/* The table. */
.table {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-center {
  display: flex;
  justify-content: center;
  gap: 32px;
}

.pile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.pile-label,
.pile-note {
  font-size: 0.875rem;
  color: var(--muted);
}

.card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 56px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card-face);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--blue-dark);
}

.card-llama {
  color: var(--ink);
  background: #fff3c4;
  border-color: var(--amber);
}

.card-big {
  width: 64px;
  height: 88px;
  font-size: 2rem;
}

.card-back {
  background: repeating-linear-gradient(
    45deg,
    var(--blue-dark),
    var(--blue-dark) 4px,
    var(--blue) 4px,
    var(--blue) 8px
  );
  color: #fff;
  font-size: 1rem;
}

.card-hidden {
  background: var(--sky);
  border-color: var(--blue);
  color: var(--blue-dark);
  font-size: 1rem;
}

.card-playable {
  outline: 3px solid var(--amber);
  outline-offset: 1px;
}

.table-seats-view {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.seat-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.seat-view.is-current {
  border-color: var(--amber);
  box-shadow: 0 0 0 2px var(--amber);
}

.seat-view.is-folded {
  opacity: 0.6;
}

.seat-view-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.seat-view-name {
  font-weight: 600;
}

.seat-view-meta {
  color: var(--muted);
  font-size: 0.875rem;
}

.badge {
  padding: 0 8px;
  border-radius: 999px;
  background: var(--sky);
  color: var(--blue-dark);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-quit {
  background: #eef1f4;
  color: var(--muted);
}

.badge-turn {
  background: var(--amber);
  color: var(--ink);
}

.hand {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.actions {
  padding: 16px;
  border: 1px solid var(--amber);
  border-radius: 8px;
  background: #fff8e1;
}

.actions-prompt {
  margin: 0 0 8px;
  font-weight: 600;
}

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

.table-status {
  margin: 0;
  font-weight: 600;
}

.log {
  max-height: 240px;
  margin: 0;
  padding: 0 0 0 24px;
  overflow-y: auto;
  color: var(--muted);
  font-size: 0.875rem;
}

.log li.is-mine {
  color: var(--ink);
}

/* Arena. */
.progress {
  height: 8px;
  margin-bottom: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: var(--blue);
  transition: width 0.2s;
}

.results {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.results th,
.results td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.results th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.875rem;
}

.results td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.results tr.is-leader td {
  font-weight: 700;
}

/* Bot roster. */
.bot-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.bot {
  padding: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.bot-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.bot-name {
  font-weight: 700;
}

.bot-description {
  margin: 0;
  color: var(--muted);
}

.bot-record {
  margin: 8px 0 0;
  font-size: 0.875rem;
  color: var(--ink);
}

/* Editor. */
.editor-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

.editor {
  width: 100%;
  min-height: 320px;
  margin-bottom: 16px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  resize: vertical;
}

.site-footer {
  max-width: 960px;
  margin: 32px auto 0;
  padding: 16px;
  color: var(--muted);
  font-size: 0.875rem;
}

@media (min-width: 768px) {
  .site-header,
  main {
    padding: 24px;
  }

  .table-seats-view {
    grid-template-columns: 1fr 1fr;
  }

  .bot-list {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1024px) {
  .table-seats-view {
    grid-template-columns: 1fr 1fr 1fr;
  }
}
