:root {
  --bg: #050816;
  --bg-elevated: #0b1020;
  --accent: #ffb347;
  --accent-soft: rgba(255, 179, 71, 0.12);
  --accent-strong: #ff8c42;
  --border-subtle: rgba(255, 255, 255, 0.06);
  --text: #f7fafc;
  --text-muted: #a0aec0;
  --danger: #f56565;
  --success: #48bb78;
  --shadow-soft: 0 18px 40px rgba(0, 0, 0, 0.6);
  --radius-lg: 18px;
  --radius-pill: 999px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #151a3a 0, #050816 50%, #02010a 100%);
  color: var(--text);
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

.shell {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.05), rgba(15, 23, 42, 0.9));
  border-radius: 26px;
  padding: 18px;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
  min-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
}

.shell-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: radial-gradient(circle at 30% 0, #ffe9c2 0, #ffb347 40%, #ff8c42 70%, #6b46c1 100%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #1a202c;
}

.brand-text-main {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-text-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.shell-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pill {
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.4);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
}

.pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(72, 187, 120, 0.25);
}

.shell-main {
  flex: 1;
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.view {
  display: none;
}

.view--active {
  display: block;
}

.card {
  background: radial-gradient(circle at top, rgba(15, 23, 42, 0.9) 0, rgba(11, 16, 32, 0.9) 45%, rgba(15, 23, 42, 0.95) 100%);
  border-radius: 22px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.85);
  padding: 18px 18px 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.card-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.card-section-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.1fr);
  gap: 16px;
}

