/* Fredoka, hosted here so nobody's browser has to contact Google (see fonts/README.txt). */
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/fredoka-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/fredoka-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg-1: #1a1245;
  --bg-2: #3a1a73;
  --ink: #ffffff;
  --ink-dark: #1d1440;
  --muted: #b9b0e6;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-line: rgba(255, 255, 255, 0.16);
  --yellow: #ffd23f;
  --yellow-deep: #d49f00;
  --pink: #ff4f8b;
  --pink-deep: #c42a62;
  --mint: #2ee6a6;
  --mint-deep: #12a877;
  --sky: #3ec6ff;
  --danger: #ff6b6b;
  --radius: 22px;
  --font: 'Fredoka', ui-rounded, 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

/* contain: a downward swipe at the top mid-guess shouldn't reload the page on Android */
html { -webkit-text-size-adjust: 100%; overscroll-behavior-y: contain; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.35;
  color: var(--ink);
  background-color: var(--bg-1);
  background-image:
    radial-gradient(circle at 15% 0%, rgba(255, 79, 139, 0.28), transparent 45%),
    radial-gradient(circle at 90% 10%, rgba(62, 198, 255, 0.22), transparent 40%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p { margin: 0; }

button, input { font: inherit; color: inherit; }

/* manipulation: no double-tap zoom. The rest stops long-press from selecting text or popping a menu. */
button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }

.noscript { padding: 24px; text-align: center; }

/* ------------------------------------------------------------------ layout */

.screen {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.screen.narrow { max-width: 560px; }

.enter { animation: rise 0.35s ease-out both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.card {
  background: var(--panel);
  border: 2px solid var(--panel-line);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(6px);
}

.card h2 {
  font-size: 1.15rem;
  margin-bottom: 12px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.center { text-align: center; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.center { justify-content: center; }
.grow { flex: 1 1 auto; min-width: 0; }

/* --------------------------------------------------------------- top bar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.85rem;
  color: var(--muted);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid var(--panel-line);
  font-weight: 600;
  font-size: 0.95rem;
  max-width: 100%;
}

.chip.code-chip { letter-spacing: 0.18em; font-weight: 700; }
.chip.good { background: rgba(46, 230, 166, 0.2); border-color: rgba(46, 230, 166, 0.5); }
.chip.text-chip { overflow-wrap: anywhere; }

.link-btn {
  background: none;
  border: 0;
  padding: 6px 4px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 0.95rem;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  --btn-bg: rgba(255, 255, 255, 0.14);
  --btn-edge: rgba(0, 0, 0, 0.28);
  --btn-ink: var(--ink);
  appearance: none;
  border: 0;
  border-radius: 16px;
  padding: 12px 20px;
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 5px 0 var(--btn-edge);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s;
  min-height: 48px;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--btn-edge); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: 0 5px 0 var(--btn-edge); }

.btn.primary { --btn-bg: var(--yellow); --btn-edge: var(--yellow-deep); --btn-ink: var(--ink-dark); }
.btn.pink { --btn-bg: var(--pink); --btn-edge: var(--pink-deep); --btn-ink: #fff; }
.btn.mint { --btn-bg: var(--mint); --btn-edge: var(--mint-deep); --btn-ink: var(--ink-dark); }
.btn.danger { --btn-bg: var(--danger); --btn-edge: #b03a3a; --btn-ink: var(--ink-dark); }
.btn.block { width: 100%; }
.btn.big { font-size: 1.25rem; padding: 16px 24px; min-height: 60px; }
.btn.tiny { padding: 6px 12px; min-height: 36px; font-size: 0.85rem; border-radius: 12px; box-shadow: 0 3px 0 var(--btn-edge); }
.btn.tiny:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--btn-edge); }

/* ------------------------------------------------------------------ inputs */

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 600; font-size: 0.95rem; color: var(--muted); }

.input {
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border-radius: 16px;
  border: 3px solid transparent;
  background: #fff;
  color: var(--ink-dark);
  font-weight: 600;
  font-size: 1.1rem;
  outline: none;
}
.input::placeholder { color: #8d84b8; font-weight: 500; }
.input:focus { border-color: var(--sky); }
textarea.input { min-height: 150px; resize: vertical; font-family: inherit; line-height: 1.35; text-align: left; }
.good-text { color: var(--mint); font-weight: 600; }
.words-form .field { text-align: left; }
.input.code { text-transform: uppercase; letter-spacing: 0.3em; text-align: center; font-weight: 700; }

.error-text {
  color: #ffd0d0;
  background: rgba(255, 107, 107, 0.18);
  border: 2px solid rgba(255, 107, 107, 0.45);
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 500;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 2px; background: var(--panel-line); }

/* -------------------------------------------------------------------- home */

.hero { text-align: center; padding-top: 28px; display: flex; flex-direction: column; align-items: center; gap: 14px; }

.logo { position: relative; display: inline-block; padding: 10px 0; }
/* The logo is a "HELLO, I AM" sticker: pink header band, big name, peeling corner. */
.logo-tag {
  position: relative;
  display: inline-block;
  overflow: hidden;
  background: #fff;
  color: var(--ink-dark);
  font-weight: 700;
  font-size: clamp(2rem, 9vw, 3.2rem);
  line-height: 1;
  letter-spacing: 0.02em;
  padding: 44px 26px 14px;
  border-radius: 18px;
  transform: rotate(-3deg);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.25);
}
.logo-tag::before {
  content: 'HELLO, I AM';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 30px;
  background: var(--pink);
  color: var(--ink-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  line-height: 30px;
}
.logo-tag::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: 0;
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, transparent 50%, rgba(26, 18, 69, 0.16) 50%);
}
.logo-tag small { display: block; font-size: 0.42em; letter-spacing: 0.35em; color: var(--pink); margin-top: 4px; }

.tagline { color: var(--muted); font-size: 1.1rem; max-width: 30ch; }
.fine-print { margin: 4px 0 0; padding: 0 12px 8px; text-align: center; color: var(--muted); font-size: 0.78rem; opacity: 0.85; }
.fine-print a { color: inherit; text-decoration: underline; }

/* Privacy and terms pages */
.legal h1 { font-size: clamp(1.8rem, 7vw, 2.4rem); margin: 8px 0 0; }
.legal h2 { font-size: 1.15rem; margin: 0 0 8px; }
.legal p, .legal li { color: var(--muted); line-height: 1.55; margin-top: 0; }
.legal p + p { margin-top: 10px; }
.legal ul { margin: 0 0 10px; padding-left: 1.2rem; }
.legal li { margin: 6px 0; }
.legal a { color: var(--sky); }
.legal a.brand { color: inherit; text-decoration: none; }
.legal .updated { margin: 0; font-size: 0.9rem; color: var(--muted); }

.steps { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { display: flex; gap: 12px; align-items: flex-start; color: var(--muted); font-size: 0.95rem; }
.steps li::before {
  counter-increment: step;
  content: counter(step);
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--yellow);
  color: var(--ink-dark);
  font-weight: 700;
  font-size: 0.85rem;
}
.steps b { color: var(--ink); font-weight: 600; }

.join-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }

/* ------------------------------------------------------------------- lobby */

.code-card { text-align: center; }
.big-code {
  appearance: none;
  background: rgba(255, 255, 255, 0.1);
  border: 3px dashed rgba(255, 255, 255, 0.35);
  border-radius: 20px;
  padding: 6px 26px;
  margin: 6px 0 12px;
  font-size: clamp(2.6rem, 14vw, 4rem);
  font-weight: 700;
  letter-spacing: 0.22em;
  padding-left: calc(26px + 0.22em);
  color: var(--yellow);
}

.players { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.player {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 16px;
  padding: 10px 12px;
}
.player.away { opacity: 0.55; }
/* The host's Make host / Remove buttons drop to their own line instead of squeezing the name into pieces. */
.player .grow { flex: 1 1 7rem; }
.player .name { font-weight: 600; overflow-wrap: break-word; }
.player .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.player .actions { margin-left: auto; display: flex; gap: 6px; flex-shrink: 0; }

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}
.badge.host { background: var(--yellow); color: var(--ink-dark); }
.badge.you { background: var(--sky); color: var(--ink-dark); }
.badge.off { background: rgba(255, 107, 107, 0.3); }

.avatar {
  --pc: #ffd43b;
  position: relative;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--pc);
}
.avatar::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 19px;
  width: 5px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-dark);
  box-shadow: 15px 0 0 var(--ink-dark);
}
.avatar::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: 15px;
  height: 7px;
  transform: translateX(-50%);
  border: 3px solid var(--ink-dark);
  border-top: 0;
  border-radius: 0 0 15px 15px;
}

