:root {
  --bg: #0b0e14;
  --panel: #141821;
  --panel-2: #1b2029;
  --line: #262c38;
  --text: #e6e9ef;
  --muted: #8b93a5;
  --accent: #6ea8fe;
  --red: #e5484d;
  --green: #30a46c;
  --blue: #0091ff;
  --yellow: #ffb224;
  --silver: #b3b8c7;
  --ok: #30a46c;
  --warn: #ffb224;
  --bad: #e5484d;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.hidden {
  display: none !important;
}

/* ---------- Startbildschirm ---------- */

.entry {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1000px 500px at 20% -10%, #1a2740 0%, transparent 60%),
    radial-gradient(800px 400px at 90% 110%, #2a1a2e 0%, transparent 60%);
}

.entry-card {
  width: min(520px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.entry-card h1 {
  margin: 0 0 8px;
  font-size: 30px;
  letter-spacing: -0.02em;
}

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

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 18px;
}

input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 11px 13px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}

input:focus {
  border-color: var(--accent);
}

button {
  padding: 11px 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}

button:hover:not(:disabled) {
  background: #232a36;
  border-color: #37404f;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06122a;
  font-weight: 600;
}

button.primary:hover:not(:disabled) {
  background: #86b8ff;
  border-color: #86b8ff;
}

button.ghost {
  background: transparent;
}

button.small {
  padding: 6px 10px;
  font-size: 13px;
}

.entry-actions {
  display: grid;
  gap: 14px;
}

.or {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.join-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.join-row input {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  text-align: center;
  font-weight: 600;
}

.entry-error {
  color: var(--bad);
  min-height: 22px;
  margin: 12px 0 0;
  font-size: 14px;
}

.rules {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

.rules summary {
  cursor: pointer;
}

.rules ul {
  padding-left: 20px;
}

.rules li {
  margin: 8px 0;
}

/* ---------- Spiel-Layout ---------- */

.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  height: 100%;
  padding: 20px;
}

.board-pane {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.board-wrap {
  position: relative;
  aspect-ratio: 1;
  width: min(100%, calc(100vh - 40px));
}

canvas#board {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: var(--radius);
  touch-action: manipulation;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(11, 14, 20, 0.72);
  backdrop-filter: blur(3px);
  border-radius: var(--radius);
  text-align: center;
  padding: 24px;
}

.overlay h2 {
  margin: 0 0 8px;
  font-size: 26px;
}

.overlay p {
  margin: 4px 0;
  color: var(--muted);
}

.touchpad {
  display: none;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(2, 44px);
  gap: 6px;
}

.touchpad button {
  padding: 0;
  font-size: 20px;
}

/* Reihenfolge im HTML: hoch, links, runter, rechts */
.touchpad button:nth-child(1) {
  grid-area: 1 / 2;
}
.touchpad button:nth-child(2) {
  grid-area: 2 / 1;
}
.touchpad button:nth-child(3) {
  grid-area: 2 / 2;
}
.touchpad button:nth-child(4) {
  grid-area: 2 / 3;
}

/* ---------- Seitenleiste ---------- */

.side {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
}

.side h2 {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.room-label {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.room-code {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.phase-box,
.action-box,
.players,
.log-box,
.chat-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.phase-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.phase-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.timer {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 600;
}

.timer.urgent {
  color: var(--bad);
}

.timer-bar {
  height: 4px;
  background: var(--panel-2);
  border-radius: 2px;
  margin-top: 10px;
  overflow: hidden;
}

.timer-bar > div {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.25s linear;
}

.timer-bar.urgent > div {
  background: var(--bad);
}

.target-box {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.target-box canvas {
  width: 56px;
  height: 56px;
  flex: none;
}

.target-title {
  font-weight: 600;
}

.target-hint {
  color: var(--muted);
  font-size: 13px;
}

.action-box {
  display: grid;
  gap: 10px;
}

.action-hint {
  color: var(--muted);
  font-size: 13px;
}

.bid-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.bid-grid button {
  padding: 9px 0;
  font-variant-numeric: tabular-nums;
}

.bid-grid button.mine {
  background: var(--accent);
  border-color: var(--accent);
  color: #06122a;
  font-weight: 700;
}

.row {
  display: flex;
  gap: 8px;
}

.row > * {
  flex: 1;
}

.players ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.players li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--panel-2);
}

.players li.you {
  outline: 1px solid #37455e;
}

.players li.demo {
  background: #21324a;
}

.players li.away .pname {
  opacity: 0.45;
}

.pname {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pname .host {
  color: var(--muted);
  font-size: 12px;
  margin-left: 5px;
}

.pbid {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--accent);
  min-width: 24px;
  text-align: right;
}

.pscore {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 30px;
  text-align: right;
}

.log,
.chat {
  max-height: 150px;
  overflow: auto;
  font-size: 13px;
  color: var(--muted);
  display: grid;
  gap: 4px;
}

.chat {
  max-height: 120px;
  margin-bottom: 8px;
}

.chat b {
  color: var(--text);
  font-weight: 600;
}

.log div.hi {
  color: var(--text);
}

#chatForm input {
  margin: 0;
}

@media (max-width: 900px) {
  .game {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
    padding: 12px;
  }

  .board-wrap {
    width: min(100%, 92vw);
  }

  .touchpad {
    display: grid;
  }

  .side {
    overflow: visible;
  }
}

.muted { color: var(--muted); }

/* Drei Bedienelemente passen neben den Raumcode nicht zuverlässig in die
   Seitenleiste — auf Dänisch oder Deutsch sind die Wörter länger als auf
   Englisch. Deshalb bekommen sie eine eigene Zeile. */
.head-actions {
  display: flex;
  gap: 6px;
  flex: 1 1 100%;
}

.head-actions .theme-select {
  flex: 1 1 0;
  min-width: 0;
}

.head-actions button {
  white-space: nowrap;
}

.theme-select {
  padding: 6px 8px;
  font-size: 13px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  max-width: 150px;
}

.theme-select:hover {
  border-color: #37404f;
}

.entry-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.entry-head h1 {
  margin: 0 0 8px;
}
