:root {
  /* ── Brand tokens — the shared PlayNinja layer every game inherits ───── */
  --bg: #efe7d6;            /* warm kraft paper */
  --bg-grad: radial-gradient(circle at 15% -10%, rgba(61, 154, 82, 0.10), transparent 50%),
              radial-gradient(circle at 90% 10%, rgba(214, 86, 143, 0.07), transparent 50%);
  --card: #fbf6ec;
  --card-2: #f1e9d6;        /* shell alias */
  --surface-2: #f1e9d6;
  --ink: #2c2118;
  --ink-dim: #5a4a36;
  --muted: #8a7a62;
  --accent: #3d9a52;        /* Herd skin — green */
  --accent-deep: #2f7d43;
  --accent-ink: #ffffff;
  --accent-glow: rgba(61, 154, 82, 0.22);
  --pink: #d6568f;
  --pink-soft: rgba(214, 86, 143, 0.14);
  --pink-deep: #b23e74;
  --yellow: #c79214;
  --yellow-soft: rgba(199, 146, 20, 0.16);
  --blue: #3b82c4;
  --purple: #8b5cc4;
  --orange: #cf7a2c;
  --majority: rgba(61, 154, 82, 0.16);
  --majority-border: #9ec7ab;
  --odd: rgba(214, 86, 143, 0.12);
  --odd-border: #e2b3c8;
  --border: #ddcfb4;
  --border-2: #cdbf9f;
  --bad: #cf5238;           /* shell unread dot */
  --error: #cf5238;
  --error-bg: rgba(207, 82, 56, 0.12);
  --shadow: 0 8px 22px rgba(80, 55, 20, 0.10);
  --shadow-soft: 0 4px 14px rgba(80, 55, 20, 0.08);
  --display: 'Fredoka', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 500;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}

body {
  display: flex;
  flex-direction: column;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 24px;
  width: 100%;
}

main.room {
  max-width: 1280px;
}

h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 40px;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-shadow: 0 0 24px rgba(74, 222, 128, 0.18);
}

h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
  margin: 0 0 14px;
  letter-spacing: -0.005em;
  color: var(--ink);
}

p { margin: 0 0 12px; }

.tagline {
  color: var(--muted);
  font-weight: 500;
  font-size: 16px;
  margin-bottom: 28px;
}

.landing h1 {
  font-size: 48px;
  margin-bottom: 6px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin: 0 0 16px;
  box-shadow: var(--shadow-soft);
  position: relative;
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

input[type="text"] {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 16px;
  font-family: inherit;
  font-weight: 500;
  transition: border-color 0.1s ease, box-shadow 0.1s ease;
}

input[type="text"]::placeholder {
  color: var(--muted);
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

button {
  display: inline-block;
  padding: 11px 20px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--display);
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--accent-deep);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.1s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 3px 0 var(--accent-deep);
  filter: brightness(1.04);
}

button:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--accent-deep);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: 0 2px 0 var(--accent-deep);
}

.error {
  color: var(--error);
  background: var(--error-bg);
  border: 1px solid rgba(255, 107, 107, 0.35);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 12px 0 0;
  font-size: 14px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

/* Room */

.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.room-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-code-label {
  color: var(--muted);
  font-size: 13px;
}

.room-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.12em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 12px;
  color: var(--yellow);
}

#copy-link {
  background: var(--surface-2);
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 7px 12px;
  font-size: 13px;
  box-shadow: none;
}

#copy-link:hover:not(:disabled) {
  box-shadow: none;
  filter: none;
  background: var(--card);
  border-color: var(--accent);
}

/* Players */

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

.player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.1s ease, transform 0.1s ease, background 0.1s ease;
}

.player.me {
  border-color: var(--accent);
  background: rgba(74, 222, 128, 0.08);
}
.player.offline { opacity: 0.5; }

.player-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-tags { display: inline-flex; gap: 6px; flex: 0 0 auto; }
.player-score {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 18px;
  min-width: 24px;
  text-align: right;
  flex: 0 0 auto;
  color: var(--accent);
}

.tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--border);
  color: var(--ink-dim);
  font-weight: 600;
}
.tag-ok { background: var(--majority); color: var(--accent); }
.tag-pink { background: var(--pink-soft); color: var(--pink); }

