/* ==========================================================================
   Tier Rasa — styles
   ========================================================================== */

:root {
  --bg: #fbf5ec;
  --surface: #ffffff;
  --surface-2: #f5ecdf;
  --ink: #2a1c12;
  --ink-2: #6e5948;
  --line: #eadcc8;
  --accent: #c4302b;
  --accent-hover: #a82722;
  --accent-ink: #ffffff;
  --accent-soft: #fbe4df;
  --gold: #e3a22c;
  --leaf: #3d7a4f;
  --focus: #2e86ab;
  --shadow-sm: 0 1px 2px rgba(70, 40, 15, .06);
  --shadow: 0 1px 2px rgba(70, 40, 15, .06), 0 8px 24px rgba(70, 40, 15, .08);
  --shadow-lg: 0 18px 40px rgba(70, 40, 15, .22);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161009;
    --surface: #221911;
    --surface-2: #2c2118;
    --ink: #f6ece1;
    --ink-2: #bfa996;
    --line: #3b2e23;
    --accent: #e5534b;
    --accent-hover: #f06a62;
    --accent-soft: #3d1f1b;
    --focus: #5bb4d8;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
    --shadow-lg: 0 18px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 100% -10%, color-mix(in srgb, var(--gold) 14%, transparent), transparent 60%),
    radial-gradient(900px 400px at -10% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.6rem, 1.1rem + 2vw, 2.4rem); line-height: 1.15; letter-spacing: -.02em; font-weight: 800; }
