@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=Cormorant+Garamond:wght@300;400;500&display=swap');

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

:focus-visible {
  outline: 2px solid var(--focus-ring, var(--gold2));
  outline-offset: 2px;
}

:root {
  --navy:       #0d1117;
  --walnut:     #2c1810;
  --gold:       #c9a84c;
  --gold2:      #f0c96e;
  --ivory:      #f0e6c8;
  --espresso:   #2d1b0e;
  --felt:       #1a3a2a;
  --felt2:      #1f4530;
  --red:        #8b1a1a;
  --cream:      #f5deb3;
  --shadow:     rgba(0,0,0,0.6);
  --focus-ring: #f0c96e;
}

html, body {
  height: 100%;
  background: var(--navy);
  background-image:
    radial-gradient(ellipse at 20% 20%, #1a1f3a 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, #1a1a0a 0%, transparent 60%),
    repeating-linear-gradient(45deg,  rgba(255,255,255,0.007) 0px, rgba(255,255,255,0.007) 1px, transparent 1px, transparent 10px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,0.007) 0px, rgba(255,255,255,0.007) 1px, transparent 1px, transparent 10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  font-family: 'Playfair Display', serif;
  color: var(--gold);
  min-height: 100vh;
  padding: 20px 10px;
  overflow-x: hidden;
}

h1 {
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  font-weight: 700;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold2);
  text-shadow: 0 0 30px rgba(201,168,76,0.4), 0 2px 4px rgba(0,0,0,0.8);
  margin-bottom: 6px;
}

h1::after {
  content: '';
  display: block;
  width: 56px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201,168,76,0.45), transparent);
  margin: 7px auto 0;
}

.subtitle {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(0.75rem, 1.5vw, 0.95rem);
  letter-spacing: 0.3em;
  color: rgba(201,168,76,0.75);
  text-transform: uppercase;
  margin-bottom: 18px;
}

/* ── Board wrapper ─────────────────────────────────────────── */
#board-wrap {
  position: relative;
  border-radius: 12px;
  padding: 18px;
  background:
    linear-gradient(135deg, #3d1f10 0%, #1e0e06 40%, #2c1810 70%, #3d1f10 100%);
  box-shadow:
    0 0 0 2px #5a3018,
    0 0 0 4px #1a0a03,
    0 8px 40px rgba(0,0,0,0.8),
    0 0 80px rgba(80,30,0,0.3),
    inset 0 1px 0 rgba(255,220,120,0.15);
}

/* wood grain overlay */
#board-wrap::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: 12px;
  background-image: repeating-linear-gradient(
    88deg,
    transparent 0px, transparent 3px,
    rgba(255,255,255,0.012) 3px, rgba(255,255,255,0.012) 4px
  );
  pointer-events: none;
}

#board {
  display: block;
  border-radius: 6px;
  cursor: default;
  touch-action: none; /* eliminate 300ms delay; prevent scroll during drag */
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Controls panel ────────────────────────────────────────── */
#controls {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

button {
  font-family: 'Playfair Display', serif;
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--navy);
  background: linear-gradient(135deg, var(--gold2) 0%, var(--gold) 60%, #a07828 100%);
  border: none;
  border-radius: 4px;
  padding: 10px 26px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.25);
  transition: transform 0.1s, box-shadow 0.1s, opacity 0.2s;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(201,168,76,0.4), inset 0 1px 0 rgba(255,255,255,0.3);
}

button:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

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

button:focus-visible {
  outline: 2px solid var(--gold2);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(240,201,110,0.3);
}

/* ── Opening roll section ──────────────────────────────────── */
#opening-section {
  margin-bottom: 16px;
}

#opening-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
}

.opening-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 80px;
}

.opening-player-name {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--gold2);
  letter-spacing: 0.1em;
  text-align: center;
}

.opening-die {
  width: 64px; height: 64px;
  padding: 10px;
}

.opening-waiting {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(201,168,76,0.60);
  text-align: center;
  min-height: 1em;
}