@media (max-width: 900px) {
  .shell {
    min-height: 100vh;
    padding: 14px;
  }

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

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.field-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

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

.input {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  padding: 8px 12px;
  min-width: 0;
  background: rgba(15, 23, 42, 0.7);
  color: var(--text);
  font-size: 0.9rem;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(255, 179, 71, 0.8);
}

.input-room-code {
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

button {
  font-family: inherit;
}

.btn {
  border-radius: 999px;
  border: none;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.08s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #1a202c;
  box-shadow: 0 12px 25px rgba(255, 179, 71, 0.45);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 38px rgba(255, 179, 71, 0.6);
}

.btn-secondary {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  border: 1px solid rgba(148, 163, 184, 0.7);
}

.btn-secondary:hover {
  background: rgba(15, 23, 42, 0.95);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  border-radius: 999px;
  border: 1px dashed rgba(148, 163, 184, 0.6);
  color: var(--text-muted);
}

.btn-ghost:hover {
  border-style: solid;
  color: var(--text);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.78rem;
}

.btn-icon {
  padding: 6px;
  border-radius: 999px;
  width: 30px;
  height: 30px;
}

.btn[disabled] {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
  transform: none;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.tag-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

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

.text-small {
  font-size: 0.8rem;
}

.text-mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.divider {
  height: 1px;
  background: radial-gradient(circle, rgba(148, 163, 184, 0.4), transparent 60%);
  opacity: 0.7;
  margin: 10px 0 12px;
}

.horizontal-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.horizontal-stack-left,
.horizontal-stack-right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.status-chip {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.85);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
}

.status-chip-dot--waiting {
  background: var(--accent);
}

.status-chip-dot--playing {
  background: var(--success);
}

.status-chip-dot--finished {
  background: var(--danger);
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.list-item {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.list-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.list-item-title {
  font-size: 0.9rem;
}

.list-item-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.badge-pill {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.5);
}

.alert {
  border-radius: 16px;
  padding: 8px 10px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.alert-info {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.alert-error {
  background: rgba(245, 101, 101, 0.12);
  border: 1px solid rgba(245, 101, 101, 0.4);
}

.alert-success {
  background: rgba(72, 187, 120, 0.12);
  border: 1px solid rgba(72, 187, 120, 0.4);
}

.alert-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.alert-dot--info {
  background: #63b3ed;
}

.alert-dot--error {
  background: #f56565;
}

.alert-dot--success {
  background: #48bb78;
}

.alert-text {
  flex: 1;
}

.alert-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

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

.kpi {
  flex: 1 1 120px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 16px;
  background: radial-gradient(circle at top left, rgba(148, 163, 184, 0.4), rgba(15, 23, 42, 0.9));
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.kpi-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 0.95rem;
  font-weight: 600;
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.game-layout {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
}

.game-top-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.game-top-left,
.game-top-right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.game-board {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.2fr);
  gap: 12px;
}

@media (max-width: 900px) {
  .game-board {
    grid-template-columns: minmax(0, 1fr);
  }
}

.pile-card {
  border-radius: 18px;
  padding: 10px;
  background: radial-gradient(circle at top, rgba(148, 163, 184, 0.45), rgba(15, 23, 42, 0.9));
  border: 1px solid rgba(148, 163, 184, 0.6);
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pile-card--draw {
  background: radial-gradient(circle at top, #0f172a, #020617);
}

.pile-card--discard {
  background: linear-gradient(180deg, #7f1d1d, #b91c1c);
  border-color: rgba(248, 113, 113, 0.8);
}

.pile-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pile-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.card-visual {
  width: 52px;
  height: 72px;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.9);
  background: radial-gradient(circle at top, #ffe9c2, #ffb347, #ff8c42);
  color: #1a202c;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.8);
}

.card-visual.small {
  width: 40px;
  height: 56px;
  border-radius: 8px;
  font-size: 0.8rem;
}

.card-visual-back {
  background: repeating-linear-gradient(45deg, #1e293b, #1e293b 6px, #10b981 6px, #10b981 12px);
  color: #e2e8f0;
}

.player-hand {
  padding: 8px 6px;
  border-radius: 18px;
  background: radial-gradient(circle at top, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 1));
  border: 1px solid rgba(148, 163, 184, 0.5);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.player-card {
  min-width: 40px;
  padding: 6px 6px 4px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.95);
  text-align: center;
  font-size: 0.8rem;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease, border-color 0.08s ease, background 0.08s ease;
}

.player-card--selected {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.8);
  background: rgba(15, 23, 42, 1);
}

.player-card-rank {
  font-weight: 600;
}

.player-card-suit {
  font-size: 0.8rem;
}

.player-card-suit--red {
  color: #fc8181;
}

.player-card-suit--black {
  color: #cbd5e1;
}

.player-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.board-center {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.board-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: space-between;
}

.board-hand {
  margin-top: 4px;
}

.player-chip {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.4);
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.player-chip--active {
  border-color: var(--accent);
  background: radial-gradient(circle at top, rgba(255, 179, 71, 0.08), rgba(15, 23, 42, 0.95));
}

.player-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.9);
}

.player-dot--active {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 179, 71, 0.35);
}

.pill-room-code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.log-panel {
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px dashed rgba(148, 163, 184, 0.6);
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.log-main {
  flex: 1;
}

.log-label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.7rem;
  opacity: 0.7;
}

.log-text {
  margin-top: 2px;
}

.log-time {
  white-space: nowrap;
}

.view-home-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.1fr);
  gap: 16px;
}

@media (max-width: 900px) {
  .view-home-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.home-hero {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.home-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.home-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill-label {
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.5);
}

.view-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.link-soft {
  color: var(--accent);
  text-decoration: none;
}

.link-soft:hover {
  text-decoration: underline;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(148, 163, 184, 0.2);
  border-top-color: rgba(148, 163, 184, 0.9);
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- Mobile-first horizontal (landscape) tuning for game table --- */

@media (max-width: 900px) and (orientation: landscape) {
  body {
    background: radial-gradient(circle at top, #111827 0, #020617 55%, #020308 100%);
  }

  #app {
    padding: 4px;
  }

  .shell {
    min-height: 100vh;
    padding: 8px;
    border-radius: 12px;
  }

  .shell-header {
    padding-bottom: 6px;
  }

  .shell-main {
    padding-top: 8px;
    gap: 8px;
  }

  .card {
    padding: 10px;
    border-radius: 14px;
  }

  .view-table .card-header {
    margin-bottom: 6px;
  }

  .game-layout {
    grid-template-rows: auto 1fr auto auto;
    gap: 6px;
  }

  .game-board {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.1fr);
    gap: 6px;
  }

  .pile-card {
    min-height: 90px;
    padding: 6px;
  }

  .player-strip {
    justify-content: space-between;
  }

  .player-hand {
    padding: 4px;
    gap: 4px;
  }

  .player-card {
    min-width: 32px;
    padding: 4px 4px 2px;
    font-size: 0.7rem;
  }

  .game-actions {
    justify-content: space-between;
  }

  .btn-sm {
    padding: 4px 8px;
    font-size: 0.7rem;
  }

  .log-panel {
    padding: 4px 6px;
    font-size: 0.7rem;
  }
}

.opacity-muted {
  opacity: 0.6;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top, #1b2735 0, #090a0f 55%, #020308 100%);
    color: #f5f5f5;
    min-height: 100vh;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    padding: 1.5rem 1.25rem 0.5rem;
    text-align: center;
}

.app-header h1 {
    margin: 0;
    font-size: 1.8rem;
    letter-spacing: 0.04em;
}

.subtitle {
    margin-top: 0.25rem;
    color: #cfd8dc;
    font-size: 0.9rem;
}

.app-main {
    flex: 1;
    padding: 1rem 1.25rem 2rem;
    max-width: 960px;
    margin: 0 auto;
    display: grid;
    gap: 1rem;
}

.card {
    background: rgba(13, 25, 41, 0.94);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    box-shadow:
        0 18px 45px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(144, 164, 174, 0.1);
    backdrop-filter: blur(14px);
}

.intro-card h2 {
    margin-top: 0;
}

.card h2,
.card h3 {
    color: #ffeb3b;
}

code {
    background: rgba(38, 50, 56, 0.9);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #ffd54f;
}

ol {
    padding-left: 1.25rem;
}

@media (min-width: 720px) {
    .app-main {
        grid-template-columns: 2fr 1.5fr;
    }
}