h2 { font-size: 1.1rem; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 1rem; font-weight: 700; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

kbd {
  font: 600 .78em var(--font);
  padding: .05em .4em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
}

.muted { color: var(--ink-2); }
.tiny { font-size: .8rem; }
.accent { color: var(--accent); }
.eyebrow {
  font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent);
  margin-bottom: .25rem;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem clamp(1rem, 3vw, 2rem);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: .5rem;
  background: none; border: 0; padding: 0; font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em;
}
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent-soft); font-size: 1.1rem;
}
.nav { display: flex; gap: .25rem; background: var(--surface-2); padding: .25rem; border-radius: 999px; }
.nav-btn {
  border: 0; background: transparent; padding: .4rem .9rem; border-radius: 999px; font-weight: 600; font-size: .9rem;
  color: var(--ink-2);
}
.nav-btn:hover:not(:disabled) { color: var(--ink); }
.nav-btn[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.nav-btn:disabled { opacity: .4; }

/* ---------- Layout ---------- */
.app {
  max-width: 1320px; margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem);
  padding-bottom: 4rem;
  display: flex; flex-direction: column; gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.card-head { margin-bottom: 1rem; display: flex; flex-direction: column; gap: .2rem; }
.card-head h2 { display: flex; align-items: center; gap: .5rem; }
.card-head .muted { font-size: .85rem; }
.count {
  font-size: .75rem; font-weight: 700; padding: .1rem .55rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.empty { color: var(--ink-2); padding: .75rem 0; font-size: .9rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid transparent; border-radius: 999px;
  padding: .6rem 1.1rem; font-weight: 700; font-size: .92rem; line-height: 1.2;
  transition: background .15s, transform .1s, box-shadow .15s, border-color .15s;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.secondary { background: var(--surface-2); border-color: var(--line); }
.btn.secondary:hover:not(:disabled) { border-color: var(--ink-2); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn.sm { padding: .35rem .75rem; font-size: .82rem; }
.btn.lg { padding: .85rem 1.6rem; font-size: 1.02rem; }
.btn.armed, .icon-btn.armed, .link-btn.armed { background: #b3261e; color: #fff; border-color: #b3261e; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(179, 38, 30, .2); } }

.icon-btn {
  flex: none; min-width: 32px; height: 32px; padding: 0 .5rem; border-radius: 999px;
  border: 1px solid transparent; background: transparent; color: var(--ink-2); font-size: .85rem; font-weight: 700;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.danger:hover { color: #b3261e; background: color-mix(in srgb, #b3261e 10%, transparent); }
.icon-btn.sm { min-width: 26px; height: 26px; font-size: .75rem; }

.link-btn {
  background: none; border: 1px solid transparent; padding: .3rem .7rem; border-radius: 999px;
  color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; font-size: .85rem;
}
.link-btn:hover { color: #b3261e; }

/* ---------- Inputs ---------- */
input[type="text"], input[type="search"], select {
  border: 1px solid var(--line); background: var(--bg); border-radius: var(--radius-sm);
  padding: .55rem .8rem; min-width: 0;
}
input[type="text"]:focus, input[type="search"]:focus, select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }

.name-input {
  flex: 1; font-weight: 600; background: transparent !important; border-color: transparent !important;
  padding: .4rem .6rem !important;
}
.name-input:hover { border-color: var(--line) !important; }
.name-input:focus { background: var(--bg) !important; border-color: var(--focus) !important; }
.name-input.sm { font-size: .9rem; padding: .25rem .45rem !important; }

/* ---------- Avatars ---------- */
.avatar {
  --size: 36px;
  flex: none; display: inline-grid; place-items: center;
  width: var(--size); height: var(--size); border-radius: 50%;
  background: var(--c); color: #fff; font-weight: 800; font-size: calc(var(--size) * .42);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15);
  text-shadow: 0 1px 1px rgba(0, 0, 0, .25);
}
.avatar.xs { --size: 22px; }
.avatar.sm { --size: 28px; }
.avatar.lg { --size: 56px; }
.avatar.xl { --size: 96px; }
.avatar-btn { border: 0; background: none; padding: 0; border-radius: 50%; display: inline-flex; }
.avatar-btn:hover:not(:disabled) .avatar { transform: scale(1.08); }
.avatar-btn:disabled { cursor: default; }
.avatar { transition: transform .15s; }

/* ==========================================================================
   Setup
   ========================================================================== */
.hero {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.5rem; align-items: center;
  padding: .5rem 0 .25rem;
}
.lede { margin-top: .6rem; color: var(--ink-2); max-width: 60ch; font-size: 1.02rem; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.steps li {
  display: flex; align-items: center; gap: .6rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .6rem .75rem; font-weight: 600; font-size: .88rem;
}
.steps li span {
  flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: .85rem;
}

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .8rem 1rem; border-radius: var(--radius);
  background: color-mix(in srgb, var(--gold) 18%, var(--surface)); border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  font-weight: 600;
}

.setup-grid { display: grid; grid-template-columns: minmax(280px, 360px) 1fr; gap: 1.25rem; align-items: start; }

.player-list { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.player-row {
  display: flex; align-items: center; gap: .5rem; padding: .35rem .4rem .35rem .45rem;
  border-radius: 12px; background: var(--surface-2);
}

.add-player { display: flex; gap: .5rem; }
.add-player input { flex: 1; }
.add-player.compact { margin-top: .75rem; }
.add-player.compact input { padding: .4rem .65rem; font-size: .88rem; }
.add-player.compact .btn { padding: .4rem .75rem; font-size: .82rem; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.toolbar .search { flex: 1 1 160px; }
.quick { display: flex; gap: .35rem; flex-wrap: wrap; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: .2rem; gap: .15rem; flex-wrap: wrap; }
.seg button {
  border: 0; background: transparent; border-radius: 999px; padding: .38rem .85rem; font-weight: 600; font-size: .86rem; color: var(--ink-2);
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.item-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .5rem;
  max-height: 460px; overflow-y: auto; padding: .15rem .35rem .15rem .15rem; margin: 0 -.35rem 0 -.15rem;
}
.item-tile { position: relative; }
.tile-main {
  width: 100%; display: flex; align-items: center; gap: .6rem; text-align: left;
  padding: .55rem .65rem; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface);
  transition: border-color .15s, background .15s;
}
.tile-main:hover { border-color: var(--ink-2); }
.item-tile.on .tile-main { border-color: var(--accent); background: var(--accent-soft); }
.tile-emoji { font-size: 1.6rem; line-height: 1; flex: none; width: 1.9rem; text-align: center; }
.tile-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.tile-name { font-weight: 700; font-size: .9rem; }
.tile-desc { font-size: .74rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-check {
  flex: none; width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--line);
  display: grid; place-items: center; font-size: .75rem; font-weight: 800;
}
.item-tile.on .tile-check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tile-remove {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); font-size: .65rem; font-weight: 800; color: var(--ink-2);
  display: grid; place-items: center; box-shadow: var(--shadow-sm);
}
.tile-remove:hover { color: #fff; background: #b3261e; border-color: #b3261e; }

.add-item { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--line); }
.add-item input[name="name"] { flex: 1 1 180px; }
.add-item .emoji-input { width: 3.6rem; text-align: center; }

.start-card { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; }
.settings { display: flex; gap: 1.5rem; flex-wrap: wrap; flex: 1 1 420px; }
.toggle { display: flex; gap: .7rem; align-items: flex-start; cursor: pointer; flex: 1 1 200px; max-width: 360px; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle b { display: block; font-size: .92rem; }
.toggle small { display: block; color: var(--ink-2); font-size: .8rem; line-height: 1.35; }
.switch {
  flex: none; position: relative; width: 40px; height: 24px; border-radius: 999px; background: var(--line); margin-top: 2px;
  transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s;
}
.toggle input:checked + .switch { background: var(--leaf); }
.toggle input:checked + .switch::after { transform: translateX(16px); }
.toggle input:focus-visible + .switch { outline: 3px solid var(--focus); outline-offset: 2px; }
.start { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; justify-content: flex-end; }

.foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: .85rem; }

/* ==========================================================================
   Play
   ========================================================================== */
.play-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.turn-banner { display: flex; align-items: center; gap: .9rem; }
.turn-banner .pname, .handoff .pname { color: var(--c); filter: saturate(1.1); }
.progress { display: flex; align-items: center; gap: .75rem; font-size: .85rem; color: var(--ink-2); font-weight: 600; min-width: min(320px, 100%); }
.progress-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.progress-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--accent)); border-radius: inherit; transition: width .4s ease; }

.play-grid {
  display: grid; grid-template-columns: 280px minmax(0, 1fr) 250px; gap: 1.25rem; align-items: start;
}
.stage, .turns { position: sticky; top: 80px; }
.stage-label { font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); margin-bottom: .6rem; }
.stage-label.last { margin: 1rem 0 0; color: var(--accent); }

.pool {
  min-height: 250px; border-radius: var(--radius); border: 2px dashed var(--line); padding: 1rem;
  display: grid; place-items: center; transition: border-color .15s, background .15s;
}
.pool.drop-hover { border-color: var(--focus); background: color-mix(in srgb, var(--focus) 8%, transparent); }
.pool-placed { text-align: center; display: flex; flex-direction: column; align-items: center; gap: .45rem; }
.pool-placed .muted { font-size: .82rem; }

.food-card {
  width: 100%; display: flex; flex-direction: column; align-items: center; text-align: center; gap: .35rem;
  padding: 1.2rem 1rem 1rem; border-radius: var(--radius);
  background: linear-gradient(160deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  cursor: grab; user-select: none; touch-action: none;
  animation: bob 2.6s ease-in-out infinite;
}
.food-card:hover { box-shadow: var(--shadow-lg); }
@keyframes bob { 50% { transform: translateY(-4px); } }
.food-type {
  font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  padding: .15rem .55rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}
.food-emoji { font-size: 4.2rem; line-height: 1.1; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .15)); }
.food-emoji.sm { font-size: 2.6rem; }
.food-name { font-size: 1.35rem; font-weight: 800; letter-spacing: -.01em; }
.food-desc { font-size: .84rem; color: var(--ink-2); }
.food-grip { margin-top: .35rem; font-size: .75rem; font-weight: 700; color: var(--ink-2); opacity: .8; }

.stage-actions { display: flex; gap: .5rem; margin-top: 1rem; }
.stage-actions .btn.primary { flex: 1; }
.hint { margin-top: .85rem; font-size: .8rem; color: var(--ink-2); line-height: 1.6; }
.up-next { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.up-next ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.up-next li { display: flex; gap: .5rem; align-items: center; font-size: .88rem; color: var(--ink-2); font-weight: 600; }

.board-wrap { display: flex; flex-direction: column; gap: .75rem; min-width: 0; }
.board-tabs { display: flex; gap: .35rem; overflow-x: auto; padding-bottom: .15rem; }
.board-tab {
  flex: none; display: inline-flex; align-items: center; gap: .4rem;
  border: 1px solid var(--line); background: var(--surface); padding: .3rem .75rem .3rem .35rem; border-radius: 999px;
  font-size: .85rem; font-weight: 600; color: var(--ink-2);
}
.board-tab[aria-selected="true"] { color: var(--ink); border-color: var(--c); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 30%, transparent); }
.board-tab em { font-style: normal; font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }
.viewing-note {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  padding: .6rem .85rem; border-radius: var(--radius-sm); background: var(--surface-2); font-size: .88rem;
}

/* ---------- Tier board ---------- */
.board {
  display: flex; flex-direction: column; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
}
.tier-row {
  display: flex; min-height: 64px; border-bottom: 1px solid var(--line);
  transition: background .12s;
}
.tier-row:last-child { border-bottom: 0; }
.tier-label {
  flex: none; width: 104px; display: flex; flex-direction: column; justify-content: center; align-items: center;
  background: var(--tier); color: var(--tier-ink); padding: .4rem;
}
.tier-num { font-size: 1.6rem; font-weight: 800; line-height: 1; }
.tier-name { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .85; margin-top: .2rem; }
.tier-items { flex: 1; display: flex; flex-wrap: wrap; align-content: center; align-items: center; gap: .4rem; padding: .5rem .6rem; min-width: 0; }

.board.interactive .tier-row { cursor: pointer; }
.board.interactive .tier-row:hover { background: color-mix(in srgb, var(--tier) 9%, transparent); }
.tier-row.drop-hover { background: color-mix(in srgb, var(--tier) 22%, transparent) !important; box-shadow: inset 4px 0 0 var(--tier), inset 0 0 0 2px var(--tier); }
.tier-empty { font-size: .78rem; color: var(--ink-2); opacity: 0; transition: opacity .15s; }
.tier-row:hover .tier-empty, .tier-row.drop-hover .tier-empty, .is-dragging .tier-empty { opacity: .7; }
.tier-none { color: var(--ink-2); opacity: .4; }

.chip {
  display: inline-flex; align-items: center; gap: .35rem; max-width: 100%;
  padding: .3rem .65rem .3rem .4rem; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: .85rem; font-weight: 600;
  user-select: none;
}
.chip-emoji { font-size: 1.15rem; line-height: 1; }
.chip-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-score { font-size: .72rem; font-weight: 800; padding: .05rem .4rem; border-radius: 999px; background: var(--surface); color: var(--ink-2); }
.chip.pending {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 40%, transparent);
  cursor: grab; touch-action: none; animation: pop .25s ease-out;
}
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

.drag-source { opacity: .35; animation: none !important; }
.drag-ghost {
  position: fixed; top: 0; left: 0; z-index: 1000; pointer-events: none; margin: 0;
  box-shadow: var(--shadow-lg) !important; animation: none !important; opacity: .95; cursor: grabbing;
}
.is-dragging, .is-dragging * { cursor: grabbing !important; user-select: none; }

.board.compact .tier-row { min-height: 40px; }
.board.compact .tier-label { width: 44px; }
.board.compact .tier-num { font-size: 1.05rem; }
.board.compact .tier-items { padding: .3rem .45rem; gap: .3rem; }
.board.compact .chip { font-size: .76rem; padding: .18rem .5rem .18rem .3rem; }
.board.compact .chip-emoji { font-size: .95rem; }

/* ---------- Turn list ---------- */
.turn-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.turn-row { display: flex; align-items: center; gap: .35rem; padding: .3rem .35rem; border-radius: 10px; border: 1.5px solid transparent; }
.turn-row.now { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.turn-row.done { opacity: .7; }
.turn-status { flex: none; width: 18px; text-align: center; font-size: .8rem; font-weight: 800; color: var(--leaf); }
.turn-row.now .turn-status { color: var(--accent); }
.turns .muted.tiny { margin-top: .5rem; }

/* ---------- Handoff ---------- */
.handoff { display: grid; place-items: center; min-height: 60vh; }
.handoff-card {
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: .7rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow-lg);
  padding: 2.5rem clamp(1.25rem, 5vw, 3.5rem); max-width: 560px;
  border-top: 6px solid var(--c);
}
.handoff-card .btn { margin-top: .75rem; white-space: normal; }

/* ==========================================================================
   Results
   ========================================================================== */
.results-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; align-items: end; }
.podium-card {
  position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: .2rem;
  padding: 1.25rem 1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow); border-bottom: 6px solid var(--tier);
}
.podium-card.p1 { order: 2; padding-top: 2rem; padding-bottom: 2rem; }
.podium-card.p2 { order: 1; }
.podium-card.p3 { order: 3; }
.medal { position: absolute; top: -14px; font-size: 1.8rem; }
.podium-emoji { font-size: 3rem; line-height: 1.15; }
.podium-card.p1 .podium-emoji { font-size: 4rem; }
.podium-name { font-weight: 800; font-size: 1.05rem; }
.podium-score { font-weight: 800; font-size: 1.4rem; color: var(--ink); }
.podium-card.p1 .podium-score { font-size: 1.9rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem; }
.stat { display: flex; gap: .8rem; align-items: center; padding: .9rem 1rem; }
.stat-icon { font-size: 1.8rem; flex: none; }
.stat-label { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2); }
.stat-value { font-weight: 800; }
.stat-sub { font-size: .8rem; color: var(--ink-2); }