#opening-vs {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.1rem;
  letter-spacing: 0.25em;
  color: rgba(201,168,76,0.60);
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ── Turn display ──────────────────────────────────────────── */
#turn-display {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: center;
  margin-top: 16px;
  margin-bottom: 6px;
  padding: 10px 24px;
  border-radius: 8px;
  transition: background 0.3s;
}

/* ── Timer display ──────────────────────────────────────────── */
#timer-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  margin-top: 8px;
  margin-bottom: 4px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.85rem;
  color: rgba(201,168,76,0.65);
  letter-spacing: 0.08em;
}

.timer-p1, .timer-p2 {
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  text-align: center;
  transition: opacity 0.3s;
}

.timer-p1 {
  opacity: 0.4;
}

.timer-p2 {
  opacity: 0.4;
}

#timer-display.p1-active .timer-p1 {
  opacity: 1;
  color: var(--gold2);
}

#timer-display.p2-active .timer-p2 {
  opacity: 1;
  color: var(--gold2);
}

#turn-display.my-turn {
  background: rgba(201,168,76,0.07);
  box-shadow: 0 0 0 1px rgba(201,168,76,0.15), 0 0 20px rgba(201,168,76,0.08);
}

#turn-checker-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
  transition: box-shadow 0.3s;
}

#turn-display.my-turn #turn-checker-icon {
  box-shadow: 0 0 16px rgba(240,200,100,0.6), 0 2px 8px rgba(0,0,0,0.5);
}

#turn-text-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}

#turn-name-text {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.3rem, 3vw, 1.9rem);
  font-weight: 700;
  color: var(--gold2);
  letter-spacing: 0.08em;
  line-height: 1.1;
  transition: text-shadow 0.3s;
}

#turn-display.my-turn #turn-name-text {
  text-shadow: 0 0 24px rgba(240,200,100,0.7), 0 0 50px rgba(240,200,100,0.3);
}

#turn-sub-text {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(0.78rem, 1.5vw, 0.92rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(201,168,76,0.65);
  transition: color 0.3s;
}

#turn-display.my-turn #turn-sub-text {
  color: rgba(240,200,100,0.75);
}

/* ── Status bar ────────────────────────────────────────────── */
#status-bar {
  min-height: 22px;
  text-align: center;
  margin-bottom: 4px;
}

#status {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(0.8rem, 1.5vw, 0.95rem);
  font-weight: 400;
  letter-spacing: 0.1em;
  color: rgba(201,168,76,0.65);
}

#status.status-error {
  color: #e8825a;
  transition: color 0.2s;
}

/* ── Action row: dice + contextual buttons ─────────────────── */
#action-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 14px;
  flex-wrap: wrap;
}

#action-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

#move-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Enlarged Roll Dice to match die height */
#btn-roll {
  height: 52px;
  padding: 0 28px;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  min-width: 130px;
}

/* Undo — secondary outlined style */
#btn-undo {
  background: transparent;
  color: rgba(201,168,76,0.65);
  border: 1.5px solid rgba(201,168,76,0.35);
  box-shadow: none;
  height: 44px;
  padding: 0 20px;
  font-size: 0.82rem;
}
#btn-undo:hover:not(:disabled) {
  color: var(--gold2);
  border-color: rgba(201,168,76,0.7);
  background: rgba(201,168,76,0.06);
  box-shadow: none;
  transform: none;
}
#btn-undo:disabled { opacity: 0.2; }

/* Done — lights up when all dice used */
#btn-done {
  background: transparent;
  color: rgba(201,168,76,0.4);
  border: 1.5px solid rgba(201,168,76,0.25);
  box-shadow: none;
  height: 44px;
  padding: 0 24px;
  font-size: 0.82rem;
  min-width: 100px;
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.1s;
}
#btn-done:not(:disabled) {
  background: rgba(201,168,76,0.12);
  color: var(--gold2);
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(201,168,76,0.25), inset 0 1px 0 rgba(255,255,255,0.1);
  cursor: pointer;
}
#btn-done:hover:not(:disabled) {
  background: rgba(201,168,76,0.22);
  box-shadow: 0 0 22px rgba(201,168,76,0.4);
  transform: translateY(-1px);
}
#btn-done:disabled {
  opacity: 0.2;
  cursor: default;
}