.cat-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
/* The three "who picks the words" choices share one row, even on a phone. */
.cat-grid.modes { grid-template-columns: repeat(2, 1fr); }
.cat-grid.modes .cat { padding: 12px 6px; font-size: 0.95rem; }
.cat-grid.modes .cat .sub { font-size: 0.7rem; }

.cat {
  position: relative;
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px;
  border-radius: 18px;
  border: 3px solid transparent;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 600;
  text-align: center;
  line-height: 1.15;
  transition: transform 0.1s, background 0.15s, border-color 0.15s;
}
.cat:disabled { cursor: default; }
.cat .emoji { font-size: 1.9rem; line-height: 1.1; }
.cat .sub { font-size: 0.75rem; font-weight: 500; color: var(--muted); }
.cat.selected { background: rgba(255, 210, 63, 0.2); border-color: var(--yellow); }
.cat.off { opacity: 0.45; }
.cat .tick {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.18);
}
.cat .tick.on { background: var(--mint); color: var(--ink-dark); }

.current-cat { display: flex; align-items: center; gap: 12px; font-size: 1.2rem; font-weight: 600; }
.current-cat .emoji { font-size: 2.2rem; }

.notice {
  background: rgba(255, 210, 63, 0.16);
  border: 2px solid rgba(255, 210, 63, 0.45);
  border-radius: 16px;
  padding: 10px 14px;
  font-weight: 500;
}

