:root {
  --bg-deep: #0b1220;
  --bg: #111b2e;
  --bg-elev: #182338;
  --chrome: #1e2d4a;
  --border: #2a3d5c;
  --text: #e8eef8;
  --muted: #8fa3c4;
  --accent: #3d7ea6;
  --accent-hot: #5a9fc4;
  --gold: #d4a84b;
  --cream: #f0e6d0;
  --felt: #0f3d2e;
  --felt-edge: #0a2e22;
  --danger: #c45c5c;
  --ok: #4a9b6e;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Libre Baskerville", Georgia, serif;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
}

body {
  background:
    radial-gradient(ellipse 120% 80% at 50% -20%, #1a3358 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 100%, #0d2840 0%, transparent 45%),
    var(--bg-deep);
  min-height: 100dvh;
}

a {
  color: var(--accent-hot);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button,
input {
  font-family: inherit;
  font-size: 1rem;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 0.65rem 1.15rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s;
}
button:hover:not(:disabled) {
  background: var(--accent-hot);
}
button:active:not(:disabled) {
  transform: scale(0.98);
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
button.ghost:hover:not(:disabled) {
  background: var(--bg-elev);
}
button.gold {
  background: linear-gradient(160deg, #c9963a, #a67c2e);
  color: #1a1208;
}
button.danger {
  background: var(--danger);
}

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-deep);
  color: var(--text);
  outline: none;
}
input:focus {
  border-color: var(--accent);
}

/* —— Shell —— */
.shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}
.brand {
  font-family: var(--display);
  font-size: 1.15rem;
  color: var(--cream);
  letter-spacing: 0.02em;
}
.brand span {
  color: var(--gold);
}
.nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.nav .user {
  color: var(--muted);
  font-size: 0.875rem;
}

/* —— Landing / picker —— */
.hero {
  text-align: center;
  padding: 2.5rem 0 2rem;
  animation: fadeUp 0.55s ease-out;
}
.hero h1 {
  font-family: var(--display);
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  color: var(--cream);
  margin: 0 0 0.5rem;
  letter-spacing: 0.01em;
}
.hero h1 .g {
  color: var(--gold);
}
.hero p {
  color: var(--muted);
  max-width: 28rem;
  margin: 0 auto 2rem;
  font-size: 1.05rem;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
  max-width: 520px;
  margin: 0 auto;
}

.game-tile {
  display: block;
  text-align: left;
  padding: 0;
  background: transparent;
  border: none;
  color: inherit;
  width: 100%;
  animation: fadeUp 0.6s ease-out 0.1s both;
}
.game-tile .face {
  background:
    linear-gradient(145deg, #1a3d32 0%, var(--felt) 40%, var(--felt-edge) 100%);
  border: 1px solid #2a5a48;
  border-radius: 12px;
  padding: 1.5rem 1.35rem;
  min-height: 160px;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.game-tile:hover .face {
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
}
.game-tile h2 {
  font-family: var(--display);
  color: var(--gold);
  margin: 0 0 0.4rem;
  font-size: 1.6rem;
}
.game-tile p {
  margin: 0;
  color: var(--cream);
  opacity: 0.85;
  font-size: 0.95rem;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* —— Auth —— */
.panel {
  max-width: 400px;
  margin: 0 auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.75rem;
}
.panel h1 {
  font-family: var(--display);
  font-size: 1.5rem;
  color: var(--cream);
  margin: 0 0 1rem;
}
.panel label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.75rem 0 0.3rem;
}
.panel .actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.solo-setup {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 0.25rem;
}
.setup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.setup-label {
  color: var(--muted);
  font-size: 0.85rem;
}
.stepper {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.stepper button {
  padding: 0.3rem 0.7rem;
}
.stepper span {
  min-width: 1.4rem;
  text-align: center;
  font-weight: 700;
  color: var(--cream);
}
.diff-set {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem 0.7rem;
  margin: 0;
}
.diff-set legend {
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0 0.3rem;
}
.diff-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
}
.diff-opts label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--cream);
  font-size: 0.9rem;
  margin: 0;
  cursor: pointer;
}
.diff-desc {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0.5rem 0 0;
}
.diff-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
  font-weight: 700;
}
.diff-badge.easy {
  background: #2a6a38;
  color: #e8ffe8;
}
.diff-badge.medium {
  background: #3d7ea6;
  color: #e8f4ff;
}
.diff-badge.hard {
  background: #a07828;
  color: #fff4d8;
}
.diff-badge.ultra {
  background: #8a2828;
  color: #ffe8e8;
}
.err {
  color: #f0a0a0;
  font-size: 0.9rem;
  margin-top: 0.75rem;
}
.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 1rem;
  text-align: center;
}