/* Double — same outlined style as Undo */
#btn-double {
  background: transparent;
  color: rgba(201,168,76,0.65);
  border: 1.5px solid rgba(201,168,76,0.35);
  box-shadow: none;
  height: 44px;
  padding: 0 20px;
  font-size: 0.82rem;
}
#btn-double:hover:not(:disabled) {
  color: var(--gold2);
  border-color: rgba(201,168,76,0.7);
  background: rgba(201,168,76,0.06);
  box-shadow: none;
  transform: none;
}

/* ── Cube row: match scores + doubling cube ────────────────── */
#cube-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-top: 10px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.85rem;
  color: rgba(201,168,76,0.65);
  letter-spacing: 0.08em;
}

#cube-display {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--espresso);
  border-radius: 5px;
  box-shadow:
    0 2px 6px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.12),
    inset 0 -1px 2px rgba(0,0,0,0.2);
  font-family: 'Playfair Display', serif;
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255,255,255,0.85);
  cursor: default;
  transition: background 0.2s, box-shadow 0.2s, color 0.2s;
}
#cube-display.owned-p1,
#cube-display.owned-p2 {
  box-shadow:
    0 2px 6px rgba(0,0,0,0.5),
    0 0 10px rgba(201,168,76,0.2),
    inset 0 1px 0 rgba(255,255,255,0.15),
    inset 0 -1px 2px rgba(0,0,0,0.2);
  color: #fff;
}

#cube-score-p1, #cube-score-p2 {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.cube-score-name {
  font-size: 0.78rem;
  color: rgba(201,168,76,0.65);
}
.cube-score-pts {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gold2);
}

/* ── Doubling cube offer overlay ───────────────────────────── */
#cube-offer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
#cube-offer-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

#cube-offer-overlay.show #cube-offer-box {
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}
#cube-offer-box {
  background: linear-gradient(135deg, #1e1206, #130c04);
  border: 1px solid rgba(201,168,76,0.5);
  border-radius: 16px;
  padding: 36px 48px;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0,0,0,0.7), 0 0 32px rgba(201,168,76,0.08);
  min-width: 280px;
}
#cube-offer-msg {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  color: var(--gold2);
  margin-bottom: 6px;
}
#cube-offer-value {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 28px;
}
#cube-offer-icon {
  width: 52px;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--espresso);
  border-radius: 10px;
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  box-shadow:
    0 4px 12px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.12),
    inset 0 -2px 4px rgba(0,0,0,0.2);
}
#cube-offer-btns {
  display: flex;
  gap: 16px;
  justify-content: center;
}
#btn-accept {
  background: rgba(201,168,76,0.15);
  color: var(--gold2);
  border: 1.5px solid var(--gold);
  min-width: 100px;
}
#btn-accept:hover:not(:disabled) {
  background: rgba(201,168,76,0.28);
  box-shadow: 0 0 18px rgba(201,168,76,0.35);
}
#btn-refuse {
  background: transparent;
  color: rgba(201,168,76,0.65);
  border: 1.5px solid rgba(201,168,76,0.25);
  min-width: 100px;
}
#btn-refuse:hover:not(:disabled) {
  color: var(--gold2);
  border-color: rgba(201,168,76,0.6);
  background: rgba(201,168,76,0.06);
  box-shadow: none;
  transform: none;
}

/* ── Dice display (HTML dice alongside canvas) ─────────────── */
#dice-row {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.die {
  width: 52px; height: 52px;
  background: var(--ivory);
  border-radius: 10px;
  box-shadow:
    0 4px 12px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.8),
    inset 0 -2px 4px rgba(0,0,0,0.15);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 8px;
  gap: 3px;
  position: relative;
  transition: transform 0.15s;
}