.results-seg { align-self: flex-start; }

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.rank-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.rank-table th, .rank-table td { padding: .6rem .75rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.rank-table tbody tr:last-child td { border-bottom: 0; }
.rank-table tbody tr:hover { background: var(--surface-2); }
.rank-table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); background: var(--surface-2); font-weight: 700; }
.rank-table .num { text-align: center; width: 1%; }
.rank-table .rank { font-weight: 800; }
.rank-table .pcol { text-align: center; }
.rank-table th.pcol { text-transform: none; letter-spacing: 0; }
.rank-table th.pcol span:last-child { display: block; max-width: 90px; margin: .2rem auto 0; overflow: hidden; text-overflow: ellipsis; }
.item-cell { font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.item-cell span { font-size: 1.25rem; }
.avg { display: flex; align-items: center; gap: .6rem; min-width: 150px; }
.avg b { width: 2.2rem; }
.avg-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.avg-bar i { display: block; height: 100%; border-radius: inherit; }

.score-pill {
  display: inline-grid; place-items: center; min-width: 30px; height: 26px; padding: 0 .4rem; border-radius: 8px;
  background: var(--tier); color: var(--tier-ink); font-weight: 800; font-size: .85rem;
}

.boards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.mini-board { padding: 1rem; }
.mini-head { display: flex; align-items: center; gap: .55rem; margin-bottom: .75rem; }
.mini-board .board { box-shadow: none; }

.empty-state { text-align: center; display: flex; flex-direction: column; align-items: center; gap: .75rem; padding: 2.5rem; }
.empty-state .add-player { width: min(420px, 100%); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; z-index: 2000;
  transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: .65rem 1.1rem; border-radius: 999px;
  font-weight: 600; font-size: .9rem; box-shadow: var(--shadow-lg);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1100px) {
  .play-grid { grid-template-columns: 260px minmax(0, 1fr); }
  .turns { grid-column: 1 / -1; position: static; }
  .turn-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

@media (max-width: 860px) {
  .hero, .setup-grid { grid-template-columns: 1fr; }
  .play-grid { grid-template-columns: 1fr; }
  .stage { position: static; }
  .pool { min-height: 0; }
  .food-card { animation: none; }
  .tier-label { width: 74px; }
  .tier-name { font-size: .58rem; }
}

@media (max-width: 560px) {
  .brand-name { display: none; }
  .steps { grid-template-columns: 1fr; }
  .podium { grid-template-columns: 1fr; }
  .podium-card.p1, .podium-card.p2, .podium-card.p3 { order: 0; }
  .start, .start .btn { width: 100%; }
  .tier-row { min-height: 54px; }
  .tier-label { width: 56px; }
  .tier-name { display: none; }
}

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