/* —— Skyjo table —— */
.skyjo-page {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 2rem;
}

.skyjo-hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.skyjo-hud .status {
  color: var(--cream);
  font-weight: 600;
}
.skyjo-hud .meta {
  color: var(--muted);
  font-size: 0.875rem;
}

.table {
  background:
    radial-gradient(ellipse at 50% 40%, #14523c 0%, var(--felt) 55%, var(--felt-edge) 100%);
  border: 2px solid #1a4d3a;
  border-radius: 16px;
  padding: 1rem 0.75rem 1.25rem;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.35), 0 12px 40px rgba(0, 0, 0, 0.4);
}

.piles {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  align-items: flex-end;
}
.pile {
  text-align: center;
}
.pile:has(.clickable) {
  cursor: pointer;
}

.pile .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cream);
  opacity: 0.7;
  margin-bottom: 0.35rem;
}

.card {
  width: 52px;
  height: 72px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.35rem;
  user-select: none;
  border: 2px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s, box-shadow 0.12s;
}
.card.sm {
  width: 44px;
  height: 60px;
  font-size: 1.15rem;
}
.card.clickable {
  cursor: pointer;
}
.card.clickable:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.45);
}
.card.selected {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.card.hidden-card {
  background: linear-gradient(160deg, #2a3548, #1a2333);
  color: transparent;
}
.card.removed {
  background: transparent;
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: none;
  color: transparent;
}
.card.v-neg2 {
  background: linear-gradient(160deg, #1a3a6e, #0f2448);
  color: #c8d8f0;
}
.card.v-neg1 {
  background: linear-gradient(160deg, #2a5a9e, #1a3a6e);
  color: #e0ecff;
}
.card.v-0 {
  background: linear-gradient(160deg, #2a9aaa, #1a6a78);
  color: #e8ffff;
}
.card.v-low {
  background: linear-gradient(160deg, #3a8a4a, #2a6a38);
  color: #e8ffe8;
}
.card.v-mid {
  background: linear-gradient(160deg, #c9a03a, #a07828);
  color: #1a1208;
}
.card.v-high {
  background: linear-gradient(160deg, #c04040, #8a2828);
  color: #ffe8e8;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, 52px);
  gap: 6px;
  justify-content: center;
  margin: 0.5rem auto 1rem;
}
.board.sm {
  grid-template-columns: repeat(4, 44px);
  gap: 4px;
}

.opponents {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1rem;
}
.opp {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
}
.opp.active {
  box-shadow: 0 0 0 2px var(--gold);
}
.opp .name {
  font-size: 0.75rem;
  color: var(--cream);
  margin-bottom: 0.35rem;
  text-align: center;
}
.opp .score {
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
  margin-top: 0.3rem;
}

.you-label {
  text-align: center;
  color: var(--gold);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.turn-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.75rem;
  min-height: 2.5rem;
}

.scores {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  justify-content: center;
  margin-top: 1rem;
  color: var(--cream);
  font-size: 0.9rem;
}

.lobby-box {
  text-align: center;
  padding: 1.5rem;
}
.lobby-box .code {
  font-family: var(--display);
  font-size: 2rem;
  color: var(--gold);
  letter-spacing: 0.2em;
  margin: 0.5rem 0 1rem;
}
.player-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  color: var(--cream);
}

/* Help overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 20, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
  animation: fadeUp 0.2s ease-out;
}
.overlay .sheet {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 480px;
  max-height: 85dvh;
  overflow: auto;
  padding: 1.5rem;
}
.overlay h2 {
  font-family: var(--display);
  color: var(--gold);
  margin: 0 0 0.75rem;
}
.overlay p,
.overlay li {
  color: var(--muted);
  font-size: 0.95rem;
}
.overlay ul {
  padding-left: 1.2rem;
}

/* Admin */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
}
.admin-table th {
  color: var(--muted);
  font-weight: 600;
}

@media (max-width: 520px) {
  .card {
    width: 48px;
    height: 66px;
    font-size: 1.2rem;
  }
  .board {
    grid-template-columns: repeat(4, 48px);
    gap: 5px;
  }
  .card.sm {
    width: 36px;
    height: 50px;
    font-size: 0.95rem;
  }
  .board.sm {
    grid-template-columns: repeat(4, 36px);
  }
}