.die.used {
  opacity: 0.32;
  filter: grayscale(0.5);
}

.die .pip {
  width: 100%; height: 100%;
  border-radius: 50%;
  background: var(--espresso);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
}

.die .pip.hidden { visibility: hidden; }

@keyframes roll {
  0%   { transform: rotate(0deg) scale(1); }
  20%  { transform: rotate(-15deg) scale(1.1); }
  40%  { transform: rotate(12deg) scale(0.95); }
  60%  { transform: rotate(-8deg) scale(1.05); }
  80%  { transform: rotate(5deg) scale(1); }
  100% { transform: rotate(0deg) scale(1); }
}

.die.rolling {
  animation: roll 0.5s ease-out;
}

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

@keyframes winReveal {
  0%   { opacity: 0; transform: scale(0.85) translateY(14px); }
  65%  { transform: scale(1.03) translateY(-1px); }
  100% { opacity: 1; transform: scale(1) translateY(0);       }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.88); }
  to   { opacity: 1; transform: scale(1);    }
}

/* ── Score / bear-off counters ─────────────────────────────── */
#scores {
  display: flex;
  gap: 40px;
  justify-content: center;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(201,168,76,0.1);
  font-family: 'Cormorant Garamond', serif;
}

.score-block {
  text-align: center;
  min-width: 80px;
}

.score-label {
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(201,168,76,0.50);
  margin-bottom: 3px;
}

.score-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--gold2);
  letter-spacing: 0.05em;
}

.score-name.p1 { color: #d4c4a0; }
.score-name.p2 { color: #a07848; }

.score-val {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 300;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(201,168,76,0.2);
}

/* ── Win overlay ───────────────────────────────────────────── */
#win-overlay {
  display: flex;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

#win-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

#win-overlay.show #win-box {
  animation: winReveal 0.5s cubic-bezier(0.34, 1.5, 0.64, 1) both;
}

#win-box {
  background: linear-gradient(135deg, #2c1810, #1a0e06);
  border: 1px solid var(--gold);
  border-radius: 16px;
  padding: 48px 60px;
  text-align: center;
  box-shadow: 0 0 60px rgba(201,168,76,0.3), 0 20px 60px rgba(0,0,0,0.8);
}

#win-box h2 {
  font-size: 2.5rem;
  color: var(--gold2);
  text-shadow: 0 0 40px rgba(240,201,110,0.6);
  margin-bottom: 8px;
}

#win-box p {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.1rem;
  color: rgba(201,168,76,0.7);
  letter-spacing: 0.2em;
  margin-bottom: 8px;
}

#win-score-line {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.15rem;
  color: var(--gold);
  letter-spacing: 0.15em;
  margin-bottom: 28px;
}

/* ── Landing screen ────────────────────────────────────────── */
#landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

#landing-box {
  background: linear-gradient(135deg, #3d1f10 0%, #1e0e06 40%, #2c1810 70%, #3d1f10 100%);
  border: 1px solid rgba(201,168,76,0.4);
  border-radius: 12px;
  padding: 36px 48px;
  width: 100%;
  max-width: 380px;
  box-shadow:
    0 0 0 1px #1a0a03,
    0 8px 40px rgba(0,0,0,0.7),
    inset 0 1px 0 rgba(255,220,120,0.1);
}

.landing-section {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.landing-label {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(201,168,76,0.70);
  margin-bottom: 6px;
}

.landing-input {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1rem;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(201,168,76,0.3);
  border-radius: 4px;
  color: var(--gold2);
  padding: 9px 14px;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: border-color 0.2s;
  margin-bottom: 14px;
}

.landing-input:focus {
  border-color: rgba(201,168,76,0.7);
}

.landing-input:focus-visible {
  border-color: rgba(201,168,76,0.7);
  outline: 2px solid var(--gold2);
  outline-offset: 2px;
}

.landing-input::placeholder { color: rgba(201,168,76,0.50); }

.landing-btn {
  font-family: 'Playfair Display', serif;
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--navy);
  background: linear-gradient(135deg, var(--gold2) 0%, var(--gold) 60%, #a07828 100%);
  border: none;
  border-radius: 4px;
  padding: 10px 26px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.25);
  transition: transform 0.1s, box-shadow 0.1s;
  width: 100%;
}