.start-area { display: flex; flex-direction: column; gap: 10px; align-items: stretch; text-align: center; }

/* ----------------------------------------------------------------- writing */

.write-card { text-align: center; display: flex; flex-direction: column; gap: 14px; padding: 26px 20px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.8rem; font-weight: 700; color: var(--pink); }
.write-card h1 { font-size: clamp(1.6rem, 6vw, 2.3rem); line-height: 1.15; }
.target { color: var(--yellow); overflow-wrap: anywhere; }
.lock { font-size: 3.4rem; animation: pop 0.45s cubic-bezier(0.3, 1.6, 0.5, 1) both; }

@keyframes pop {
  from { transform: scale(0.2); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.progress { height: 16px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), var(--sky)); border-radius: 999px; transition: width 0.4s ease; }
.progress-label { font-weight: 700; font-size: 1.2rem; text-align: center; margin-top: 8px; }

.ready-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }

/* ----------------------------------------------------------------- playing */

.hint { text-align: center; color: var(--muted); }

.board {
  display: grid;
  gap: 22px 14px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  padding: 8px 0 0;
}

.pcard {
  --pc: #ffd43b;
  --pc-dark: #b89400;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  min-width: 0;
}

/* Each player is a little bust with a "HELLO, I AM" sticker stuck on their chest. */
.tag {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: 190px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 12px 10px;
  margin-top: -38px;
  overflow: hidden;
  background: #fff;
  color: var(--ink-dark);
  border-radius: 10px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.25);
  text-align: center;
  font-weight: 700;
  line-height: 1.1;
  overflow-wrap: anywhere;
  transform: rotate(-2.5deg);
}
.tag::before {
  content: 'HELLO, I AM';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 20px;
  background: var(--pc);
  color: var(--ink-dark);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 20px;
}
.tag::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  background: linear-gradient(135deg, transparent 50%, rgba(26, 18, 69, 0.16) 50%);
}
.pcard:nth-child(even) .tag { transform: rotate(2.5deg); }
.tag.len-s { font-size: 1.6rem; }
.tag.len-m { font-size: 1.3rem; }
.tag.len-l { font-size: 1.05rem; }
.tag.len-xl { font-size: 0.9rem; }

.pcard.you:not(.solved) .tag {
  background: repeating-linear-gradient(45deg, #fff, #fff 10px, #efeaff 10px, #efeaff 20px);
  color: var(--pink);
  font-size: 2rem;
  letter-spacing: 0.1em;
  animation: wobble 2.4s ease-in-out infinite;
}

@keyframes wobble {
  0%, 100% { transform: rotate(-2.5deg); }
  50% { transform: rotate(2.5deg) translateY(-2px); }
}

.head { position: relative; z-index: 1; width: 100%; max-width: 190px; height: 122px; }

.shoulders {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 0;
  height: 58px;
  border-radius: 36px 36px 10px 10px;
  background: var(--pc-dark);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.22);
}

