:root {
  --bg-1: #1a0f16;
  --bg-2: #2a1620;
  --gold: #c9a24b;
  --terracotta: #d17b4f;
  --deep-red: #8b2e3f;
  --cream: #fbf5e9;
  --cream-dim: #f2e6cf;
  --ink: #2a1620;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(ellipse at 50% 20%, var(--bg-2) 0%, var(--bg-1) 70%);
  color: var(--cream);
  font-family: 'Cormorant Garamond', serif;
  font-size: 19px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.18;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

#app {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: max(1.5rem, env(safe-area-inset-top)) 1.5rem max(1.5rem, env(safe-area-inset-bottom));
}

.hidden {
  display: none !important;
}

/* ---------- Start screen ---------- */

#screen-start {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 2.5rem;
}

.brand .wordmark {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(3rem, 14vw, 4.5rem);
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--cream);
  text-shadow: 0 0 40px rgba(201, 162, 75, 0.25);
}

.brand .tagline {
  margin: 0.5rem 0 0;
  color: var(--cream-dim);
  opacity: 0.75;
  font-size: 1.15rem;
  font-style: italic;
}

.start-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 360px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
}

.field span {
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.85;
}

.field input {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.2rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(201, 162, 75, 0.35);
  background: rgba(251, 245, 233, 0.06);
  color: var(--cream);
  outline: none;
}

.field input::placeholder {
  color: rgba(251, 245, 233, 0.35);
}

.field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 75, 0.18);
}

.hint {
  color: var(--cream-dim);
  opacity: 0.55;
  font-size: 0.95rem;
  font-style: italic;
}

/* ---------- Buttons ---------- */

.btn {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.15rem;
  letter-spacing: 0.03em;
  padding: 0.85rem 1.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold), #a9812f);
  color: var(--ink);
  font-weight: 600;
}

.btn-draw {
  background: linear-gradient(135deg, var(--gold), #a9812f);
  color: var(--ink);
  font-weight: 600;
  animation: pulse-glow 2.6s ease-in-out infinite;
}

.btn-resolve {
  background: transparent;
  border-color: var(--gold);
  color: var(--gold);
}

.btn-skip {
  background: transparent;
  border-color: rgba(251, 245, 233, 0.3);
  color: var(--cream-dim);
  font-size: 1rem;
}

.btn-restart {
  background: transparent;
  border: 1px solid rgba(251, 245, 233, 0.2);
  color: var(--cream-dim);
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  opacity: 0.7;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 162, 75, 0.45); }
  50% { box-shadow: 0 0 0 12px rgba(201, 162, 75, 0); }
}

/* ---------- Game screen ---------- */

#screen-game {
  gap: 1.25rem;
}

.game-header {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.turn-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.turn-label {
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.8;
}

.turn-name {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 1.6rem;
}

.depth-track {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: rgba(251, 245, 233, 0.12);
  overflow: visible;
}

.depth-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--terracotta), var(--deep-red));
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.depth-tick {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 12px;
  background: rgba(251, 245, 233, 0.4);
  border-radius: 1px;
}

.depth-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--cream-dim);
  opacity: 0.55;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.table {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.75rem;
}

.card-scene {
  width: 100%;
  max-width: 340px;
  aspect-ratio: 3 / 4.2;
  perspective: 1600px;
}

.card {
  all: unset;
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.7s cubic-bezier(0.4, 0.1, 0.2, 1);
  transform-style: preserve-3d;
}

.card-inner.flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.75rem;
  text-align: center;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(201, 162, 75, 0.25);
}

.card-back {
  background:
    radial-gradient(circle at 50% 50%, rgba(201, 162, 75, 0.12), transparent 60%),
    linear-gradient(160deg, #24131c, #150b11);
  border: 1px solid rgba(201, 162, 75, 0.3);
  gap: 1.25rem;
}

.card-ornament {
  font-size: 2rem;
  color: var(--gold);
  opacity: 0.85;
}

.card-wordmark {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 500;
  letter-spacing: 0.25em;
  font-size: 1.1rem;
  color: var(--gold);
}

.card-front {
  background: linear-gradient(165deg, var(--cream), var(--cream-dim));
  color: var(--ink);
  transform: rotateY(180deg);
  gap: 1.25rem;
}

.card-tier {
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.3rem 0.9rem;
  border-radius: 999px;
  background: rgba(42, 22, 32, 0.08);
}

.card-front.tier-tier1 .card-tier { background: rgba(201, 162, 75, 0.2); color: #8a6a1f; }
.card-front.tier-tier2 .card-tier { background: rgba(209, 123, 79, 0.2); color: #9a4d29; }
.card-front.tier-tier3 .card-tier { background: rgba(139, 46, 63, 0.18); color: #8b2e3f; }
.card-front.tier-forfeit .card-tier { background: rgba(42, 22, 32, 0.12); color: var(--ink); }

.card-question {
  font-family: 'Fraunces', serif;
  font-weight: 400;
  font-size: 1.45rem;
  line-height: 1.35;
  margin: 0;
}

.actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 340px;
}

.btn-draw, .btn-resolve {
  width: 100%;
}

.players-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.player-chip {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.6rem 0.5rem;
  border-radius: 14px;
  border: 1px solid rgba(251, 245, 233, 0.1);
  transition: border-color 0.3s ease, background 0.3s ease;
}

.player-chip.active {
  border-color: var(--gold);
  background: rgba(201, 162, 75, 0.08);
}

.player-chip-name {
  font-size: 0.95rem;
  color: var(--cream-dim);
}

.player-chip-skips {
  font-size: 0.85rem;
  color: var(--gold);
  letter-spacing: 0.15em;
}

/* ---------- Responsive niceties ---------- */

@media (min-width: 600px) {
  body { font-size: 20px; }
  .screen { padding: 2.5rem; }
}

@media (max-height: 640px) {
  .card-scene { max-width: 260px; }
  .brand .wordmark { font-size: 2.75rem; }
}
