/* SCAT CAT — PPL design language (warm paper, friendly blue, card red). */
:root {
  --paper: #fdf8f2;
  --paper-deep: #f3ead9;
  --ink: #2a241f;
  --soft: #7a6f66;
  --card-red: #d5281e;
  --card-blue: #2d2a86;
  --green: #3e9b57;
  --green-soft: #dff2e4;
  --yellow: #e8a13c;
  --yellow-soft: #fbeed7;
  --black: #17130f;
  --white: #ffffff;
  --radius: 14px;
  --shadow: 0 2px 6px rgb(42 36 31 / 0.12), 0 10px 24px -10px rgb(42 36 31 / 0.25);
  --font: 'Trebuchet MS', 'Comic Sans MS', 'Segoe UI', system-ui, sans-serif;
}
:root[data-contrast='high'] {
  --paper: #ffffff; --paper-deep: #eeeeee; --ink: #000000; --soft: #333333;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: radial-gradient(circle at 50% 20%, var(--paper) 0%, var(--paper-deep) 100%);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; }
button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--card-blue); outline-offset: 2px; border-radius: 8px; }

.screen { min-height: 100%; display: flex; flex-direction: column; align-items: center; padding: 20px; }
.center { justify-content: center; text-align: center; }

h1.logo { font-size: clamp(2.2rem, 7vw, 4rem); margin: 0.2em 0; letter-spacing: 0.04em; }
h1.logo .scat { color: var(--card-red); }
h1.logo .cat { color: var(--card-blue); }
.tagline { color: var(--soft); margin-top: 0; }