.landing-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(201,168,76,0.4), inset 0 1px 0 rgba(255,255,255,0.3);
}

.landing-divider {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.8rem;
  color: rgba(201,168,76,0.60);
  letter-spacing: 0.15em;
  text-align: center;
  margin: 20px 0;
}

/* Entrance animations for landing screen */
#landing h1         { animation: fadeSlideUp 0.55s ease-out both; }
#landing .subtitle  { animation: fadeSlideUp 0.55s 0.07s ease-out both; }
#landing-box        { animation: fadeSlideUp 0.60s 0.13s ease-out both; }

/* ── Session bar ───────────────────────────────────────────── */
#session-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.85rem;
  color: rgba(201,168,76,0.65);
  flex-wrap: wrap;
  justify-content: center;
}

.session-label {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.7rem;
}

.session-code {
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  color: var(--gold2);
  letter-spacing: 0.25em;
  background: rgba(0,0,0,0.3);
  padding: 2px 10px;
  border-radius: 3px;
  border: 1px solid rgba(201,168,76,0.2);
}

.session-btn {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--navy);
  background: linear-gradient(135deg, var(--gold2) 0%, var(--gold) 100%);
  border: none;
  border-radius: 3px;
  padding: 4px 12px;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s;
}

.session-btn:hover { opacity: 1; }

.session-select {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--navy);
  background: linear-gradient(135deg, var(--gold2) 0%, var(--gold) 100%);
  border: none;
  border-radius: 3px;
  padding: 4px 8px;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s;
}
.session-select:hover { opacity: 1; }

#viewer-badge {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(201,168,76,0.65);
  font-style: italic;
}

#viewers-display {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.78rem;
  color: rgba(201,168,76,0.55);
  font-style: italic;
}

/* ── "Session not found" modal ─────────────────────────────── */
#modal-notfound {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#modal-box {
  background: linear-gradient(135deg, #2c1810, #1a0e06);
  border: 1px solid var(--gold);
  border-radius: 16px;
  padding: 40px 52px;
  text-align: center;
  box-shadow: 0 0 60px rgba(201,168,76,0.2), 0 20px 60px rgba(0,0,0,0.8);
}

#modal-box h2 {
  font-size: 1.8rem;
  color: var(--gold2);
  margin-bottom: 10px;
}

#modal-box p {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1rem;
  color: rgba(201,168,76,0.6);
  letter-spacing: 0.1em;
  margin-bottom: 28px;
}

/* ── Join overlay (shown inside game screen for direct URL visitors) */
#join-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  z-index: 50;
}

#join-overlay-box {
  background: linear-gradient(135deg, #2c1810, #1a0e06);
  border: 1px solid var(--gold);
  border-radius: 16px;
  padding: 40px 52px;
  text-align: center;
  box-shadow: 0 0 60px rgba(201,168,76,0.2), 0 20px 60px rgba(0,0,0,0.8);
  min-width: 300px;
}

#join-overlay-box h2 {
  font-size: 1.8rem;
  color: var(--gold2);
  margin-bottom: 4px;
}

#join-overlay-box .landing-input {
  margin-top: 8px;
  width: 100%;
  box-sizing: border-box;
}

/* ── New game toast ────────────────────────────────────────── */
#reset-notify {
  position: fixed;
  top: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #3d1f10, #1a0e06);
  border: 1px solid rgba(201,168,76,0.5);
  border-radius: 12px;
  padding: 18px 36px 14px;
  text-align: center;
  z-index: 150;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s;
  min-width: 260px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 24px rgba(201,168,76,0.12);
}
#reset-notify.show { opacity: 1; }
#reset-notify-msg {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  color: var(--gold2);
}
#reset-notify-bar {
  height: 3px;
  background: rgba(201,168,76,0.15);
  border-radius: 2px;
  margin-top: 12px;
  overflow: hidden;
}
#reset-notify-progress {
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
  width: 100%;
}
@keyframes countdown {
  from { width: 100%; }
  to   { width: 0%; }
}