.cow {
  display: inline-block;
  font-size: 22px;
  animation: cow-bounce-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.cow.pink {
  filter: hue-rotate(280deg) saturate(2.2);
}
@keyframes cow-bounce-in {
  0% { transform: scale(0) rotate(-30deg); }
  60% { transform: scale(1.3) rotate(8deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* Question / answer */

.question {
  font-family: var(--display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
  line-height: 1.25;
  color: var(--ink);
}

#answer-form button { margin-top: 4px; }

/* Reveal groups */

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

.group {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  animation: group-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.group:nth-child(2) { animation-delay: 0.08s; }
.group:nth-child(3) { animation-delay: 0.16s; }
.group:nth-child(4) { animation-delay: 0.24s; }
.group:nth-child(5) { animation-delay: 0.32s; }

.group.majority { background: var(--majority); border-color: var(--majority-border); }
.group.odd { background: var(--odd); border-color: var(--odd-border); }

@keyframes group-pop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.group-entries {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.group-entry {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 14px;
}

.group-who {
  font-weight: 600;
  color: var(--ink);
  flex: 0 1 auto;
  min-width: 0;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-who::after {
  content: ':';
  color: var(--muted);
  margin-left: 1px;
}

.group-said {
  color: var(--ink-dim);
  font-style: italic;
  word-break: break-word;
}

.group-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag-soft {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
}

.pink-cow-msg {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--pink-soft);
  border: 1px solid var(--odd-border);
  border-radius: 10px;
  color: var(--pink);
  font-weight: 600;
}

.no-majority-msg {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--yellow-soft);
  border: 1px solid rgba(250, 204, 21, 0.4);
  border-radius: 10px;
  color: var(--yellow);
  font-weight: 600;
}

/* Landing form spacing */

.landing form button { margin-top: 4px; }

/* Floating Rules button */

.rules-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 8000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 12px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--display);
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--border-2);
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.rules-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: none;
  box-shadow: 0 4px 16px rgba(74, 222, 128, 0.25);
}

.rules-btn:active {
  transform: translateY(1px);
}

.rules-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

@media (max-width: 480px) {
  .rules-btn-text { display: none; }
  .rules-btn { padding: 8px; }
}

/* Rules modal */

.rules-modal {
  margin: auto;
  border: 1px solid var(--border-2);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  max-width: 640px;
  width: calc(100% - 32px);
  max-height: calc(100vh - 64px);
  padding: 28px 28px 24px;
  margin: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  font-family: var(--display);
}

.rules-modal::backdrop {
  background: rgba(8, 9, 16, 0.7);
  backdrop-filter: blur(2px);
}

.rules-modal[open] {
  animation: rules-pop 0.18s ease-out;
}

@keyframes rules-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)  scale(1); }
}

.rules-modal h2 {
  font-size: 24px;
  margin: 0 0 14px;
}

.rules-modal h3 {
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 22px 0 10px;
  font-weight: 700;
}

.rules-modal h4 {
  margin: 0 0 10px;
}

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

.rules-list > li {
  position: relative;
  padding: 10px 14px 10px 36px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-dim);
  counter-increment: rules-step;
}

ol.rules-list { counter-reset: rules-step; }

ol.rules-list > li::before {
  content: counter(rules-step);
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
}

ul.rules-list > li {
  padding-left: 14px;
}

.rules-list b { color: var(--ink); font-weight: 700; }

.rules-cow {
  display: inline-block;
  font-size: 18px;
  vertical-align: -2px;
}
.rules-cow.pink { filter: hue-rotate(280deg) saturate(2.2); }

.rules-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  color: var(--ink-dim);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.rules-modal-close:hover {
  color: var(--ink);
  border-color: var(--ink-dim);
  transform: none;
  box-shadow: none;
}

/* Mode picker (lobby) */

.mode-picker {
  margin: 18px 0 14px;
  padding: 0;
  border: none;
}

.mode-picker legend {
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
  padding: 0;
}

.mode-option {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  background: var(--surface-2);
  margin-bottom: 8px;
  font-size: 14px;
  transition: border-color 0.1s ease, background 0.1s ease;
  align-items: center;
}

.mode-option:hover {
  border-color: var(--accent);
}

