/* =====================================================================
   The Parlor — design system
   A turn-of-the-century gaming room. Felt, brass, oxblood, parchment.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght,SOFT,WONK@9..144,300..900,0..100,0..1&family=Spectral:ital,wght@0,300;0,400;0,500;0,700;1,400&family=JetBrains+Mono:wght@400;600&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Surfaces */
  --felt-deep:   #07201a;
  --felt:        #0d3527;
  --felt-light:  #15463a;
  --felt-glow:   rgba(46, 120, 88, 0.35);

  /* Accents */
  --oxblood:        #5a141d;
  --oxblood-bright: #8c2230;
  --crimson:        #c63746;

  /* Type & paper */
  --parchment:      #efe4c6;
  --parchment-dim:  #c9bb96;
  --parchment-mute: #8a7e5e;
  --ink:            #0a0805;

  /* Metals */
  --brass:        #c9a14a;
  --brass-bright: #efce6e;
  --brass-dim:    #8a6f2e;

  /* Semantic */
  --good: #6ab04a;
  --bad:  #c63746;

  /* Fonts */
  --font-display: "Fraunces", "Bodoni Moda", Georgia, serif;
  --font-body:    "Spectral", "Crimson Pro", Georgia, serif;
  --font-mono:    "JetBrains Mono", "Courier New", monospace;
}

/* ===== Paper / felt textures via SVG noise ===== */
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--parchment);
  background-color: var(--felt-deep);
  background-image:
    radial-gradient(ellipse 80% 60% at 20% 0%, rgba(140, 34, 48, 0.18), transparent 70%),
    radial-gradient(ellipse 70% 50% at 100% 100%, rgba(201, 161, 74, 0.10), transparent 70%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.05  0 0 0 0 0.05  0 0 0 0 0.03  0 0 0 0.35 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.55;
  font-size: 17px;
}

::selection { background: var(--brass); color: var(--ink); }

/* Type */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.05;
  color: var(--parchment);
  font-variation-settings: "opsz" 144, "SOFT" 50, "WONK" 0;
}
h1 { font-size: clamp(2.5rem, 6vw, 5rem); font-weight: 400; }
h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); font-weight: 500; }
h3 { font-size: 1.25rem; font-weight: 600; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--brass);
  font-weight: 600;
}
.serif-italic {
  font-style: italic;
  font-family: var(--font-display);
  color: var(--parchment-dim);
}

/* Ornaments */
.ornament {
  text-align: center;
  color: var(--brass);
  font-size: 1.5rem;
  letter-spacing: 1.2em;
  padding-right: 0; /* compensate letter-spacing */
  text-indent: 1.2em;
  user-select: none;
}
.rule {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--brass-dim) 20%, var(--brass) 50%, var(--brass-dim) 80%, transparent);
  margin: 28px auto;
  max-width: 480px;
}

/* ===== Buttons ===== */
.btn, button {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.98rem;
  letter-spacing: 0.02em;
  background: linear-gradient(180deg, var(--brass-bright), var(--brass));
  color: var(--ink);
  border: 1px solid var(--brass-dim);
  padding: 11px 22px;
  border-radius: 2px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s, filter 0.2s;
  box-shadow: inset 0 1px 0 rgba(255, 240, 200, 0.5), 0 2px 0 var(--brass-dim), 0 6px 14px rgba(0,0,0,0.3);
}
.btn:hover, button:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn:active, button:active { transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255,240,200,0.4), 0 1px 0 var(--brass-dim); }
.btn:disabled, button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn.secondary, button.secondary {
  background: transparent;
  color: var(--parchment);
  border: 1px solid var(--brass-dim);
  box-shadow: none;
}
.btn.secondary:hover, button.secondary:hover { background: rgba(201, 161, 74, 0.1); border-color: var(--brass); }
.btn.danger, button.danger {
  background: linear-gradient(180deg, var(--crimson), var(--oxblood-bright));
  color: var(--parchment);
  border-color: var(--oxblood);
  box-shadow: inset 0 1px 0 rgba(255,200,200,0.2), 0 2px 0 var(--oxblood), 0 6px 14px rgba(0,0,0,0.3);
}
.btn.ghost, button.ghost {
  background: transparent;
  color: var(--brass);
  border: none;
  box-shadow: none;
  padding: 6px 8px;
  font-size: 0.92rem;
}
.btn.ghost:hover, button.ghost:hover { color: var(--brass-bright); }