/* ── Help overlay ──────────────────────────────────────────── */
#help-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  align-items: flex-start;
  justify-content: center;
  z-index: 300;
  padding: 40px 16px;
  overflow-y: auto;
}
#help-overlay.show { display: flex; }

#help-overlay.show #help-box {
  animation: scaleIn 0.32s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

#help-box {
  position: relative;
  background: linear-gradient(135deg, #2c1810, #1a0e06);
  border: 1px solid var(--gold);
  border-radius: 16px;
  padding: 40px 48px 36px;
  max-width: 560px;
  width: 100%;
  box-shadow: 0 0 60px rgba(201,168,76,0.2), 0 20px 60px rgba(0,0,0,0.8);
}
#help-box h2 {
  font-size: 1.8rem;
  color: var(--gold2);
  margin-bottom: 20px;
}
#help-content section {
  margin-bottom: 18px;
}
#help-content h3 {
  font-family: 'Playfair Display', serif;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold2);
  margin-bottom: 6px;
}
#help-content p {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1rem;
  color: rgba(201,168,76,0.75);
  line-height: 1.6;
  letter-spacing: 0.03em;
}
#help-content strong {
  color: var(--gold2);
}
.help-close {
  position: absolute;
  top: 16px; right: 18px;
  background: transparent;
  color: rgba(201,168,76,0.55);
  border: none;
  font-size: 1.1rem;
  padding: 4px 8px;
  cursor: pointer;
  box-shadow: none;
  min-width: unset;
  letter-spacing: 0;
  text-transform: none;
}
.help-close:hover:not(:disabled) {
  color: var(--gold2);
  transform: none;
  box-shadow: none;
}

/* ── Connection banner (SSE disconnect indicator) ──────────── */
#conn-banner {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  background: rgba(30, 10, 5, 0.92);
  color: rgba(201,168,76,0.85);
  text-align: center;
  padding: 8px 16px;
  font-size: 14px;
  z-index: 1000;
  border-bottom: 1px solid rgba(201,168,76,0.3);
}
#conn-banner a {
  color: rgba(201,168,76,0.85);
  margin-left: 12px;
  text-decoration: underline;
  cursor: pointer;
}

/* ── Reduced motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .die.rolling,
  #landing h1, #landing .subtitle, #landing-box,
  #win-overlay.show #win-box,
  #help-overlay.show #help-box,
  #cube-offer-overlay.show #cube-offer-box { animation: none; }
  #win-overlay           { transition: none; }
  #cube-offer-overlay    { transition: none; }
  #reset-notify          { transition: none; }
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 700px) {
  #board-wrap { padding: 10px; }
  .die { width: 40px; height: 40px; padding: 6px; }
  #btn-roll { height: 44px; padding: 0 18px; min-width: 100px; }
  #btn-undo, #btn-done, #btn-double { height: 38px; padding: 0 14px; }
  #cube-display { width: 22px; height: 22px; font-size: 0.65rem; }
  #cube-offer-icon { width: 40px; height: 40px; font-size: 1.1rem; }
  #cube-offer-box { padding: 28px 28px; }
  #landing-box { padding: 24px 20px; }
  #modal-box, #join-overlay-box { padding: 28px 24px; }
  #help-box { padding: 36px 20px 28px; }
  #help-overlay { padding: 20px 10px; }
}

/* Status Indicators */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  transition: opacity 0.3s;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(201, 168, 76, 0.85);
  box-shadow: 0 0 7px rgba(201, 168, 76, 0.45);
}

.status-offline .status-dot {
  background: #9e9e9e;
  box-shadow: none;
}

.status-text {
  text-transform: uppercase;
  color: rgba(220, 185, 100, 0.85);
}

.status-offline .status-text {
  color: rgba(201, 168, 76, 0.4);
}
