:root {
  --bg: #0f1b2d; --panel: #18283f; --ink: #f2f5fa; --muted: #9db0c9; --accent: #ffb703;
  --good: #3ddc97; --bad: #ff6b6b; --perf: #4dabf7; --eng: #f783ac; --well: #69db7c; --trust: #ffd43b;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--ink); }
h1, h2, h3 { margin: 0 0 .5rem; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: .8rem 1.2rem; background: var(--accent); color: #1b1b1b; font-weight: 700; }
button:focus-visible, input:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary { background: #2b4263; color: var(--ink); }
button.big { width: 100%; font-size: 1.3rem; padding: 1.1rem; }
input { font: inherit; width: 100%; padding: .9rem; border-radius: 10px; border: 2px solid #2b4263; background: #0c1626; color: var(--ink); margin-bottom: .75rem; }
.panel { background: var(--panel); border-radius: 14px; padding: 1.1rem; margin-bottom: 1rem; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.4em; }
.hidden { display: none !important; }

/* stats */
.stat { margin: .35rem 0; }
.stat .row { display: flex; justify-content: space-between; font-size: .9rem; }
.bar { height: 10px; border-radius: 6px; background: #0c1626; overflow: hidden; }
.bar > span { display: block; height: 100%; transition: width .5s; }
.perf { background: var(--perf); } .eng { background: var(--eng); } .well { background: var(--well); } .trust { background: var(--trust); }

.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: .5rem 0; }
.chip { padding: .2rem .6rem; border-radius: 99px; font-weight: 700; font-size: .9rem; background: #0c1626; }
.chip.up { color: var(--good); } .chip.down { color: var(--bad); }
.note { border-left: 4px solid var(--accent); padding-left: .75rem; margin: .75rem 0; color: #ffe29a; }

/* player page */
.wrap { max-width: 520px; margin: 0 auto; padding: 1rem; }
.opt { display: block; width: 100%; text-align: left; margin-bottom: .6rem; background: #2b4263; color: var(--ink); font-weight: 500; }
.opt:hover:not(:disabled) { background: #36557f; }
.turnbanner { text-align: center; font-weight: 700; padding: .6rem; border-radius: 10px; background: #2b4263; margin-bottom: 1rem; }
.turnbanner.me { background: var(--accent); color: #1b1b1b; }
.dice { font-size: 4rem; text-align: center; }

/* host page */
.host { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(300px, 1fr); gap: 1rem; padding: 1rem; min-height: 100vh; }
.board { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; }
.tile { position: relative; aspect-ratio: 1 / .85; border-radius: 10px; padding: 4px; font-size: clamp(.55rem, .9vw, .8rem); background: #22385a; display: flex; flex-direction: column; justify-content: space-between; }
.tile .n { opacity: .6; font-size: .75em; }
.tile.d { background: #3b3a7a; } .tile.e { background: #1f5c58; } .tile.p { background: #8a5a00; }
.tile.r { background: #6b2f6b; } .tile.s, .tile.f { background: #2f6b2f; }
.tile.active { outline: 3px solid #fff; }
.tokens { display: flex; flex-wrap: wrap; gap: 2px; }
.tok { width: clamp(10px, 1.3vw, 18px); height: clamp(10px, 1.3vw, 18px); border-radius: 50%; border: 2px solid #fff; }
.legend { display: flex; gap: .75rem; flex-wrap: wrap; font-size: .85rem; margin-top: .5rem; color: var(--muted); }
.code { font-size: clamp(3rem, 8vw, 7rem); letter-spacing: .25em; font-weight: 800; color: var(--accent); }
.lb { width: 100%; border-collapse: collapse; }
.lb td { padding: .3rem .4rem; border-bottom: 1px solid #22385a; }
.lb tr.cur td { background: #22385a; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: .4rem; }
.bigcard h2 { font-size: clamp(1.4rem, 2.4vw, 2.2rem); }
.bigcard p { font-size: clamp(1rem, 1.6vw, 1.5rem); }
.lobbygrid { display: flex; flex-wrap: wrap; gap: .5rem; }
.pill { padding: .4rem .8rem; border-radius: 99px; background: #22385a; font-weight: 600; }
.log { font-size: .85rem; color: var(--muted); max-height: 9rem; overflow: auto; }
@media (max-width: 1000px) { .host { grid-template-columns: 1fr; } }

/* mini board on phones */
.board.mini { gap: 3px; }
.tile.mini { aspect-ratio: 1 / 1; padding: 2px; border-radius: 6px; font-size: .6rem; align-items: center; justify-content: space-between; }
.tile.mini .n { font-weight: 700; opacity: .85; }
.tile.mini .tokens { gap: 1px; justify-content: center; }
.tile.mini .tok { width: 8px; height: 8px; border-width: 1px; }
.tok.me { width: 14px !important; height: 14px !important; border: 2px solid #fff; box-shadow: 0 0 0 2px #000; animation: pulse 1.2s infinite; }
.tile.mine { outline: 3px solid #fff; z-index: 1; }
@keyframes pulse { 50% { transform: scale(1.25); } }
@media (prefers-reduced-motion: reduce) { .tok.me { animation: none; } }
.legendline { font-size: .75rem; }
.near { list-style: none; padding: 0; margin: 0 0 .5rem; }
.near li { padding: .15rem 0; }

/* dice */
.diewrap { display: flex; justify-content: center; padding: 1rem 0; perspective: 600px; }
.die { width: 96px; height: 96px; border-radius: 18px; background: #fff; padding: 12px; display: grid;
  grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); box-shadow: 0 6px 0 #c9c9c9, 0 10px 20px rgba(0,0,0,.4); }
.die i { display: block; align-self: center; justify-self: center; width: 18px; height: 18px; border-radius: 50%; }
.die i.pip { background: #1b1b1b; }
.die.tumble { animation: tumble .45s linear infinite; }
.die.land { animation: land .5s ease-out; }
.rolltext { text-align: center; font-size: 1.4rem; font-weight: 700; margin: 0 0 .5rem; }
@keyframes tumble {
  0% { transform: rotate(0) translateY(0); } 25% { transform: rotate(90deg) translateY(-14px); }
  50% { transform: rotate(180deg) translateY(0); } 75% { transform: rotate(270deg) translateY(-14px); }
  100% { transform: rotate(360deg) translateY(0); }
}
@keyframes land { 0% { transform: scale(1.5) rotate(-25deg); } 60% { transform: scale(.92) rotate(6deg); } 100% { transform: scale(1) rotate(0); } }
@media (prefers-reduced-motion: reduce) { .die.tumble, .die.land { animation: none; } }

/* host join panel */
.joinrow { display: flex; gap: 2rem; align-items: center; flex-wrap: wrap; margin: 1rem 0; }
.qr { background: #fff; border-radius: 12px; padding: 8px; width: clamp(180px, 22vw, 300px); height: auto; }
.joinlabel { margin: .2rem 0; color: var(--muted); font-size: 1.1rem; }
.joinurl { margin: .2rem 0; font-size: clamp(1.4rem, 3vw, 2.6rem); font-weight: 800; word-break: break-all; }