/* ===== Inputs ===== */
input[type="text"], input[type="number"], input[type="password"], select, textarea {
  font-family: var(--font-body);
  font-size: 1rem;
  background: var(--felt-deep);
  color: var(--parchment);
  border: 1px solid var(--brass-dim);
  border-radius: 2px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(201, 161, 74, 0.15);
}
label { color: var(--parchment-dim); font-size: 0.85rem; letter-spacing: 0.02em; }

/* ===== Layout primitives ===== */
.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}
.panel {
  background:
    linear-gradient(180deg, rgba(15, 60, 45, 0.85), rgba(7, 32, 26, 0.9)),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2'/><feColorMatrix values='0 0 0 0 0.02  0 0 0 0 0.05  0 0 0 0 0.04  0 0 0 0.4 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  border: 1px solid var(--brass-dim);
  border-radius: 4px;
  padding: 32px;
  position: relative;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.6), inset 0 0 80px rgba(0,0,0,0.25);
}
.panel::before, .panel::after {
  content: "";
  position: absolute;
  pointer-events: none;
}
.panel::before {
  inset: 6px;
  border: 1px solid rgba(201, 161, 74, 0.25);
  border-radius: 2px;
}

/* ===== Site header (shared across protected pages) ===== */
.parlor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  max-width: 1180px;
  margin: 0 auto;
  border-bottom: 1px solid var(--brass-dim);
  position: relative;
}
.parlor-header::after {
  content: "";
  position: absolute;
  bottom: -3px;
  left: 24px; right: 24px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--brass-dim) 30%, transparent);
}
.parlor-brand {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.5rem;
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
  text-decoration: none;
  color: var(--parchment);
  display: flex;
  align-items: center;
  gap: 12px;
}
.parlor-brand .mark {
  color: var(--brass);
  font-size: 1.6rem;
}
.parlor-user {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.95rem;
  color: var(--parchment-dim);
}
.parlor-user .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--felt-light);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--brass-dim);
  font-size: 1.1rem;
}
.parlor-user .name { color: var(--parchment); font-family: var(--font-display); font-weight: 500; }

.back-link {
  color: var(--brass);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.back-link:hover { color: var(--brass-bright); }

/* ===== Hero & lobby ===== */
.hero {
  text-align: center;
  padding: 60px 20px 30px;
  position: relative;
}
.hero .eyebrow { margin-bottom: 12px; display: block; }
.hero h1 {
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
  font-weight: 300;
}
.hero h1 em {
  font-style: italic;
  color: var(--brass-bright);
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
}
.hero .lede {
  max-width: 540px;
  margin: 18px auto 0;
  color: var(--parchment-dim);
  font-size: 1.1rem;
  font-style: italic;
}

/* ===== Game catalogue ===== */
.catalogue {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
  margin-top: 24px;
}
.game-card {
  position: relative;
  background:
    linear-gradient(160deg, var(--felt-light), var(--felt));
  border: 1px solid var(--brass-dim);
  border-radius: 3px;
  padding: 26px 22px 22px;
  text-decoration: none;
  color: var(--parchment);
  display: block;
  transition: transform 0.25s cubic-bezier(.2,.7,.3,1), box-shadow 0.25s, border-color 0.25s;
  overflow: hidden;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,0.6);
}
.game-card::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(201, 161, 74, 0.18);
  pointer-events: none;
  border-radius: 1px;
}
.game-card:nth-child(odd)  { transform: rotate(-0.4deg); }
.game-card:nth-child(even) { transform: rotate(0.3deg); }
.game-card:hover {
  transform: translateY(-6px) rotate(0deg);
  border-color: var(--brass);
  box-shadow: 0 24px 50px -16px rgba(0,0,0,0.8), 0 0 0 1px var(--brass-dim);
}
.game-card .num {
  position: absolute;
  top: 14px; right: 18px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--brass);
  letter-spacing: 0.2em;
}
.game-card .glyph {
  font-size: 3rem;
  color: var(--brass);
  line-height: 1;
  margin-bottom: 14px;
  display: inline-block;
  text-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.game-card h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-variation-settings: "opsz" 144, "SOFT" 80, "WONK" 1;
  font-size: 1.6rem;
  margin-bottom: 6px;
}
.game-card h2 em { font-style: italic; color: var(--brass-bright); }
.game-card .meta {
  color: var(--parchment-mute);
  font-size: 0.82rem;
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 8px;
}
.game-card.selected {
  border-color: var(--brass-bright);
  box-shadow: 0 0 0 2px var(--brass), 0 24px 50px -16px rgba(0,0,0,0.8);
}

