/* Catan - a small, deliberately calm interface.
   Ocean-dark chrome so the warm board art carries all the colour. */

:root {
  --bg:        #121a24;
  --sea:       #17303f;
  --sea-deep:  #102431;
  --panel:     #1b2634;
  --panel-2:   #223042;
  --raised:    #2a3a4e;
  --ink:       #ece4d3;
  --ink-dim:   #b9c4d1;
  --muted:     #8695a6;
  --line:      rgba(255, 255, 255, .10);
  --line-soft: rgba(255, 255, 255, .06);
  --gold:      #e0a94a;
  --gold-dim:  #a97f34;
  --good:      #4aa96c;
  --bad:       #d2564b;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 6px 24px rgba(0, 0, 0, .38);
  --dock-h:    148px;
  --side-w:    330px;

  --brick:  #b4552f;
  --lumber: #2f7a45;
  --wool:   #7fb551;
  --grain:  #dfa92c;
  --ore:    #7b8ea3;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- buttons */
.btn {
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--ink);
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 560;
  line-height: 1.1;
  transition: background .13s, border-color .13s, transform .06s, opacity .13s;
  white-space: nowrap;
}
.btn:hover:not(:disabled)  { background: #33465e; border-color: rgba(255,255,255,.18); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn--primary { background: var(--gold); border-color: var(--gold); color: #23180a; }
.btn--primary:hover:not(:disabled) { background: #eeba5e; border-color: #eeba5e; }
.btn--ghost   { background: transparent; }
.btn--ghost:hover:not(:disabled) { background: var(--panel-2); }
.btn--small   { padding: 6px 11px; font-size: 13px; }
.btn--danger  { border-color: rgba(210,86,75,.5); color: #ffb3ab; }
.btn--danger:hover:not(:disabled) { background: rgba(210,86,75,.16); }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  background: rgba(18, 26, 36, .82);
  backdrop-filter: blur(6px);
  color: var(--ink);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 17px; line-height: 1;
}
.icon-btn:hover { background: var(--raised); }

input, select {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--gold-dim); outline-offset: -1px; }
select { width: 100%; cursor: pointer; }
select option { background: var(--panel); color: var(--ink); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > input { flex: 1 1 8rem; }

/* ---------------------------------------------------------------- layout */
.app { height: 100%; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.topbar__home {
  background: none; border: 0; cursor: pointer; flex: none;
  padding: 6px 4px;                 /* keeps the logo a comfortable tap target */
  display: grid; place-items: center; min-height: 40px;
  border-radius: var(--radius-sm);
}
.topbar__home:hover { background: var(--panel-2); }
.topbar__home img { height: 30px; width: auto; }
.topbar__title { min-width: 0; flex: 1; }
.topbar__title h1 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__title p  { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__right { display: flex; align-items: center; gap: 8px; flex: none; }

.clock {
  font-variant-numeric: tabular-nums;
  font-size: 12.5px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px;
}
.clock.is-urgent { color: #ffbdb6; border-color: rgba(210,86,75,.45); }

/* ---------------------------------------------------------------- lobby */
.lobby { flex: 1; overflow: auto; padding: 26px 18px 60px; }
.lobby__inner { max-width: 820px; margin: 0 auto; display: grid; gap: 18px; }
.lobby__logo { width: min(320px, 68%); margin: 4px auto 6px; }
.lobby__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.game-list { display: grid; gap: 10px; }
.game-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  cursor: pointer; text-align: left; width: 100%;
  transition: border-color .13s, background .13s;
}
.game-card:hover { border-color: var(--gold-dim); background: var(--panel-2); }
.game-card.is-yours { border-color: var(--gold); background: linear-gradient(180deg, rgba(224,169,74,.11), transparent); }
.game-card__main { flex: 1; min-width: 0; }
.game-card__name { font-weight: 620; }
.game-card__meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.game-card__badge {
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 5px 10px; border-radius: 20px; background: var(--gold); color: #23180a; flex: none;
}
.game-card__badge.is-done { background: var(--raised); color: var(--ink-dim); }
.seats { display: flex; gap: 4px; flex: none; }
.seat-dot { width: 13px; height: 13px; border-radius: 50%; border: 1px solid rgba(0,0,0,.45); }

.notice {
  background: rgba(224, 169, 74, .10);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid; gap: 6px;
}
.notice h4 { margin: 0; font-size: 14.5px; font-weight: 650; color: var(--gold); }
.notice p { font-size: 13px; color: var(--ink-dim); line-height: 1.5; }
.notice code {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px;
  background: rgba(0,0,0,.28); padding: 1px 6px; border-radius: 4px;
}
.warn { color: #e8b06a; }

.admin { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; }
.user-list { display: grid; gap: 8px; }
.user-row { display: flex; align-items: center; gap: 10px; background: var(--panel-2); border-radius: var(--radius-sm); padding: 9px 12px; flex-wrap: wrap; }
.user-row__name { font-weight: 580; display: flex; align-items: center; gap: 7px; }
.tag--bot { background: var(--raised); color: var(--ink-dim); }
.tag {
  font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 20px; background: var(--gold); color: #23180a;
}
/* One tidy line with an ellipsis: the full link is behind "Copy link", and
   letting it wrap made every row a different height. */
.user-row__link {
  font-size: 12px; color: var(--muted);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  flex: 1 1 12rem; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------------------------------------------------------------- game */
.game {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 1fr var(--side-w);
  grid-template-rows: 1fr var(--dock-h);
  grid-template-areas: "board side" "dock dock";
}

.board-wrap {
  grid-area: board; position: relative; min-width: 0; min-height: 0;
  background: radial-gradient(120% 110% at 50% 38%, var(--sea) 0%, var(--sea-deep) 62%, #0c1a24 100%);
  /* Dragging to pan would otherwise sweep-select every number and harbour
     label, leaving the board covered in blue highlight. */
  user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.board-host { position: absolute; inset: 0; touch-action: none; }
.board-host svg { width: 100%; height: 100%; display: block; }

.board-tools { position: absolute; right: 12px; bottom: 12px; display: grid; gap: 6px; }

.banner {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  background: rgba(18,26,36,.9); backdrop-filter: blur(8px);
  border: 1px solid var(--gold-dim); color: var(--ink);
  padding: 9px 15px; border-radius: 22px; box-shadow: var(--shadow);
  font-weight: 560; font-size: 14px; max-width: calc(100% - 24px);
  z-index: 5;
}
.banner.is-waiting { border-color: var(--line); color: var(--ink-dim); font-weight: 500; }

.dice-tray {
  position: absolute; left: 12px; top: 12px;
  display: flex; align-items: center; gap: 8px;
  background: rgba(18,26,36,.86); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 7px 12px 7px 8px; box-shadow: var(--shadow);
  user-select: none;
}
.dice-tray__dice { display: flex; align-items: center; gap: 7px; }
.dice-tray img { width: 38px; height: 38px; }
.dice-tray #dice-total {
  font-weight: 700; font-size: 19px; font-variant-numeric: tabular-nums;
  min-width: 1.3em; text-align: center;
}
.dice-tray.is-seven #dice-total { color: var(--bad); }
.dice-tray__roll { padding: 10px 16px; }

/* Tumbling while the roll is in flight... */
@keyframes tumble {
  0%   { transform: rotate(0deg)    scale(1);    }
  25%  { transform: rotate(160deg)  scale(1.14); }
  50%  { transform: rotate(300deg)  scale(.94);  }
  75%  { transform: rotate(470deg)  scale(1.12); }
  100% { transform: rotate(720deg)  scale(1);    }
}
.dice-tray.is-rolling img { animation: tumble .55s linear infinite; }
.dice-tray.is-rolling img:nth-child(2) { animation-duration: .47s; animation-direction: reverse; }
.dice-tray.is-rolling #dice-total { opacity: .25; }

/* ...then a short overshoot as they land. */
@keyframes settle {
  0%   { transform: scale(1.4) rotate(-22deg); }
  55%  { transform: scale(.9)  rotate(7deg);   }
  80%  { transform: scale(1.05) rotate(-2deg); }
  100% { transform: none; }
}
.dice-tray.is-new img { animation: settle .45s cubic-bezier(.2, 1.3, .4, 1) both; }
.dice-tray.is-new img:nth-child(2) { animation-delay: .08s; }
@keyframes pop { from { opacity: 0; transform: scale(.6); } }
.dice-tray.is-new #dice-total { animation: pop .3s .22s ease-out both; }

/* ---------------------------------------------------------------- side */
.side {
  grid-area: side; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--line);
}
.players { user-select: none; padding: 10px; display: grid; gap: 7px; border-bottom: 1px solid var(--line); }

.pcard {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  background: var(--panel-2); border: 1px solid transparent;
  border-radius: var(--radius-sm); padding: 8px 10px;
}
.pcard.is-turn { border-color: var(--gold); background: linear-gradient(180deg, rgba(224,169,74,.14), rgba(224,169,74,.03)); }
.pcard.is-you .pcard__name::after { content: " (you)"; color: var(--muted); font-weight: 500; }
.pcard__pip { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(0,0,0,.5); }
.pcard__name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.pcard__meta { font-size: 12px; color: var(--muted); display: flex; gap: 9px; margin-top: 2px; flex-wrap: wrap; }
.pcard__vp { font-weight: 720; font-size: 18px; font-variant-numeric: tabular-nums; }
/* Longest Road and Largest Army are two points each - worth actually seeing.
 * These used to be 17px thumbnails and people missed them entirely. */
.pcard__awards { display: flex; gap: 4px; }
.pcard__awards img {
  width: 30px; height: 37px; border-radius: 3px;
  box-shadow: 0 0 0 1.5px var(--gold), 0 2px 8px rgba(0,0,0,.5);
}
.pcard.is-you .pcard__awards img { animation: award-in .5s cubic-bezier(.2,1.5,.4,1) both; }
@keyframes award-in {
  0%   { transform: scale(.3) rotate(-12deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .pcard.is-you .pcard__awards img { animation: none; }
}
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); flex: none; }

.side__tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tab { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 9px 4px; color: var(--muted); cursor: pointer; font-weight: 560; font-size: 13.5px; }
.tab.is-active { color: var(--ink); border-bottom-color: var(--gold); }
.side__panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side__panel > form { padding: 8px; border-top: 1px solid var(--line); }

.log { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.log__row { display: flex; gap: 7px; align-items: baseline; line-height: 1.45; }
.log__pip { width: 8px; height: 8px; border-radius: 2px; flex: none; transform: translateY(1px); border: 1px solid rgba(0,0,0,.4); }
.log__text { color: var(--ink-dim); }
.log__row.is-turn  { margin-top: 6px; padding-top: 7px; border-top: 1px solid var(--line-soft); }
.log__row.is-turn  .log__text { color: var(--ink); font-weight: 600; }
.log__row.is-roll  .log__text { color: var(--ink); }
.log__row.is-win   .log__text { color: var(--gold); font-weight: 700; }
.log__row.is-chat  .log__text { color: var(--ink); }
.log__row.is-chat  .log__text b { color: var(--gold); font-weight: 620; }
.log__row.is-award .log__text { color: var(--gold); }

.bank { padding: 12px; display: grid; gap: 9px; }
.bank__row { display: flex; align-items: center; gap: 10px; }
.bank__bar { flex: 1; height: 7px; border-radius: 4px; background: var(--raised); overflow: hidden; }
.bank__fill { height: 100%; border-radius: 4px; }
.bank__n { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; min-width: 3.4rem; text-align: right; }

/* ---------------------------------------------------------------- dock */
.dock {
  grid-area: dock; min-height: 0;
  display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center;
  padding: 10px 14px;
  background: var(--panel); border-top: 1px solid var(--line);
}
.dock__hand { user-select: none; display: flex; align-items: center; gap: 18px; min-width: 0; overflow-x: auto; padding-bottom: 2px; }
.hand, .devhand { display: flex; gap: 7px; align-items: flex-end; }
.devhand { padding-left: 18px; border-left: 1px solid var(--line); }

/* Longest Road / Largest Army, sat with your cards where you will see them. */
.awards { display: flex; gap: 8px; }
.awards:not(:empty) { padding-left: 18px; border-left: 1px solid var(--line); }
.award img {
  display: block; height: 74px; border-radius: 4px;
  box-shadow: 0 0 0 2px var(--gold), 0 3px 12px rgba(0, 0, 0, .55);
}

.react-btn {
  margin-left: auto; flex: none; cursor: pointer;
  width: 42px; height: 42px; border-radius: 50%;
  font-size: 21px; line-height: 1;
  background: var(--panel-2); border: 1px solid var(--line); color: inherit;
  transition: transform .12s ease, border-color .12s ease;
}
.react-btn:hover { transform: scale(1.08); border-color: var(--gold); }
.react-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.react-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.react-cell {
  aspect-ratio: 1; cursor: pointer; font-size: 25px; line-height: 1;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  color: inherit; transition: transform .12s ease, border-color .12s ease;
}
.react-cell:hover { transform: scale(1.12); border-color: var(--gold); }
.react-cell.is-picked { border-color: var(--gold); background: rgba(224, 169, 74, .16); }
.react-cell:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.pcard__reaction { font-size: 17px; line-height: 1; animation: react-pop .35s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes react-pop { from { transform: scale(.2) rotate(-15deg); opacity: 0; } }

@media (max-width: 640px) {
  .react-grid { grid-template-columns: repeat(4, 1fr); }
  .award img { height: 56px; }
  .react-btn { width: 38px; height: 38px; font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  .react-btn, .react-cell { transition: none; }
  .pcard__reaction { animation: none; }
}

.rescard {
  position: relative; width: 62px; flex: none;
  border-radius: 6px; overflow: hidden;
  border: 1px solid rgba(0,0,0,.45);
  box-shadow: 0 3px 9px rgba(0,0,0,.35);
  background: var(--panel-2);
  transition: transform .12s;
}
.rescard img { width: 100%; height: auto; }
.rescard.is-zero { opacity: .26; filter: grayscale(.75); }
.rescard__n {
  position: absolute; right: 3px; bottom: 3px;
  background: rgba(12,18,26,.9); color: #fff;
  border-radius: 12px; min-width: 21px; height: 21px;
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700;
  padding: 0 5px;
}
.devcard {
  width: 58px; flex: none; border-radius: 6px; overflow: hidden; cursor: pointer;
  border: 1px solid rgba(0,0,0,.45); box-shadow: 0 3px 9px rgba(0,0,0,.35);
  transition: transform .12s, box-shadow .12s; background: none; padding: 0;
}
.devcard:hover:not(:disabled) { transform: translateY(-5px); box-shadow: 0 8px 16px rgba(0,0,0,.45); }
.devcard:disabled { cursor: default; opacity: .55; }
.devcard.is-vp { cursor: default; }

.dock__actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; max-width: 62%; }
.dock__actions .btn { position: relative; }
.cost {
  display: flex; gap: 2px; justify-content: center; margin-top: 3px;
}
.cost i { width: 7px; height: 7px; border-radius: 2px; display: block; }

.empty-hand { color: var(--muted); font-size: 13px; padding: 8px 2px; }

/* ---------------------------------------------------------------- board pieces */
.hex-clickable { cursor: pointer; }

/* A build target is a group: a transparent finger-sized hit area wrapping the
   smaller visible marker, so tapping works on a phone. */
.spot-hit { cursor: pointer; }
.spot-hit > .spot, .spot-hit > .spot-road { pointer-events: none; }
.spot {
  fill: var(--gold); fill-opacity: .9;
  stroke: #23180a; stroke-width: .04;
  animation: pulse 1.7s ease-in-out infinite;
}
.spot-hit:hover > .spot { fill: #fff; }
@keyframes pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
.spot-road { stroke: var(--gold); stroke-opacity: .9; stroke-width: .17; stroke-linecap: round; animation: pulse 1.7s ease-in-out infinite; }
.spot-hit:hover > .spot-road { stroke: #fff; stroke-opacity: 1; }

/* On a touchscreen the marker itself is the aiming point, so make it bigger.
   The invisible hit circle stays at 0.46 units - half the spacing between two
   intersections - because during setup adjacent spots are both legal and any
   larger would make them overlap. Pinch to zoom for finer work. */
@media (pointer: coarse) {
  .spot { r: 0.25; }
  .spot-road { stroke-width: 0.22; }
}
.spot-hex { fill: var(--gold); fill-opacity: .001; stroke: var(--gold); stroke-width: .07; cursor: pointer; animation: pulse 1.7s ease-in-out infinite; }
.spot-hex:hover { fill-opacity: .3; }

.tok-circle { fill: #f0e4c8; stroke: rgba(0,0,0,.4); stroke-width: .02; }
.tok-text { font: 700 .40px var(--font); text-anchor: middle; fill: #2b2318; }
.tok-text.is-red { fill: #b3271c; }
.tok-pips { fill: #2b2318; }
.tok-pips.is-red { fill: #b3271c; }
.tok-blocked { opacity: .35; }

.port-badge { fill: rgba(12, 26, 36, .82); stroke: rgba(240,228,200,.5); stroke-width: .025; }
.port-text  { font: 700 .26px var(--font); text-anchor: middle; fill: #f0e4c8; }
.port-line  { stroke: rgba(240,228,200,.42); stroke-width: .05; stroke-linecap: round; }

.road-piece { stroke-linecap: round; stroke-width: .19; }
.road-piece__edge { stroke: rgba(0,0,0,.55); stroke-width: .27; stroke-linecap: round; }
.piece-stroke { stroke: rgba(0,0,0,.6); stroke-width: .035; stroke-linejoin: round; }

.robber-shadow { fill: rgba(0,0,0,.4); }

/* ---------------------------------------------------------------- celebrating */
.party {
  position: fixed; inset: 0; z-index: 95; pointer-events: none;
  display: grid; place-items: center; overflow: hidden;
}
.party.is-going { animation: party-out .5s ease-in both; }
@keyframes party-out { to { opacity: 0; } }

/* The board underneath is busy, so darken it behind the words - otherwise the
 * subtitle lands on top of a button and neither is readable. */
.party::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse 60% 42% at 50% 50%, rgba(6,12,20,.82), rgba(6,12,20,0) 70%);
}
.party__words {
  position: relative; text-align: center; padding: 0 16px;
  animation: party-in .5s cubic-bezier(.2,1.5,.4,1) both;
}
@keyframes party-in {
  0%   { opacity: 0; transform: scale(.35) rotate(-8deg); }
  65%  { opacity: 1; transform: scale(1.1) rotate(2.5deg); }
  100% { opacity: 1; transform: scale(1) rotate(-1deg); }
}
.party__shout {
  font-weight: 800; letter-spacing: -.02em; line-height: 1;
  font-size: clamp(26px, 6vw, 58px); color: var(--gold);
  text-shadow: 0 3px 0 rgba(0,0,0,.6), 0 0 38px rgba(224,169,74,.5);
}
.party__shout--punch {
  font-size: clamp(38px, 9vw, 88px); color: #ff6f61; text-transform: uppercase;
  text-shadow: 0 4px 0 rgba(0,0,0,.6), 0 0 44px rgba(255,111,97,.55);
  animation: punch .35s .16s cubic-bezier(.2,1.8,.4,1) both;
}
@keyframes punch { from { transform: scale(.5) rotate(6deg); opacity: 0; } }
.party__sub {
  margin-top: 12px; font-size: clamp(13px, 2.4vw, 18px); font-weight: 600;
  color: var(--ink); text-transform: uppercase; letter-spacing: .16em;
  text-shadow: 0 2px 6px rgba(0,0,0,.8);
}
[data-tier="huge"] .party__shout--punch { font-size: clamp(46px, 12vw, 128px); }

.party__confetti { position: absolute; inset: 0; }
.confetto {
  position: absolute; top: -6vh; display: block; border-radius: 2px;
  animation-name: fall; animation-timing-function: linear; animation-fill-mode: both;
}
@keyframes fall {
  0%   { opacity: 1; transform: translate(0, 0) rotate(0deg); }
  100% { opacity: 0; transform: translate(var(--drift), 108vh) rotate(var(--spin)); }
}

@media (prefers-reduced-motion: reduce) {
  .party__confetti { display: none; }
}

/* ---------------------------------------------------------------- the yelling */
.yell {
  position: fixed; left: 50%; top: 38%; transform: translate(-50%, -50%);
  z-index: 90; pointer-events: none; text-align: center;
  max-width: min(46rem, calc(100% - 32px));
  font-size: clamp(28px, 6.5vw, 62px); font-weight: 800; line-height: 1.05;
  letter-spacing: -.02em; text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 3px 0 rgba(0,0,0,.55), 0 0 34px rgba(224,169,74,.45);
  animation: yell-in .42s cubic-bezier(.2, 1.5, .4, 1) both;
}
.yell.is-scold {
  color: #ffb3ab; text-transform: none; font-size: clamp(21px, 4vw, 38px);
  text-shadow: 0 3px 0 rgba(0,0,0,.55), 0 0 30px rgba(210,86,75,.45);
}
.yell.is-going { animation: yell-out .38s ease-in both; }
@keyframes yell-in {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.4) rotate(-9deg); }
  60%  { opacity: 1; transform: translate(-50%, -50%) scale(1.12) rotate(3deg); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-1.5deg); }
}
@keyframes yell-out {
  to { opacity: 0; transform: translate(-50%, -50%) scale(1.5) rotate(4deg); }
}

/* ---------------------------------------------------------------- toasts + modal */
.toasts { position: fixed; left: 50%; bottom: calc(var(--dock-h) + 16px); transform: translateX(-50%);
  display: grid; gap: 8px; z-index: 60; pointer-events: none; width: min(30rem, calc(100% - 24px)); }
.toast {
  background: var(--raised); border: 1px solid var(--line); color: var(--ink);
  border-radius: var(--radius-sm); padding: 11px 15px; box-shadow: var(--shadow);
  font-size: 14px; animation: rise .2s ease-out;
}
.toast.is-bad  { border-color: rgba(210,86,75,.6); background: #40222133; backdrop-filter: blur(8px); }
.toast.is-good { border-color: rgba(74,169,108,.5); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.modal-back {
  position: fixed; inset: 0; background: rgba(6, 12, 18, .7); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 18px; z-index: 80;
  animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); width: min(34rem, 100%); max-height: 88vh; overflow: auto;
  padding: 20px; display: grid; gap: 14px;
}
.modal h3 { font-size: 17px; }
.modal__actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.picker__cell { display: grid; gap: 5px; justify-items: center; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 4px; }
.picker__cell.is-selected { border-color: var(--gold); background: rgba(224,169,74,.14); }
.picker__cell img { width: 42px; border-radius: 4px; }
.picker__cell .name { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 24px; height: 24px; border-radius: 5px; border: 1px solid var(--line);
  background: var(--raised); cursor: pointer; display: grid; place-items: center; line-height: 1; }
.stepper button:disabled { opacity: .3; cursor: not-allowed; }
.stepper span { min-width: 1.4rem; text-align: center; font-variant-numeric: tabular-nums; font-weight: 650; }

.invite { display: grid; gap: 8px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.invite h4 { margin: 0; font-size: 14px; font-weight: 640; }
.invite code { font-size: 12px; color: var(--gold); font-family: ui-monospace, Menlo, Consolas, monospace;
  word-break: break-all; }

.avatar-grid {
  display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px;
  max-height: 40vh; overflow-y: auto;
}
.avatar-cell {
  aspect-ratio: 1; font-size: 21px; line-height: 1;
  display: grid; place-items: center; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 0;
}
.avatar-cell:hover { background: var(--raised); }
.avatar-cell.is-selected { border-color: var(--gold); background: rgba(224,169,74,.18); }

/* A player's emoji, shown wherever their name appears. */
.avatar { font-size: 17px; line-height: 1; flex: none; }
.avatar--lg { font-size: 24px; }
.avatar--sm { font-size: 13px; }
.seat-dot { position: relative; }

.costs-table { display: grid; gap: 10px; }
.costs-row { display: flex; align-items: center; gap: 12px; background: var(--panel-2);
  border-radius: var(--radius-sm); padding: 10px 12px; }
.costs-row__what { font-weight: 600; flex: 1; }
.costs-row__cost { display: flex; gap: 5px; }
.costs-row__cost img { width: 26px; border-radius: 3px; }

.trade-offer { background: var(--panel-2); border: 1px solid var(--gold-dim); border-radius: var(--radius-sm); padding: 12px; display: grid; gap: 10px; }
.trade-side { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.trade-side img { width: 34px; border-radius: 3px; }
.trade-arrow { color: var(--muted); }

/* ---------------------------------------------------------------- sign in */
.signin { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.signin__card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 30px; width: min(28rem, 100%); display: grid; gap: 14px; box-shadow: var(--shadow); }
.signin__logo { width: 74%; margin: 0 auto 4px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1080px) { :root { --side-w: 290px; } }

@media (max-width: 860px) {
  :root { --dock-h: auto; }
  /* Flex, not grid: a fixed-height grid squeezes the auto rows and the action
     buttons spill over the panel below. A column lets each block take the
     height it needs and the page scroll. */
  .game {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }
  /* Explicit order: the DOM has the side panel before the dock, but on a phone
     your own hand and buttons belong directly under the board. */
  .board-wrap { flex: none; order: 1; height: 52vh; min-height: 300px; }
  .dock       { flex: none; order: 2; }
  .side       { flex: none; order: 3; border-left: 0; border-top: 1px solid var(--line); }
  /* A definite height here is what makes the log scroll inside itself instead
     of stretching to fit every entry. */
  .side__panel { flex: none; height: 40vh; min-height: 200px; }
  .dock { grid-template-columns: 1fr; gap: 10px; }
  .dock__actions { max-width: none; justify-content: stretch; }
  .dock__actions .btn { flex: 1 1 8rem; min-height: 46px; }
  .toasts { bottom: 16px; }
  .picker { grid-template-columns: repeat(3, 1fr); }
  .side__panel > form { padding: 10px 8px; }

  /* The dice sit top-left, so keep the status message out of their way, and
     let it span the width so it stays one line instead of a wrapped block. */
  .banner {
    top: auto; bottom: 8px; left: 8px; right: 8px;
    transform: none; max-width: none; justify-content: center;
    font-size: 13.5px; padding: 9px 12px; border-radius: 12px;
  }
  .dice-tray { padding: 5px 10px 5px 6px; }
  .dice-tray img { width: 28px; height: 28px; }

  /* Comfortable thumb targets. */
  .icon-btn { width: 44px; height: 44px; font-size: 19px; }
  /* Sit above the full-width status bar rather than under it. */
  .board-tools { right: 8px; bottom: 66px; }
  .tab { padding: 13px 4px; }
}

@media (max-width: 620px) {
  /* Give the game name and status a full row of their own instead of
     squeezing them between the logo and the buttons. */
  .topbar { flex-wrap: wrap; gap: 10px 12px; padding: 8px 12px; }
  .topbar__title { order: 3; flex: 1 0 100%; }
  .topbar__title h1 { font-size: 15px; }
  .topbar__right { margin-left: auto; }
  .topbar__right .btn { padding: 9px 12px; font-size: 13.5px; min-height: 40px; }
  .topbar__home img { height: 26px; }

  /* Stack the two hands instead of side-scrolling them off the edge. */
  .dock__hand { flex-wrap: wrap; gap: 10px; overflow-x: visible; }
  .hand, .devhand { gap: 6px; flex: 1 0 100%; overflow-x: auto; padding-bottom: 2px; }
  .devhand {
    padding-left: 0; border-left: 0;
    border-top: 1px solid var(--line); padding-top: 9px;
  }
  .rescard { width: 52px; }
  .devcard { width: 48px; }
  .empty-hand { white-space: nowrap; font-size: 12px; padding: 2px; }
  .pcard { grid-template-columns: auto 1fr auto; }
  /* No room for a 60-character URL on a phone - "Copy link" covers it. */
  .user-row__link { display: none; }
  .user-row { gap: 8px; }
  .user-row .btn { flex: 1 1 auto; }

  /* Nothing tappable should be smaller than a fingertip. */
  .btn { min-height: 42px; }
  .btn--small { min-height: 40px; padding: 8px 14px; }
  .stepper button { width: 36px; height: 36px; font-size: 17px; }
  .stepper span { min-width: 1.8rem; }
  .picker__cell { padding: 10px 6px; }
}

@media (max-width: 620px) {
  .invite { display: grid; gap: 8px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.invite h4 { margin: 0; font-size: 14px; font-weight: 640; }
.invite code { font-size: 12px; color: var(--gold); font-family: ui-monospace, Menlo, Consolas, monospace;
  word-break: break-all; }

.avatar-grid { grid-template-columns: repeat(8, 1fr); }
  .avatar-cell { font-size: 22px; }
}

@media (max-width: 400px) {
  .rescard { width: 46px; }
  .devcard { width: 44px; }
  .picker { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