.mode-option:has(input:checked) {
  border-color: var(--accent);
  background: rgba(74, 222, 128, 0.08);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.mode-option input[type="radio"] {
  grid-row: 1 / span 2;
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
}

.mode-option .mode-name {
  font-weight: 700;
  color: var(--ink);
}

.mode-option .mode-desc {
  font-size: 13px;
  color: var(--muted);
  grid-column: 2;
}

/* Picking screen */

.picking-msg {
  color: var(--ink-dim);
  font-size: 16px;
  margin-bottom: 14px;
}

.picking-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.picking-option {
  text-align: left;
  padding: 16px 18px;
  font-size: 17px;
  font-family: var(--display);
  font-weight: 600;
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: none;
  cursor: pointer;
  transition: border-color 0.1s ease, background 0.1s ease, transform 0.08s ease;
  width: 100%;
  letter-spacing: 0;
  line-height: 1.4;
}

.picking-option:hover:not(:disabled):not(.locked) {
  border-color: var(--accent);
  background: rgba(74, 222, 128, 0.08);
  transform: translateY(-1px);
  box-shadow: 0 4px 0 var(--accent-deep);
}

.picking-option:active:not(:disabled):not(.locked) {
  transform: translateY(1px);
  box-shadow: 0 0 0 var(--accent-deep);
}

.picking-option.locked {
  cursor: default;
  color: var(--muted);
  font-style: italic;
  text-align: center;
  letter-spacing: 0.4em;
}

.picking-timer {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 14px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 24px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  transition: color 0.1s ease, border-color 0.1s ease;
}

.picking-timer.urgent {
  color: var(--pink);
  border-color: var(--pink);
  animation: timer-pulse 0.8s ease-in-out infinite;
}

.picking-timer-unit {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

@keyframes timer-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

/* Matching info disclosure */

.match-info {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.match-info > summary {
  cursor: pointer;
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
  color: var(--accent);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  user-select: none;
}

.match-info > summary::-webkit-details-marker { display: none; }

.match-info > summary::before {
  content: '▸';
  font-size: 12px;
  color: var(--muted);
  transition: transform 0.15s ease;
  display: inline-block;
}

.match-info[open] > summary::before {
  transform: rotate(90deg);
}

.match-info > summary:hover {
  color: var(--ink);
}

.match-info-body {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.match-col {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}

.match-col h4 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 10px;
}

.match-yes { border-left: 3px solid var(--accent); }
.match-yes h4 { color: var(--accent); }
.match-yes h4::before { content: '✓ '; }

.match-no { border-left: 3px solid var(--pink); }
.match-no h4 { color: var(--pink); }
.match-no h4::before { content: '✗ '; }

.match-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.match-col li {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-dim);
}

.match-col li b {
  font-weight: 600;
  color: var(--ink);
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 1px;
}

.match-col li i {
  font-style: normal;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
  color: var(--ink);
}

.match-tip {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

.match-tip i {
  font-style: normal;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink-dim);
}

@media (max-width: 640px) {
  .match-info-body { grid-template-columns: 1fr; }
}

.matching-tip {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.matching-tip i {
  font-style: normal;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink-dim);
}

/* Confetti + celebration overlays */

.confetti-burst {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9000;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 16px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
  will-change: transform, opacity;
}

@keyframes confetti-fall {
  0% { transform: translateY(-30px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(900deg); opacity: 0; }
}

.float-burst {
  position: fixed;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-family: var(--display);
  font-weight: 700;
  font-size: 88px;
  letter-spacing: -0.02em;
  color: var(--accent);
  text-shadow:
    0 0 30px rgba(74, 222, 128, 0.7),
    0 0 60px rgba(74, 222, 128, 0.4),
    3px 3px 0 var(--accent-deep);
  z-index: 9100;
  pointer-events: none;
  animation: float-pop 1.8s cubic-bezier(0.22, 1.2, 0.36, 1) forwards;
  white-space: nowrap;
}

.float-burst.pink {
  color: var(--pink);
  text-shadow:
    0 0 30px rgba(255, 126, 179, 0.7),
    0 0 60px rgba(255, 126, 179, 0.4),
    3px 3px 0 var(--pink-deep);
}

@keyframes float-pop {
  0%   { transform: translate(-50%, -50%) scale(0)    rotate(-8deg); opacity: 0; }
  18%  { transform: translate(-50%, -50%) scale(1.2)  rotate(2deg); opacity: 1; }
  35%  { transform: translate(-50%, -50%) scale(1)    rotate(-2deg); opacity: 1; }
  75%  { transform: translate(-50%, -55%) scale(1.05) rotate(1deg); opacity: 1; }
  100% { transform: translate(-50%, -120%) scale(1.2) rotate(0deg); opacity: 0; }
}

/* Podium */

.podium {
  list-style: none;
  margin: 22px 0 18px;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  align-items: end;
}

.podium:has(li:nth-child(1):last-child) { grid-template-columns: 1fr; }
.podium:has(li:nth-child(2):last-child) { grid-template-columns: 1fr 1fr; }

.podium-spot {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.podium-medal {
  font-size: 38px;
  animation: medal-bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.podium-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 16px;
  margin-top: 2px;
}

.podium-cows {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 6px;
}

.podium-block {
  width: 100%;
  border: 1px solid var(--border-2);
  border-radius: 12px 12px 4px 4px;
  font-family: var(--display);
  font-weight: 700;
  color: #1a1d28;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-soft);
}

.rank-1 .podium-block { background: linear-gradient(180deg, #facc15, #ca8a04); height: 100px; font-size: 22px; box-shadow: 0 0 24px rgba(250, 204, 21, 0.35); }
.rank-2 .podium-block { background: linear-gradient(180deg, #cbd5e1, #94a3b8); height: 78px; font-size: 18px; }
.rank-3 .podium-block { background: linear-gradient(180deg, #ea934f, #b97532); height: 60px; font-size: 16px; }

.rank-1 .podium-medal { animation-delay: 0.05s; }
.rank-2 .podium-medal { animation-delay: 0.18s; }
.rank-3 .podium-medal { animation-delay: 0.30s; }

@keyframes medal-bounce {
  0% { transform: scale(0) rotate(-180deg); }
  100% { transform: scale(1) rotate(0deg); }
}

#gameover-title {
  font-size: 32px;
}

.last-round {
  margin: 22px 0 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.last-round-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 12px;
}

.last-round .question {
  font-size: 22px;
  margin-bottom: 12px;
}

/* Two-column room layout */

.room-grid {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 340px;
  grid-template-areas: "players game chat";
  gap: 20px;
  align-items: start;
}

.players-pane { grid-area: players; min-width: 0; }
.game-pane    { grid-area: game; min-width: 0; }
.chat-pane    { grid-area: chat; }

@media (min-width: 1100px) {
  .players-pane {
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
  }
}

.chat-pane {
  position: sticky;
  top: 24px;
  height: min(calc(100vh - 160px), 680px);
  display: flex;
  flex-direction: column;
}

/* Chat */

.chat-card {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
}

.chat-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.chat-list:empty::before {
  content: 'No messages yet.';
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}

.chat-msg {
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  color: var(--ink);
}

.chat-msg .who {
  font-weight: 700;
  color: var(--accent);
  margin-right: 6px;
}

.chat-msg.me .who {
  color: var(--yellow);
}

.chat-locked {
  margin: 0 0 8px;
}

.chat-form {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.chat-form input {
  flex: 1;
  margin-top: 0;
}

.chat-form button {
  flex: 0 0 auto;
}

.chat-form input:disabled {
  background: var(--card);
  color: var(--muted);
  cursor: not-allowed;
}

@media (max-width: 1099px) {
  .room-grid {
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-areas:
      "players players"
      "game chat";
  }
}

@media (max-width: 880px) {
  .room-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "players"
      "game"
      "chat";
  }
  .chat-pane {
    position: static;
    height: 50vh;
  }
}

/* Scrollbars (dark) */

.chat-list::-webkit-scrollbar {
  width: 8px;
}
.chat-list::-webkit-scrollbar-track {
  background: transparent;
}
.chat-list::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 4px;
}
.chat-list::-webkit-scrollbar-thumb:hover {
  background: #4a4f63;
}

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

@media (max-width: 480px) {
  h1 { font-size: 26px; }
  .question { font-size: 19px; }
}

/* ── Back to main site ─────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  margin-top: auto;        /* pin to the bottom of the viewport */
  padding: 24px 16px 28px;
}
.site-footer a {
  color: var(--muted);
  font-family: var(--display);
  font-size: 0.92rem;
  text-decoration: none;
  transition: color 0.15s;
}
.site-footer a:hover { color: var(--accent); }
.site-footer strong { color: var(--ink-dim); font-weight: 600; }
.site-footer-sep { color: var(--border); margin: 0 10px; }

/* Room title doubles as a link back to the game home */
.home-link { color: inherit; text-decoration: none; transition: color 0.15s; }
.home-link:hover { color: var(--accent); }
/* ── How-to-play card (landing + lobby) ── */
.lobby-tagline { color: var(--ink-dim); font-size: 15px; margin: 0 0 14px; max-width: 580px; }
details.howto { padding: 0; overflow: hidden; }
details.howto > summary { cursor: pointer; list-style: none; padding: 15px 18px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
details.howto > summary::-webkit-details-marker { display: none; }
.howto-lead { color: var(--accent); }
details.howto > summary::after { content: '＋'; color: var(--muted); font-size: 18px; font-weight: 700; }
details.howto[open] > summary::after { content: '－'; }
details.howto[open] > summary { border-bottom: 1px solid var(--border); }
.howto-list { margin: 0; padding: 14px 18px 16px 38px; display: flex; flex-direction: column; gap: 9px; }
.howto-list li { color: var(--ink-dim); font-size: 14px; line-height: 1.55; }
.howto-list b { color: var(--ink); }
.howto-list i { color: var(--accent); font-style: normal; }

/* ── Play page top bar (home + game page) ── */
.play-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 104px 10px 18px; }
.play-top-link { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-dim); text-decoration: none; padding: 7px 14px; border-radius: 100px; border: 1px solid var(--border); background: var(--card); transition: color 0.15s, border-color 0.15s; }
.play-top-link:hover { color: var(--ink); border-color: var(--accent); }
.play-top-link .ar { color: var(--muted); }

/* ── PlayNinja shared room shell — topbar + off-canvas drawers (players move into the right drawer) ── */
.room-topbar { display: flex; align-items: center; gap: 10px; padding: 6px 2px; margin: 0 0 12px; }
.rtb-menu { background: var(--card); color: var(--ink); border: 1px solid var(--border); border-radius: 10px; width: 38px; height: 38px; font-size: 17px; padding: 0; display: grid; place-items: center; cursor: pointer; flex: 0 0 auto; }
.rtb-title { font-weight: 700; font-size: 20px; color: var(--ink); text-decoration: none; }
.rtb-spacer { flex: 1; }
.rtb-icon { background: var(--card); color: var(--ink-dim); border: 1px solid var(--border); border-radius: 50%; width: 34px; height: 34px; font-size: 16px; font-weight: 700; padding: 0; display: grid; place-items: center; cursor: pointer; flex: 0 0 auto; }
.rtb-icon svg { display: block; }
.rtb-icon.mobile-only { display: none; }
.room-drawer { position: fixed; top: 0; left: 0; bottom: 0; height: 100dvh; width: min(320px, 86vw); transform: translateX(-100%); transition: transform 0.25s ease; z-index: 200; background: var(--bg); box-shadow: 10px 0 30px rgba(0,0,0,0.2); padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 11px; }
.room-drawer.open { transform: translateX(0); }
.drawer-link, .drawer-btn { display: inline-flex; align-items: center; gap: 5px; font-size: 14px; font-weight: 600; color: var(--ink-dim); text-decoration: none; width: fit-content; }
.drawer-btn { background: none; border: none; padding: 0; cursor: pointer; font-family: var(--display); }
.drawer-link:hover, .drawer-btn:hover { color: var(--accent); }
.drawer-link .ar { color: var(--muted); }
.drawer-room { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.drawer-room .room-code { color: var(--ink); }
.drawer-room #copy-link { font-size: 13px; padding: 6px 12px; background: var(--card-2); color: var(--ink-dim); border: 1px solid var(--border); }
.side-toggle { display: none; position: relative; }
.side-toggle.has-unread::after { content: ''; position: absolute; top: 0; right: 0; width: 9px; height: 9px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px var(--bg); }
.drawer-head { display: none; align-items: center; justify-content: space-between; margin-bottom: 10px; font-weight: 700; font-size: 16px; }
.room-drawer .drawer-head { display: flex; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 150; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.drawer-backdrop.show { opacity: 1; pointer-events: auto; }
/* Pre-game share panel (visible in lobby, hidden once the game starts) */
.pregame { text-align: center; }
.pregame-title { margin: 0 0 12px; font-size: 18px; font-weight: 700; }
.pregame-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 14px; font-size: 15px; color: var(--muted); }
.pregame-row .room-code { color: var(--ink); font-size: 24px; letter-spacing: 3px; font-weight: 700; }
.pregame-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.pregame-actions .ghost-btn { background: var(--card-2); color: var(--ink-dim); border: 1px solid var(--border); }
/* Players panel now lives above chat in the right drawer */
#players-section { flex: 0 0 auto; max-height: 42%; overflow-y: auto; margin: 0 0 12px; }
/* 2-column desktop (players moved into the chat drawer) */
.room-grid { grid-template-columns: minmax(0, 1fr) 340px; grid-template-areas: "game chat"; }
@media (max-width: 880px) {
  .room-grid { grid-template-columns: 1fr; grid-template-areas: "game"; }
  .side-toggle { display: grid; }
  .rtb-icon.mobile-only { display: grid; }
  .drawer-head { display: flex; }
  .chat-pane { position: fixed; top: 0; right: 0; bottom: 0; height: 100dvh; width: min(380px, 88vw); transform: translateX(100%); transition: transform 0.25s ease; z-index: 200; background: var(--bg); box-shadow: -10px 0 30px rgba(0,0,0,0.2); padding: 14px; overflow-y: auto; }
  .chat-pane.open { transform: translateX(0); }
}