.game-card .play-badge {
  position: absolute;
  top: 14px;
  left: 18px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 12px;
  border: 1px solid var(--brass-dim);
  background: rgba(7, 32, 26, 0.7);
}
.game-card .play-badge.live {
  color: var(--good);
  border-color: rgba(106, 176, 74, 0.4);
  background: rgba(106, 176, 74, 0.08);
}
.game-card .play-badge.live::before {
  content: "● ";
  color: var(--good);
}
.game-card .play-badge.hotseat {
  color: var(--brass);
  border-color: var(--brass-dim);
}
.game-card.hotseat-card {
  background: linear-gradient(160deg, #2a1a14, #1a0e08);
  border-color: rgba(201, 161, 74, 0.3);
}
.game-card.hotseat-card .glyph { color: var(--brass-dim); }

/* ===== Lobby room ===== */
.room-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
  margin-top: 28px;
}
@media (max-width: 800px) {
  .room-grid { grid-template-columns: 1fr; }
}
.room-code {
  font-family: var(--font-mono);
  font-size: 2.4rem;
  font-weight: 600;
  letter-spacing: 0.4em;
  color: var(--brass-bright);
  background: var(--felt-deep);
  border: 1px dashed var(--brass-dim);
  padding: 18px 28px;
  border-radius: 3px;
  text-align: center;
  margin: 16px 0;
  user-select: all;
}
.player-list { list-style: none; padding: 0; margin: 14px 0; }
.player-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  background: rgba(7, 32, 26, 0.6);
  border-left: 3px solid var(--brass-dim);
  border-radius: 0 3px 3px 0;
}
.player-list li.host { border-left-color: var(--brass-bright); }
.player-list li.ready { border-left-color: var(--good); }
.player-list .badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 12px;
  background: rgba(201, 161, 74, 0.12);
  color: var(--brass);
}
.player-list .badge.ready { background: rgba(106, 176, 74, 0.15); color: var(--good); }

/* ===== Status / toasts ===== */
.notice {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--parchment-dim);
  border-left: 3px solid var(--brass);
  padding: 10px 16px;
  background: rgba(7, 32, 26, 0.5);
  border-radius: 0 3px 3px 0;
  margin: 14px 0;
}
.notice.warn { border-color: var(--crimson); }
.notice.good { border-color: var(--good); }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 32, 26, 0.85);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-backdrop.show {
  display: flex;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--felt);
  border: 1px solid var(--brass-dim);
  border-radius: 4px;
  padding: 36px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 40px 80px rgba(0,0,0,0.7), inset 0 0 60px rgba(0,0,0,0.2);
  position: relative;
}
.modal::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(201, 161, 74, 0.25);
  pointer-events: none;
  border-radius: 2px;
}
.modal h2 { margin-bottom: 8px; }
.modal .sub { color: var(--parchment-dim); font-style: italic; margin-bottom: 20px; }
.modal label { display: block; margin: 14px 0 6px; text-transform: uppercase; letter-spacing: 0.18em; font-size: 0.72rem; }
.modal input, .modal select { width: 100%; }
.modal .actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  justify-content: flex-end;
}

