/* Ultimatum Game — game-specific styles (prefix ug-) */

.ug-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.board:has(.ug-head) { --ug-coin: clamp(22px, 4.6vw, 40px); --ug-gap: clamp(4px, 1vw, 8px); }

.ug-ico { display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- header ---------- */
.ug-head { display: grid; grid-template-columns: 1fr minmax(0, 1.5fr) 1fr; align-items: center; gap: 12px; }
.ug-sc { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.ug-sc.jev { align-items: flex-end; }
.ug-sc > div { display: flex; align-items: center; gap: 10px; }
.ug-sc small, .ug-round small { font-size: 11px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.ug-sc b { font-family: var(--font-display); font-weight: 600; font-size: clamp(36px, 6vw, 52px); letter-spacing: -.03em; font-variant-numeric: lining-nums tabular-nums; }
.ug-sc.jev b { color: var(--accent); }
.ug-sc-coin { display: inline-flex; width: clamp(20px, 3vw, 26px); filter: drop-shadow(0 2px 3px rgba(80, 55, 10, .25)); }
.ug-sc-coin svg { width: 100%; height: auto; display: block; }
.ug-mid-head { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.ug-round { display: flex; align-items: baseline; gap: 6px; }
.ug-round b { font-family: var(--font-display); font-size: 22px; font-weight: 600; font-variant-numeric: lining-nums; }
.ug-round span { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.ug-roles { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; width: 100%; max-width: 260px; }
.ug-role {
  display: grid; place-items: center; height: 22px; border-radius: 6px;
  font: 600 10px var(--mono); color: var(--muted);
  background: var(--surface-2); border: 1px solid transparent;
  transition: border-color .3s var(--ease), background .3s var(--ease);
}
.ug-role.jev { color: color-mix(in srgb, var(--accent) 80%, var(--text)); }
.ug-role.ok { background: color-mix(in srgb, var(--good) 13%, var(--surface)); }
.ug-role.no { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.ug-role.now { border-color: var(--text); color: var(--text); background: var(--surface); box-shadow: 0 2px 8px -3px rgba(0, 0, 0, .25); }

/* ---------- stage ---------- */
.ug-stage { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.ug-prompt { margin: 0; text-align: center; font-family: var(--font-display); font-size: clamp(18px, 2.6vw, 22px); font-weight: 600; line-height: 1.3; }
.ug-prompt.wait { color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.ug-dots { display: inline-flex; gap: 4px; }
.ug-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: ug-dot 1s infinite; }
.ug-dots i:nth-child(2) { animation-delay: .15s; }
.ug-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ug-dot { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

.ug-verdict { display: inline-flex; align-items: center; gap: 10px; margin: 0; text-align: left; font-family: var(--font-display); font-size: clamp(17px, 2.4vw, 21px); font-weight: 600; line-height: 1.3; animation: ug-rise .45s var(--ease) both; }
.ug-verdict > span { flex: none; display: inline-flex; width: 28px; height: 28px; }
.ug-verdict .ug-ico { width: 100%; height: 100%; }
.ug-verdict.ok { color: color-mix(in srgb, var(--good) 85%, var(--text)); }
.ug-verdict.no { color: color-mix(in srgb, var(--bad) 85%, var(--text)); }

/* ---------- the table ---------- */
.ug-table {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(48px, 9vw, 84px) minmax(0, 1fr);
  align-items: stretch;
  gap: clamp(6px, 1.4vw, 14px);
  width: 100%;
  max-width: 680px;
}
.ug-tray { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ug-tray-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; padding: 0 4px; min-height: 42px; }
.ug-tray.jev .ug-tray-head { flex-direction: row-reverse; }
.ug-who { display: flex; flex-direction: column; font-weight: 700; font-size: 14px; line-height: 1.2; }
.ug-tray.jev .ug-who { align-items: flex-end; color: color-mix(in srgb, var(--accent) 85%, var(--text)); }
.ug-who em { font-style: normal; font-size: 10.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ug-count { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.05; }
.ug-tray.jev .ug-count { align-items: flex-start; }
.ug-count small { font-size: 11px; color: var(--muted); }
.ug-count b { font-family: var(--font-display); font-size: clamp(24px, 3.6vw, 32px); font-weight: 600; font-variant-numeric: lining-nums tabular-nums; }
.ug-count b.burned { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 2px; }

.ug-dish {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, var(--ug-coin));
  grid-auto-rows: var(--ug-coin);
  align-content: center;
  justify-content: center;
  gap: var(--ug-gap);
  min-height: calc(2 * var(--ug-coin) + var(--ug-gap) + 2 * clamp(12px, 2vw, 18px));
  padding: clamp(12px, 2vw, 18px) clamp(6px, 1.4vw, 14px);
  border-radius: calc(var(--radius) + 2px);
  background:
    var(--noise),
    radial-gradient(120% 100% at 50% 0%, color-mix(in srgb, var(--rail-1) 88%, #fff) 0%, var(--rail-1) 45%, var(--rail-2) 100%);
  background-blend-mode: soft-light, normal;
  box-shadow:
    inset 0 2px 10px rgba(0, 0, 0, .55),
    inset 0 0 0 1px rgba(236, 217, 166, .16),
    0 0 0 3px color-mix(in srgb, var(--gold) 26%, transparent),
    0 12px 24px -16px rgba(0, 0, 0, .5);
  transition: box-shadow .5s var(--ease), filter .5s var(--ease);
}
.ug-tray.jev .ug-dish { direction: rtl; }
.is-burned .ug-dish { filter: saturate(.3) brightness(.85); }
.ug-coin {
  display: block;
  width: var(--ug-coin);
  height: var(--ug-coin);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .45));
}
.ug-coin svg { display: block; width: 100%; height: 100%; }
button.ug-coin { cursor: pointer; transition: filter .2s var(--ease), translate .2s var(--ease); }
button.ug-coin:hover { translate: 0 -3px; filter: drop-shadow(0 6px 5px rgba(0, 0, 0, .5)) brightness(1.06); }
button.ug-coin:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }
.ug-coin.burned { filter: grayscale(1) brightness(.75) drop-shadow(0 2px 2px rgba(0, 0, 0, .4)); opacity: .55; }
.ug-gain {
  position: absolute; bottom: -11px; left: 50%; translate: -50% 0; direction: ltr;
  padding: 2px 10px; border-radius: 999px;
  font: 600 13px var(--mono); color: #3d2c07;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  box-shadow: 0 6px 14px -6px rgba(80, 55, 10, .6);
  animation: ug-float .8s var(--ease) both .45s;
}
@keyframes ug-float { from { opacity: 0; transform: translateY(10px) scale(.8); } to { opacity: 1; transform: none; } }

.ug-mid { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; padding-bottom: 6px; min-width: 0; }
.ug-pot { position: relative; width: var(--ug-coin); height: calc(var(--ug-coin) + 9 * 4px); }
.ug-pot:empty { display: none; }
.ug-pot .ug-coin { position: absolute; left: 0; bottom: calc(var(--i) * 4px); }
.is-pot .ug-mid { justify-content: center; }
.ug-pot-lab { font-size: 10.5px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.ug-flow { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-bottom: auto; margin-top: auto; color: var(--muted); }
.ug-flow b { font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--text); order: -1; }
.ug-flow.to-left .ug-arrow { transform: scaleX(-1); }
.ug-arrow { display: block; width: clamp(30px, 5vw, 44px); height: auto; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ph-thinking .ug-pot .ug-coin { animation: ug-bob 1.2s ease-in-out infinite; animation-delay: calc(var(--i) * 60ms); }
@keyframes ug-bob { 50% { translate: 0 -3px; } }

/* ---------- slider ---------- */
.ug-slider { display: flex; align-items: flex-start; gap: 14px; width: 100%; max-width: 520px; }
.ug-step {
  flex: none; display: grid; place-items: center; width: 36px; height: 36px; margin-top: -4px; padding: 0;
  border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
  box-shadow: var(--shadow); transition: transform .15s var(--ease), border-color .2s;
}
.ug-step svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.ug-step:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.ug-step:disabled { opacity: .35; cursor: default; }
.ug-range-wrap { flex: 1; min-width: 0; }
.ug-range {
  --thumb: 26px;
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; height: var(--thumb); margin: 0; background: transparent; cursor: pointer;
}
.ug-range:focus-visible { outline: none; }
.ug-range::-webkit-slider-runnable-track {
  height: 6px; border-radius: 99px;
  background: linear-gradient(to right, var(--accent) var(--p), color-mix(in srgb, var(--gold) 45%, var(--surface-2)) var(--p));
}
.ug-range::-moz-range-track { height: 6px; border-radius: 99px; background: color-mix(in srgb, var(--gold) 45%, var(--surface-2)); }
.ug-range::-moz-range-progress { height: 6px; border-radius: 99px; background: var(--accent); }
.ug-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: var(--thumb); height: var(--thumb); margin-top: calc(3px - var(--thumb) / 2);
  border-radius: 50%; border: 2px solid var(--accent);
  background: radial-gradient(circle at 35% 30%, #fff, var(--surface) 60%);
  box-shadow: 0 4px 10px -3px rgba(0, 0, 0, .35);
  transition: transform .15s var(--ease);
}
.ug-range::-moz-range-thumb {
  width: var(--thumb); height: var(--thumb); border-radius: 50%; border: 2px solid var(--accent);
  background: var(--surface); box-shadow: 0 4px 10px -3px rgba(0, 0, 0, .35);
}
.ug-range:active::-webkit-slider-thumb { transform: scale(1.12); }
.ug-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 28%, transparent); }
.ug-ticks { display: flex; justify-content: space-between; padding: 4px calc(13px - 8px) 0; }
.ug-ticks span { width: 16px; text-align: center; font: 500 10px var(--mono); color: var(--muted); transition: color .2s; }
.ug-ticks span.on { color: var(--text); font-weight: 700; }

.ug-note { margin: -6px 0 0; text-align: center; font-size: 11.5px; color: var(--muted); }

/* ---------- result ---------- */
.ug-result { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; animation: ug-rise .5s var(--ease) both; }
.ug-result h2 { font-family: var(--font-display); font-size: clamp(30px, 5vw, 42px); font-weight: 600; margin: 0; }
.ug-result.win h2 { color: color-mix(in srgb, var(--good) 85%, var(--text)); }
.ug-result.lose h2 { color: color-mix(in srgb, var(--bad) 85%, var(--text)); }
.ug-final { margin: 0; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.ug-avg { margin: 2px 0 10px; font-size: 13px; }
@keyframes ug-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- history ---------- */
.ug-hist { padding: 16px; border-radius: var(--radius); border: 1px solid var(--border); background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--surface-2) 55%, var(--surface))); }
.ug-cap { margin-bottom: 8px; font-size: 11px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.ug-hist-scroll { overflow-x: auto; }
.ug-htable { width: 100%; border-collapse: collapse; font-size: 13px; }
.ug-htable th { padding: 4px 8px 8px; text-align: left; font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.ug-htable td { padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.ug-htable tr:last-child td { border-bottom: 0; }
.ug-htable tr.fresh td { animation: ug-rise .45s var(--ease) both .3s; }
.ug-htable .num { text-align: right; }
.ug-htable td.num { font-family: var(--mono); font-size: 12.5px; }
.ug-htable td.num.zero { color: var(--muted); }
.ug-htable .rn { font-family: var(--mono); color: var(--muted); width: 1%; }
.ug-htable .split { width: 45%; }
.ug-pdot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--text); vertical-align: 1px; }
.ug-pdot.jev { background: var(--accent); }
.ug-seg { display: inline-grid; grid-template-columns: repeat(10, 1fr); gap: 2px; width: min(170px, 60%); vertical-align: middle; margin-right: 10px; }
.ug-seg i { height: 10px; border-radius: 3px; }
.ug-seg i.y { background: linear-gradient(180deg, var(--gold-2), var(--gold)); }
.ug-seg i.j { background: color-mix(in srgb, var(--accent) 75%, var(--surface)); }
.ug-htable tr.no .ug-seg i { background: repeating-linear-gradient(135deg, var(--surface-2) 0 3px, color-mix(in srgb, var(--muted) 30%, transparent) 3px 5px); }
.ug-seg-n { font: 500 11.5px var(--mono); color: var(--muted); }
.ug-res { display: inline-flex; width: 16px; height: 16px; vertical-align: -3px; margin-right: 6px; }
.ug-res .ug-ico { width: 100%; height: 100%; stroke-width: 2; }
.ug-res.ok { color: var(--good); }
.ug-res.no { color: var(--bad); }
.ug-res-t { font-size: 12.5px; }

/* ---------- responsive ---------- */
@media (max-width: 560px) {
  .board:has(.ug-head) { --ug-coin: clamp(18px, 5.6vw, 28px); --ug-gap: 4px; }
  .ug-tray-head { flex-direction: column; align-items: flex-start; gap: 2px; min-height: 0; }
  .ug-tray.jev .ug-tray-head { flex-direction: column; align-items: flex-end; }
  .ug-count, .ug-tray.jev .ug-count { flex-direction: row; align-items: baseline; gap: 6px; }
  .ug-tray.jev .ug-count { flex-direction: row-reverse; }
  .ug-slider { gap: 8px; }
  .ug-res-t, .ug-seg-n { display: none; }
  .ug-htable td, .ug-htable th { padding-left: 5px; padding-right: 5px; }
  .ug-seg { width: 100%; margin: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ug-stage *, .ug-verdict, .ug-result, .ug-htable tr, .ug-gain { animation: none !important; transition: none !important; }
}