.face {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 50%;
  width: 88px;
  height: 88px;
  margin-left: -44px;
  border-radius: 50%;
  background: var(--pc);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.12);
}
.face::before {
  content: '';
  position: absolute;
  left: 25px;
  top: 40px;
  width: 10px;
  height: 14px;
  border-radius: 50%;
  background: var(--ink-dark);
  box-shadow: 28px 0 0 var(--ink-dark);
}
.face::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 17px;
  width: 28px;
  height: 13px;
  transform: translateX(-50%);
  border: 4px solid var(--ink-dark);
  border-top: 0;
  border-radius: 0 0 28px 28px;
}
.pcard.you:not(.solved) .face::after { width: 14px; height: 14px; border: 4px solid var(--ink-dark); border-radius: 50%; }
.pcard.solved .face::after { height: 20px; background: var(--ink-dark); }
.pcard.solved .shoulders { background: var(--mint-deep); }
.pcard.solved .tag { background: #e9fff6; box-shadow: 0 5px 0 var(--mint-deep); }
.pcard.solved .tag::before { background: var(--mint); }

.pname {
  margin-top: 10px;
  max-width: 100%;
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  overflow-wrap: anywhere;
  text-align: center;
}

.pstatus { margin-top: 2px; font-size: 0.85rem; min-height: 1.2em; text-align: center; color: var(--muted); font-weight: 500; }
.pcard.solved .pstatus { color: var(--mint); font-weight: 700; }

.actionbar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin: 8px -16px 0;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg-1) 60%, rgba(26, 18, 69, 0));
}
.actionbar-inner { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
/* Opaque (panel tint over a solid base): the board scrolls underneath the sticky bar and must not show through. */
.guess-box { background: linear-gradient(var(--panel), var(--panel)), #2a1a63; border: 2px solid var(--panel-line); border-radius: 20px; padding: 14px; display: grid; gap: 10px; }
.guess-box h3 { font-size: 1.15rem; }

.know-it { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.025); }
}

.celebrate { text-align: center; font-weight: 700; font-size: 1.1rem; color: var(--mint); }

.banner-all { background: linear-gradient(90deg, rgba(46, 230, 166, 0.3), rgba(62, 198, 255, 0.3)); border: 2px solid rgba(46, 230, 166, 0.6); border-radius: 18px; padding: 12px; text-align: center; font-weight: 700; font-size: 1.15rem; animation: pop 0.4s both; }

/* ----------------------------------------------------------------- results */

.results-head { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; padding-top: 8px; }
.results-head h1 { font-size: clamp(2rem, 8vw, 3rem); }

.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.row-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 14px;
  align-items: center;
  background: var(--panel);
  border: 2px solid var(--panel-line);
  border-radius: 18px;
  padding: 14px 16px;
}
.row-card .line { font-size: 1.1rem; overflow-wrap: anywhere; }
.row-card .who { font-weight: 700; }
.row-card .gave { color: var(--muted); }
.row-card .arrow { color: var(--yellow); font-weight: 700; }
.row-card .answer { font-weight: 700; color: var(--yellow); }
.row-card .meta { font-size: 0.9rem; font-weight: 600; text-align: right; white-space: nowrap; }
.row-card .meta.win { color: var(--mint); }
.row-card .meta.lose { color: var(--muted); }

.next-actions { display: grid; gap: 12px; }
.next-actions .secondary { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }

/* ----------------------------------------------------------------- overlays */

.banner {
  position: sticky;
  top: 0;
  z-index: 30;
  text-align: center;
  padding: 8px 12px;
  background: var(--danger);
  color: var(--ink-dark);
  font-weight: 700;
  font-size: 0.95rem;
}
.banner.connecting { background: var(--yellow); color: var(--ink-dark); }