/* ===== Page entry animation ===== */
.fade-up { animation: fadeUp 0.7s cubic-bezier(.2,.7,.3,1) both; }
.fade-up.d1 { animation-delay: 0.1s; }
.fade-up.d2 { animation-delay: 0.2s; }
.fade-up.d3 { animation-delay: 0.3s; }
.fade-up.d4 { animation-delay: 0.4s; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Footer ===== */
.parlor-footer {
  max-width: 1180px;
  margin: 50px auto 0;
  padding: 24px;
  text-align: center;
  color: var(--parchment-mute);
  font-size: 0.85rem;
  font-style: italic;
}
.parlor-footer .ornament-line {
  color: var(--brass-dim);
  letter-spacing: 0.6em;
  font-size: 0.9rem;
  margin-bottom: 10px;
}

/* ===== Game container ===== */
.game-stage {
  margin-top: 24px;
}
.game-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 18px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.game-meta h1 {
  font-size: 2rem;
  font-weight: 400;
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
}
.game-meta .room-pill {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--brass);
  background: rgba(201, 161, 74, 0.1);
  padding: 5px 12px;
  border-radius: 12px;
  border: 1px solid var(--brass-dim);
  letter-spacing: 0.18em;
}

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

.player-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}
.player-chip {
  background: rgba(7, 32, 26, 0.7);
  border: 1px solid var(--brass-dim);
  padding: 8px 14px;
  border-radius: 2px;
  font-size: 0.92rem;
  color: var(--parchment-dim);
}
.player-chip.active {
  border-color: var(--brass-bright);
  color: var(--parchment);
  box-shadow: 0 0 0 1px var(--brass), 0 0 18px rgba(201, 161, 74, 0.3);
}
.player-chip .avatar { margin-right: 6px; }

/* ===== Cards (playing cards) ===== */
.card {
  display: inline-block;
  width: 62px;
  height: 88px;
  background: var(--parchment);
  color: var(--ink);
  border-radius: 4px;
  text-align: center;
  font-weight: 600;
  padding: 4px;
  position: relative;
  font-size: 0.95rem;
  user-select: none;
  border: 1px solid var(--parchment-mute);
  box-shadow: 0 3px 8px rgba(0,0,0,0.4), inset 0 0 0 2px rgba(255,255,255,0.4);
  font-family: var(--font-display);
}
.card.red { color: var(--crimson); }
.card.back {
  background:
    linear-gradient(135deg, var(--oxblood) 0%, var(--oxblood-bright) 100%);
  background-size: cover;
  color: transparent;
  position: relative;
}
.card.back::after {
  content: "❦";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brass);
  font-size: 1.8rem;
  opacity: 0.8;
}
.card .suit-big {
  font-size: 2rem;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.card .corner {
  position: absolute;
  line-height: 1;
  font-size: 0.78rem;
  font-weight: 700;
}
.card .corner.tl { top: 5px; left: 5px; text-align: left; }
.card .corner.br { bottom: 5px; right: 5px; transform: rotate(180deg); text-align: left; }
.hand {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
  min-height: 100px;
  align-items: center;
}
.hand .card { cursor: pointer; transition: transform 0.15s; }
.hand .card:hover { transform: translateY(-8px); }
.hand .card.selected { transform: translateY(-12px); box-shadow: 0 8px 18px rgba(201, 161, 74, 0.5); }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .panel { padding: 20px; }
  .page { padding: 16px; }
}
