:root {
  --bg: #1a1025;
  --bg-card: #251536;
  --bg-card-hover: #301c44;
  --accent: #ff7a3d;
  --accent-2: #ffd23f;
  --accent-3: #35e0a1;
  --accent-4: #ff4d97;
  --text: #f5f0ff;
  --text-dim: #b7a9cc;
  --border: #3a2650;
  --danger: #ff4d6d;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top left, #2a1740, #150c22 60%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  min-height: 100%;
}

a { color: inherit; text-decoration: none; }

.wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

header.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  flex-wrap: wrap;
  gap: 12px;
}

.logo {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.logo span { color: var(--accent); }

nav.crumbs {
  font-size: 0.9rem;
  color: var(--text-dim);
}
nav.crumbs a { color: var(--accent-2); }

.hero {
  text-align: center;
  padding: 40px 10px 30px;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  margin: 0 0 12px;
  line-height: 1.1;
}
.hero h1 .accent { color: var(--accent); }
.hero p {
  color: var(--text-dim);
  max-width: 560px;
  margin: 0 auto;
  font-size: 1.05rem;
}

.section-title {
  font-size: 1.3rem;
  margin: 40px 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title .pill {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: var(--accent-3);
  color: #08251a;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 700;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  box-shadow: var(--shadow);
}
.card.playable:hover {
  transform: translateY(-4px);
  background: var(--bg-card-hover);
  border-color: var(--accent);
  cursor: pointer;
}
.card .emoji { font-size: 2rem; }
.card h3 { margin: 0; font-size: 1.1rem; }
.card p { margin: 0; color: var(--text-dim); font-size: 0.9rem; flex-grow: 1; }
.card .tag {
  align-self: flex-start;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700;
}
.tag.ready { background: var(--accent-3); color: #08251a; }
.tag.soon { background: var(--border); color: var(--text-dim); }
.tag.online {
  background: rgba(77, 181, 255, 0.18);
  color: #8fd0ff;
  border: 1px solid rgba(77, 181, 255, 0.45);
}
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; }

footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 40px 0 10px;
}

/* Game shell */
.game-shell {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.btn {
  background: var(--accent);
  color: #241000;
  border: none;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-2px); background: #ff8a52; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn.secondary { background: transparent; border: 1px solid var(--accent); color: var(--accent); }
.btn.danger { background: var(--danger); color: #2a0008; }
.btn.small { padding: 8px 16px; font-size: 0.85rem; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

input[type=text], input[type=number], select {
  background: #170e26;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 1rem;
  width: 100%;
}
input[type=text]:focus, select:focus { outline: 2px solid var(--accent); }

label { font-size: 0.85rem; color: var(--text-dim); display: block; margin-bottom: 6px; }
.field { margin-bottom: 16px; }

.timer {
  font-size: 3rem;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
  margin: 10px 0;
}
.timer.warn { color: var(--accent-2); }
.timer.critical { color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

.scramble-word {
  text-align: center;
  font-size: clamp(2rem, 8vw, 3.2rem);
  letter-spacing: 8px;
  font-weight: 800;
  color: var(--accent-2);
  margin: 20px 0;
  word-break: break-all;
}

.scoreboard {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.score-box {
  flex: 1;
  min-width: 120px;
  background: #170e26;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  border: 1px solid var(--border);
}
.score-box.active { border-color: var(--accent); }
.score-box .name { font-size: 0.8rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.score-box .val { font-size: 1.8rem; font-weight: 800; }

.feedback { text-align: center; font-weight: 700; min-height: 26px; margin: 8px 0; }
.feedback.ok { color: var(--accent-3); }
.feedback.bad { color: var(--danger); }

.letter-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin: 16px 0;
}
.letter-btn {
  background: #170e26;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 0;
  font-weight: 700;
  cursor: pointer;
}
.letter-btn:hover { border-color: var(--accent); }
.letter-btn.chosen { background: var(--accent); color: #241000; }

.cat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.cat-row label { width: 110px; margin: 0; flex-shrink: 0; }

.chain-log {
  list-style: none;
  padding: 0;
  margin: 16px 0;
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chain-log li {
  background: #170e26;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.95rem;
}
.chain-log li .who { color: var(--accent-2); font-weight: 700; margin-right: 6px; }

.rules {
  background: #170e26;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 20px;
}
.rules summary { cursor: pointer; color: var(--accent-2); font-weight: 700; }

@media (max-width: 480px) {
  .letter-grid { grid-template-columns: repeat(5, 1fr); }
  .cat-row { flex-wrap: wrap; }
}

/* Header widgets */
.header-widgets {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.profile-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.profile-chip:hover { border-color: var(--accent); }
.profile-emoji { font-size: 1.1rem; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 5, 18, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow);
  max-height: 90vh;
  overflow-y: auto;
}

.profile-list { display: flex; flex-direction: column; gap: 8px; }
.profile-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #170e26;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}
.profile-row.active { border-color: var(--accent-3); }
.profile-row .profile-name { flex-grow: 1; font-weight: 600; }

.emoji-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.emoji-btn { width: 44px; padding: 8px 0; font-size: 1.2rem; }

/* Online status bar shared by every game */
.online-bar {
  background: #170e26;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 0.92rem;
  text-align: center;
  color: var(--text-dim);
}
.online-bar.ok { border-color: var(--accent-3); color: var(--text); }
.online-bar.bad { border-color: var(--danger); color: var(--text); }
.online-bar strong { color: var(--accent-2); }

.online-pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(53, 224, 161, 0.15);
  color: var(--accent-3);
  border: 1px solid rgba(53, 224, 161, 0.4);
}

.seat-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.seat {
  flex: 1;
  background: #170e26;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.seat.active {
  border-color: var(--accent-2);
  box-shadow: 0 0 18px rgba(255, 210, 63, 0.2);
}
.seat.you .seat-name::after {
  content: " (you)";
  color: var(--accent-3);
  font-weight: 700;
}
.seat-name {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seat-score { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.seat-sub { font-size: 0.75rem; color: var(--text-dim); }

/* Ncho board */
.ncho-stage { display: flex; justify-content: center; margin: 10px 0 4px; }
.ncho-stage svg {
  width: 100%;
  height: auto;
  max-width: 900px;
  touch-action: manipulation;
  user-select: none;
}
.ncho-stage .pit-hit { cursor: default; }
.ncho-stage .pit-hit.playable { cursor: pointer; }
.ncho-stage .pit-ring.playable {
  animation: pitPulse 1.8s ease-in-out infinite;
}
@keyframes pitPulse {
  0%, 100% { stroke-opacity: 0.35; }
  50% { stroke-opacity: 1; }
}
/* the pit's number lights up as it changes, so it's easy to count along */
.ncho-stage text.count-pop { animation: countPop 0.45s ease-out; }
@keyframes countPop {
  0% { fill: #ffd23f; }
  60% { fill: #ffd23f; }
  100% { fill: #fdf1d6; }
}

.ncho-stage .sow-flash { animation: sowFlash 0.5s ease-out; }
@keyframes sowFlash {
  0% { filter: brightness(2.1) drop-shadow(0 0 6px rgba(255, 210, 63, 0.9)); }
  100% { filter: brightness(1); }
}
.ncho-stage .capture-flash { animation: captureFlash 0.8s ease-out; }
@keyframes captureFlash {
  0% { filter: brightness(2.6) saturate(1.8) drop-shadow(0 0 10px rgba(53, 224, 161, 0.9)); }
  100% { filter: brightness(1); }
}
.turn-banner {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  margin: 6px 0 2px;
}
.turn-banner.mine { color: var(--accent-3); }

/* Dots and boxes */
.dab-stage { display: flex; justify-content: center; margin: 12px 0; }
.dab-stage svg { width: 100%; height: auto; max-width: 460px; touch-action: manipulation; }
.dab-stage .edge-hit { cursor: pointer; }

.waiting-note {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
  margin: 8px 0;
}

.connect-status {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin: 12px 0 4px;
  min-height: 20px;
}
.connect-status::after {
  content: "";
  display: inline-block;
  width: 10px;
  text-align: left;
  animation: dots 1.4s steps(4, end) infinite;
}
@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

/* ---- how a game ends ---- */

.result-title {
  text-align: center;
  font-size: clamp(1.7rem, 7vw, 2.6rem);
  margin: 6px 0 4px;
  animation: resultIn 0.65s cubic-bezier(0.18, 1.4, 0.4, 1) both;
}
.result-title.win {
  color: var(--accent-2);
  text-shadow: 0 0 26px rgba(255, 210, 63, 0.45);
}
.result-title.close, .result-title.tie, .result-title.done { color: var(--text); }

.result-subtitle {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.98rem;
  margin: 0 0 18px;
  animation: fadeUp 0.5s ease-out 0.18s both;
}

@keyframes resultIn {
  0% { opacity: 0; transform: scale(0.75) translateY(10px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes fadeUp {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 200;
}
.confetti-bit {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 14px;
  opacity: 0.95;
  animation-name: confettiFall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: 0.9; }
}

/* ---- general polish ---- */

#setup-screen, #play-screen, #end-screen {
  animation: screenIn 0.32s ease-out both;
}
@keyframes screenIn {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

.btn { will-change: transform; }
.btn:active { transform: translateY(1px) scale(0.985); }

.seat { transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease; }
.seat.active { transform: translateY(-2px); }
.seat-score { transition: color 0.2s ease; }

.card { animation: cardIn 0.4s ease-out both; }
.grid .card:nth-child(2) { animation-delay: 0.04s; }
.grid .card:nth-child(3) { animation-delay: 0.08s; }
.grid .card:nth-child(4) { animation-delay: 0.12s; }
.grid .card:nth-child(5) { animation-delay: 0.16s; }
.grid .card:nth-child(6) { animation-delay: 0.2s; }
.grid .card:nth-child(n+7) { animation-delay: 0.24s; }
@keyframes cardIn {
  0% { opacity: 0; transform: translateY(14px); }
  100% { opacity: 1; transform: translateY(0); }
}

.modal-box { animation: modalIn 0.28s cubic-bezier(0.2, 1.2, 0.4, 1) both; }
@keyframes modalIn {
  0% { opacity: 0; transform: scale(0.94) translateY(8px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.feedback { transition: color 0.2s ease; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