#toasts {
  position: fixed;
  z-index: 60;
  top: calc(10px + env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding: 0 12px;
}
.toast {
  background: #fff;
  color: var(--ink-dark);
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 14px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.25);
  max-width: min(92vw, 460px);
  overflow-wrap: anywhere;
  animation: toast-in 0.25s ease-out both;
}
.toast.success { background: var(--mint); }
.toast.error { background: var(--danger); color: var(--ink-dark); }
.toast.out { animation: toast-out 0.25s ease-in both; }
@keyframes toast-in { from { transform: translateY(-16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { transform: translateY(-12px); opacity: 0; } }

.flash {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  animation: fade 0.18s ease-out both;
}
.flash.correct { background: rgba(18, 168, 119, 0.92); }
.flash.nope { background: rgba(196, 42, 98, 0.92); }
.flash h1 { font-size: clamp(3rem, 16vw, 6.5rem); line-height: 1; text-shadow: 0 6px 0 rgba(0, 0, 0, 0.25); animation: slam 0.45s cubic-bezier(0.3, 1.5, 0.5, 1) both; }
.flash.nope h1 { animation: slam 0.3s ease-out both, shake 0.5s 0.25s ease-in-out both; }
.flash p { font-size: clamp(1.1rem, 5vw, 1.6rem); font-weight: 600; max-width: 24ch; overflow-wrap: anywhere; }
.flash .reveal { background: #fff; color: var(--ink-dark); border-radius: 16px; padding: 10px 22px; font-size: clamp(1.4rem, 7vw, 2.2rem); font-weight: 700; transform: rotate(-2deg); box-shadow: 0 6px 0 rgba(0, 0, 0, 0.25); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slam { from { transform: scale(2.4); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-14px) rotate(-2deg); }
  40% { transform: translateX(14px) rotate(2deg); }
  60% { transform: translateX(-10px); }
  80% { transform: translateX(10px); }
}

.confetti {
  position: fixed;
  z-index: 71;
  top: -20px;
  width: 10px;
  height: 16px;
  border-radius: 3px;
  pointer-events: none;
  animation: fall var(--dur, 2.4s) var(--delay, 0s) linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(var(--spin, 540deg)); }
}

#modal:empty { display: none; }
.modal-back {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 6, 32, 0.75);
  animation: fade 0.15s ease-out both;
}
.modal {
  width: min(100%, 420px);
  background: #2a1a63;
  border: 2px solid var(--panel-line);
  border-radius: 24px;
  padding: 22px;
  display: grid;
  gap: 14px;
  animation: rise 0.2s ease-out both;
}
.modal h2 { font-size: 1.3rem; }
.modal .row { justify-content: flex-end; }

.spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--yellow);
  animation: spin 0.9s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Hover effects only where there is a real hover: on a phone they would stay stuck after a tap. */
@media (hover: hover) {
  .btn:hover:not(:disabled) { filter: brightness(1.08); }
  .link-btn:hover { color: var(--ink); }
  .big-code:hover { background: rgba(255, 255, 255, 0.16); }
  .cat:hover:not(:disabled) { background: rgba(255, 255, 255, 0.18); transform: translateY(-2px); }
}

/* Fingers need bigger targets than mice (about 44px). */
@media (pointer: coarse) {
  .btn.tiny, .chip.code-chip, .link-btn { min-height: 44px; }
  .link-btn { padding: 10px 8px; }
}

@media (max-width: 480px) {
  body { font-size: 16px; }
  .card { padding: 16px; }
  .next-actions .secondary { grid-template-columns: 1fr; }
  .row-card { grid-template-columns: 1fr; }
  .row-card .meta { text-align: left; }
  .players { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .confetti { display: none; }
}

/* ----------------------------------------------------------------- scoreboard */

.scores { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.score-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.07); font-weight: 600; }
.score-row.you { background: rgba(62, 198, 255, 0.18); }
.score-row .rank { width: 1.8em; text-align: center; color: var(--muted); font-weight: 700; }
.score-row .sname { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.score-row .gained { color: var(--mint); font-weight: 700; font-size: 0.9rem; }
.score-row .total { min-width: 2ch; text-align: right; font-weight: 700; font-size: 1.15rem; }
.scoreboard .link-btn { margin-top: 10px; }

/* ---------------------------------------------------------------- round timer */

.timer-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.chip.pick { appearance: none; cursor: pointer; min-height: 44px; padding: 8px 13px; font-size: 0.95rem; border: 2px solid transparent; border-radius: 999px; background: rgba(255, 255, 255, 0.12); color: var(--ink); font: inherit; font-weight: 600; }
.chip.pick.on { background: rgba(255, 210, 63, 0.22); border-color: var(--yellow); }
.chip.timer { font-variant-numeric: tabular-nums; }
.chip.timer.urgent { background: var(--pink); color: var(--ink-dark); animation: pulse 1s ease-in-out infinite; }

.icon-btn { appearance: none; cursor: pointer; min-width: 44px; min-height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; font-size: 1.25rem; line-height: 1; }
@media (hover: hover) { .icon-btn:hover { background: rgba(255, 255, 255, 0.12); } }