.btn {
  border: none; border-radius: 999px; padding: 14px 30px; font-size: 1.15rem; font-weight: 700;
  background: var(--card-blue); color: var(--white); box-shadow: var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease; min-height: 48px;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn.secondary { background: var(--white); color: var(--ink); border: 2px solid var(--paper-deep); }
.btn.danger { background: var(--card-red); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 18px; }

/* ---------- cards ---------- */
.card {
  width: var(--card-w, 92px); aspect-ratio: 140 / 196; border-radius: 10px;
  background: var(--white); box-shadow: var(--shadow); position: relative;
  display: inline-flex; align-items: center; justify-content: center; user-select: none;
}
.card img { width: 100%; height: 100%; object-fit: contain; border-radius: 10px; display: block; }
/* text-rendered faces over the blank card templates */
.face-glyph {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.face-glyph b { font-weight: 800; color: var(--white); line-height: 1; letter-spacing: 0.01em; }
.face-glyph.red-square::before {
  content: ''; position: absolute; width: 54%; aspect-ratio: 1; background: var(--card-red); border-radius: 8%;
}
.face-glyph.red-square b { position: relative; font-size: calc(var(--card-w, 92px) * 0.34); }
.face-glyph.blue-diamond::before {
  content: ''; position: absolute; width: 52%; aspect-ratio: 1; background: var(--card-blue);
  transform: rotate(45deg) scale(1.08); border-radius: 10%;
}
.face-glyph.blue-diamond b { position: relative; font-size: calc(var(--card-w, 92px) * 0.26); }
.face-glyph.wordface::before {
  content: ''; position: absolute; width: 78%; height: 42%; background: var(--card-blue); border-radius: 12px;
}
.wordcard.real .face-glyph.wordface::before { background: var(--green); }
.wordcard.nonsense .face-glyph.wordface::before, .wordcard.blocked .face-glyph.wordface::before { background: var(--yellow); }
.wordcard.nonsense .face-glyph b, .wordcard.blocked .face-glyph b { color: var(--black); }
.face-glyph.wordface b { position: relative; font-size: calc(var(--card-w, 92px) * 0.21); }
.face-index {
  position: absolute; font-weight: 800; font-size: calc(var(--card-w, 92px) * 0.11);
  pointer-events: none; line-height: 1;
}
.face-index.tl { top: 6%; left: 8%; }
.face-index.br { bottom: 6%; right: 8%; transform: rotate(180deg); }
.ix-red { color: var(--card-red); }
.ix-blue { color: var(--card-blue); }
.word-badge {
  position: absolute; bottom: 4%; right: 6%; font-size: calc(var(--card-w, 92px) * 0.12);
  font-weight: 800; pointer-events: none;
}
.word-badge.real { color: var(--green); }
.word-badge.nonsense, .word-badge.blocked { color: #8a5a10; }
.robot-tag { font-size: 0.8em; opacity: 0.8; }
.card.tappable { cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.card.tappable:hover, .card.tappable:focus-visible { transform: translateY(-6px); box-shadow: 0 6px 10px rgb(42 36 31 / 0.18), 0 18px 34px -12px rgb(42 36 31 / 0.35); }
.card.glow { animation: glow 1.1s ease-in-out infinite; }
@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 3px var(--green), var(--shadow); }
  50% { box-shadow: 0 0 0 7px rgb(62 155 87 / 0.45), var(--shadow); }
}
.card.dim { opacity: 0.4; }
.card.flip-in { animation: flipIn 0.45s ease-out; }
.travel-left { display: inline-block; animation: travelLeft 0.5s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes travelLeft {
  from { transform: translate(-140px, -120px) rotate(-10deg) scale(0.8); opacity: 0.4; }
  to { transform: translate(0, 0) rotate(0) scale(1); opacity: 1; }
}
.joined { transition: gap 0.5s ease; }
.joined.blending { gap: 56px; }
.joined.blending .card { animation: lean 1.7s ease-in-out; }
.joined.together { gap: 2px; }
@keyframes lean { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.blend-dots { letter-spacing: 0.08em; font-size: 1.5rem; }
.bigword.tremble { animation: tremble 0.9s ease-in-out 0.15s; }
@keyframes tremble {
  0%, 100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-4px) rotate(-1.5deg); }
  40% { transform: translateX(4px) rotate(1.5deg); }
  60% { transform: translateX(-4px) rotate(-1deg); }
  80% { transform: translateX(3px) rotate(1deg); }
}
.tray-toggle {
  background: none; border: none; color: var(--soft); font-weight: 700; font-size: 0.85rem;
  letter-spacing: 0.04em; padding: 4px 10px; margin-top: -4px;
}
.tray {
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: 640px;
  background: rgb(255 255 255 / 0.55); border-radius: 12px; padding: 8px 12px; margin-bottom: 4px;
}
.tray-chip {
  background: var(--white); border: 2px solid var(--card-red); color: var(--card-red);
  border-radius: 8px; padding: 2px 8px; font-weight: 800; font-size: 0.9rem;
}
@keyframes flipIn { from { transform: rotateY(90deg) scale(0.9); } to { transform: rotateY(0deg) scale(1); } }

.pile { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pile .stack { position: relative; }
.pile .stack .card { position: relative; }
.pile .stack::before, .pile .stack::after {
  content: ''; position: absolute; inset: 0; border-radius: 10px; background: var(--white);
  box-shadow: var(--shadow); transform: translate(3px, 3px); z-index: -1;
}
.pile .stack::after { transform: translate(6px, 6px); z-index: -2; }
.pile-label { font-weight: 700; font-size: 0.85rem; color: var(--soft); letter-spacing: 0.06em; }
.pile.empty .stack { opacity: 0.35; }

/* ---------- table layout ---------- */
.table-top { width: 100%; max-width: 1080px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.table-top h2 { margin: 0; font-size: 1.3rem; }
.spacer { flex: 1; }
.scorebar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 10px 0; }
.chip {
  background: var(--white); border-radius: 999px; padding: 7px 14px; box-shadow: var(--shadow);
  font-weight: 700; display: flex; gap: 8px; align-items: center; border: 3px solid transparent;
}
.chip.active { border-color: var(--card-blue); }
.chip.out { opacity: 0.55; text-decoration: line-through; }
.chip .pts { color: var(--card-blue); }

.piles-row { display: flex; gap: clamp(20px, 6vw, 70px); margin: 18px 0 10px; }
.prompt { font-size: 1.15rem; font-weight: 700; min-height: 1.6em; text-align: center; margin: 8px 0; }
.prompt .name { color: var(--card-blue); }

.seat {
  width: 100%; max-width: 1080px; background: rgb(255 255 255 / 0.6); border-radius: var(--radius);
  padding: 12px 14px; margin-top: 10px; box-shadow: var(--shadow);
}
.seat.active { border: 3px solid var(--card-blue); }
.seat.out { opacity: 0.6; }
.seat-head { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.seat-cards { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin-top: 8px; }
.group { display: flex; flex-direction: column; gap: 4px; }
.group-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; color: var(--soft); text-transform: uppercase; }
.fan { display: flex; }
.fan > * + * { margin-left: -40px; }
.fan.spread > * + * { margin-left: -16px; }
.fan { flex-wrap: wrap; row-gap: 6px; }
.shelf-empty {
  border: 3px dashed var(--paper-deep); background: transparent; box-shadow: none;
  align-items: center; justify-content: center; color: var(--soft);
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em;
}
.mini { --card-w: 64px; }
.wordstack { display: flex; gap: 4px; flex-wrap: wrap; max-width: 380px; }
.wordpill {
  font-weight: 800; padding: 4px 10px; border-radius: 8px; font-size: 0.95rem;
  background: var(--green-soft); color: var(--green); border: 2px solid var(--green);
}
.wordpill.nonsense { background: var(--yellow-soft); color: #8a5a10; border-color: var(--yellow); }
.wordpill.blocked { background: var(--yellow-soft); color: #8a5a10; border-color: var(--yellow); font-style: italic; }

/* ---------- resolve overlay ---------- */
.overlay {
  position: fixed; inset: 0; background: rgb(42 36 31 / 0.45); display: flex;
  align-items: center; justify-content: center; z-index: 40; padding: 20px;
}
.panel {
  background: var(--paper); border-radius: 20px; padding: 26px; box-shadow: var(--shadow);
  text-align: center; max-width: min(92vw, 560px); animation: pop 0.25s ease-out;
}
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.joined { display: flex; justify-content: center; gap: 6px; margin: 4px 0 8px; }
.joined .card { --card-w: 96px; }
.bigword {
  font-size: clamp(2.4rem, 9vw, 4rem); font-weight: 900; letter-spacing: 0.05em;
  padding: 6px 26px; border-radius: 16px; display: inline-block; margin: 12px 0; animation: pop 0.3s ease-out;
}
.bigword.real { background: var(--green); color: var(--white); }
.bigword.nonsense { background: var(--yellow); color: var(--black); }
.bigword.blocked { background: var(--yellow); color: var(--black); }
.bigword.cat { background: var(--black); color: var(--white); }
.resolve-note { font-size: 1.15rem; font-weight: 700; }
.resolve-note.real { color: var(--green); }
.resolve-note.nonsense { color: #8a5a10; }

/* scat cat! */
.scat-stage { position: relative; height: 120px; overflow: hidden; }
.scat-cat { position: absolute; left: 40%; bottom: 6px; animation: dash 1.5s ease-in 0.25s forwards; }
@keyframes dash {
  0% { transform: translateX(0) scaleX(1); }
  15% { transform: translateX(-8px) scaleX(1); }
  100% { transform: translateX(min(70vw, 640px)) scaleX(1); opacity: 0.9; }
}
.dust { position: absolute; bottom: 10px; left: 34%; font-size: 1.4rem; opacity: 0; animation: puff 1.1s ease-out 0.4s; }
@keyframes puff { 0% { opacity: 0; } 25% { opacity: 0.9; } 100% { opacity: 0; transform: translateX(-30px) scale(1.6); } }

/* pickers */
.picker-grid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; max-width: 480px; }
.pick {
  min-width: 58px; min-height: 58px; border-radius: 12px; border: 3px solid var(--paper-deep);
  background: var(--white); font-size: 1.5rem; font-weight: 800; box-shadow: var(--shadow);
}
.pick.red { color: var(--card-red); }
.pick.blue { color: var(--card-blue); }
.pick:hover { border-color: var(--card-blue); transform: translateY(-2px); }

/* setup */
.setup-box { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; width: min(94vw, 560px); margin-top: 14px; }
.setup-box h3 { margin: 0 0 10px; }
.name-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.name-row input {
  flex: 1; font-size: 1.05rem; padding: 10px 12px; border-radius: 10px; border: 2px solid var(--paper-deep); font-family: inherit;
}
.diff-row, .unit-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 14px; }
.choice {
  border: 3px solid var(--paper-deep); background: var(--white); border-radius: 12px;
  padding: 10px 16px; font-weight: 700; font-size: 1rem;
}
.choice.selected { border-color: var(--card-blue); background: #e8ecfb; }
.hint { color: var(--soft); font-size: 0.9rem; margin: 4px 0 10px; }

/* confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i {
  position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px;
  animation: fall 2.6s linear forwards;
}
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }

.gameover-list { width: min(94vw, 520px); margin-top: 10px; }
.go-row {
  display: flex; align-items: center; gap: 10px; background: var(--white); border-radius: 12px;
  box-shadow: var(--shadow); padding: 12px 16px; margin-bottom: 8px; font-weight: 700; font-size: 1.1rem;
}
.go-row.winner { border: 3px solid var(--yellow); }
.go-row .pts { margin-left: auto; color: var(--card-blue); font-size: 1.3rem; }

.footer-note { color: var(--soft); font-size: 0.8rem; margin-top: auto; padding-top: 16px; text-align: center; }
.iconbtn { background: var(--white); border: 2px solid var(--paper-deep); border-radius: 999px; min-width: 44px; min-height: 44px; font-size: 1.2rem; box-shadow: var(--shadow); }

@media (prefers-reduced-motion: reduce) {
  .card.flip-in, .panel, .bigword, .travel-left, .joined.blending .card, .bigword.tremble { animation: none; }
  .joined.blending { gap: 8px; }
  .scat-cat { animation: none; opacity: 0.85; left: 60%; }
  .card.glow { animation: none; box-shadow: 0 0 0 4px var(--green), var(--shadow); }
  .confetti i { animation-duration: 0.01s; }
}
@media (max-width: 640px) {
  .card { --card-w: 72px; }
  .mini { --card-w: 52px; }
  .fan > * + * { margin-left: -36px; }
}

/* ---------- Blazor host chrome (not part of the original design) ---------- */
#app > .screen { min-height: 100vh; }
.boot { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
/* Friendly crash screen — a child should never see a stack trace.
   Blazor reveals this div with an inline display:block on unhandled error. */
#blazor-error-ui {
  display: none; position: fixed; inset: 0; z-index: 100; text-align: center;
  background: radial-gradient(circle at 50% 20%, var(--paper) 0%, var(--paper-deep) 100%);
  padding: 22vh 20px 20px;
}
#blazor-error-ui a { text-decoration: none; }
