/* Liar's Dice. One world: a dark ship's table lit by a lantern, over a rolling sea. Rows of cups up top, the bid on a
   plaque, your own cup on a round wooden table at the bottom. The sea and the table take their colors from the
   player's settings (--sea, --table); each player's dice bring their own (--die, --pip). */
:root {
  color-scheme: dark;
  --sea: #1d4b45;
  --wood: #20150e;
  --wood-hi: #33231a;
  --ink: #eadfc6;
  --ink-dim: #b3a78c;
  --brass: #cfa64b;
  --blood: #a5342b;
  --die: #e8dfc8;
  --pip: #1b1612;
  --table: #5a3a22;
  --display: 'IM Fell English SC', 'Iowan Old Style', Georgia, serif;
  --body: 'Alegreya Sans', 'Trebuchet MS', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--sea); color: var(--ink); font: 500 16px/1.35 var(--body); overflow-x: hidden; -webkit-tap-highlight-color: transparent; }
#backdrop { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
#app { position: relative; z-index: 1; min-height: 100%; max-width: 480px; margin: 0 auto; }
.screen { min-height: 100vh; min-height: 100dvh; padding: 10px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.thud { animation: thud .22s; }
@keyframes thud { 30% { transform: translateY(5px); } 60% { transform: translateY(-2px); } }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
[hidden] { display: none !important; }

header { display: flex; align-items: center; gap: 8px; }
h1, h2, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
.spacer { flex: 1; }
.plate { background: var(--wood); border: 1px solid rgba(234,223,198,.22); border-radius: 8px; padding: 9px 14px; min-height: 42px; font-family: var(--display); letter-spacing: .04em; box-shadow: 0 2px 0 rgba(0,0,0,.45); }
.plate:active { transform: translateY(1px); }
.plate:disabled { opacity: .4; cursor: default; }
.plate.go { background: var(--brass); color: #1b1408; border-color: transparent; }
.plate.liar { background: var(--blood); border-color: transparent; }

.panel { background: color-mix(in srgb, var(--wood) 88%, transparent); border: 1px solid rgba(234,223,198,.14); border-radius: 12px; }

/* Opponents */
#opps { padding: 4px 10px; display: flex; flex-direction: column; }
.opp { display: flex; align-items: center; gap: 10px; padding: 6px 0; min-height: 56px; border-bottom: 1px solid rgba(234,223,198,.08); }
.opp:last-child { border-bottom: 0; }
.opp.out { opacity: .38; }
.opp.turn .who b { color: var(--brass); }
.opp.turn .who b::after { content: ' \25C6'; font-size: .7em; }
.who { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.who b { font: 400 1.05rem/1.1 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--ink-dim); font-size: .82rem; }
.opp .dice { margin-left: auto; flex: none; }
.said { color: var(--ink-dim); font-style: italic; font-size: .92rem; text-align: right; }

/* Cups */
.cup { display: block; flex: none; background: none; border: 0; padding: 0; transform-origin: 15% 100%; transition: transform .28s cubic-bezier(.3,1.4,.5,1); }
.cup svg { display: block; width: 100%; height: auto; overflow: visible; }
.cup.sm { width: 42px; position: relative; z-index: 1; }
/* Each cup's shadow belongs to the table, so it stays put when the cup lifts. */
.spot { position: relative; flex: none; width: 42px; }
.spot::after, .seat::after { content: ''; position: absolute; border-radius: 50%; background: rgba(0,0,0,.38); }
.spot::after { left: 2%; right: 2%; bottom: -1px; height: 5px; }
.seat::after { left: 50%; width: 130px; margin-left: -65px; bottom: -3px; height: 14px; }
.cup.lg { width: 140px; position: absolute; left: 50%; bottom: 0; margin-left: -70px; z-index: 2; }
.cup.shake { animation: shake .42s linear infinite; transition: none; }
.cup.slam { animation: slam .3s cubic-bezier(.7,0,1,.5) both; transition: none; }
.cup.sm.peek, .cup.sm.lift { transform: translateY(-15%) rotate(-20deg); }
.cup.lg.peek { transform: translateY(-34px) rotate(-9deg); }
.cup.lg.lift { transform: translateY(-40px) rotate(-13deg); }
@keyframes shake {
  0% { transform: translate(0, -22%) rotate(0); }
  20% { transform: translate(-9%, -32%) rotate(-11deg); }
  45% { transform: translate(8%, -16%) rotate(9deg); }
  70% { transform: translate(-6%, -28%) rotate(-7deg); }
  100% { transform: translate(0, -22%) rotate(0); }
}
@keyframes slam {
  0% { transform: translateY(-34%) rotate(-6deg); }
  80% { transform: translateY(0) scale(1.07, .92); }
  100% { transform: translateY(0); }
}

/* Dice */
.dice { display: flex; gap: 4px; align-items: center; }
.d { width: 20px; height: 20px; display: block; flex: none; transition: opacity .2s; }
.d rect { fill: var(--die); }
.d circle, .d .bone { fill: var(--pip); }
.d .bone { stroke: var(--die); stroke-width: .7; }
.d .hole { fill: var(--die); }
.d .x { stroke: var(--pip); stroke-width: 2.3; stroke-linecap: round; }
.d .tooth { stroke: var(--die); stroke-width: .6; }
.d.miss { opacity: .3; }
.d.hit rect { stroke: var(--brass); stroke-width: 2.5; }
.d.hit { animation: pop .3s; }
@keyframes pop { 40% { transform: scale(1.3); } }

/* Plaque */
#plaque { text-align: center; padding: 10px 12px 12px; position: relative; }
/* (shared) */
.eyebrow { color: var(--ink-dim); font-size: .82rem; letter-spacing: .12em; text-transform: uppercase; }
.bid { margin: 2px 0 0; font: 400 clamp(1.7rem, 8vw, 2.3rem)/1.05 var(--display); display: flex; justify-content: center; align-items: center; gap: 10px; text-wrap: balance; }
.bid .d { width: 30px; height: 30px; }
.tag { display: inline-block; margin-bottom: 4px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--brass); border: 1px solid currentColor; border-radius: 99px; padding: 1px 8px; }
#status { margin: 6px 0 0; min-height: 2.7em; color: var(--ink); text-wrap: balance; }

/* Your seat */
/* The table: a round wooden top seen from your seat, under your cup and your controls. */
#deck { position: relative; margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-bottom: 14px; }
#deck::before { content: ''; position: absolute; z-index: -1; left: -11%; right: -11%; top: 112px; bottom: 0; border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 22%, rgba(255,214,150,.2), transparent 62%),
    repeating-linear-gradient(0deg, transparent 0 37px, rgba(0,0,0,.3) 37px 39px),
    repeating-linear-gradient(0deg, rgba(0,0,0,.07) 0 2px, transparent 2px 6px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.025) 0 3px, transparent 3px 11px),
    var(--table);
  box-shadow: inset 0 0 0 5px rgba(0,0,0,.3), inset 0 3px 0 5px rgba(255,220,170,.1), inset 0 0 46px rgba(0,0,0,.5),
    0 11px 0 color-mix(in srgb, var(--table) 50%, #000), 0 24px 28px rgba(0,0,0,.55); }
#me { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.seat { position: relative; width: 180px; height: 154px; margin-top: 38px; }
.seat .dice { position: absolute; left: 0; right: 0; bottom: 4px; justify-content: center; z-index: 1; }
.me-name { margin: 0; font: 400 1.05rem/1 var(--display); }
.me-name small { font: 500 .82rem var(--body); color: var(--ink-dim); margin-left: 6px; }
.me-name.turn { color: var(--brass); }

/* Controls */
#controls { display: flex; flex-direction: column; gap: 8px; min-height: 150px; justify-content: flex-end; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper output { flex: 1; text-align: center; font: 400 1.5rem/1 var(--display); }
.stepper .plate { width: 52px; font-size: 1.3rem; padding: 0; }
.faces { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.face { background: var(--wood); border: 1px solid rgba(234,223,198,.2); border-radius: 8px; padding: 6px 0; display: grid; place-items: center; min-height: 44px; }
.face .d { width: 28px; height: 28px; }
.face[aria-pressed="true"] { border-color: var(--brass); box-shadow: 0 0 0 2px var(--brass) inset; }
.face:disabled { opacity: .28; cursor: default; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.row > .liar { flex: 0 0 34%; }
.wait { text-align: center; color: var(--ink); font-style: italic; margin: 0; }

/* Sheets */
.sheet { position: fixed; inset: 0; z-index: 5; background: rgba(8,6,4,.72); display: grid; place-items: end center; padding: 16px; overflow-y: auto; }
.card { width: 100%; max-width: 448px; background: var(--wood-hi); border: 1px solid rgba(234,223,198,.2); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card h2 { font: 400 1.4rem/1 var(--display); margin: 0; }
.card h3 { font: 400 1.05rem/1 var(--display); margin: 6px 0 0; color: var(--brass); }
.card p, .card ul { margin: 0; }
.card ul { padding-left: 1.1em; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field input[type="text"] { background: var(--wood); border: 1px solid rgba(234,223,198,.25); border-radius: 8px; padding: 8px 10px; width: 60%; }
.field input[type="color"] { width: 52px; height: 36px; border: 1px solid rgba(234,223,198,.25); border-radius: 8px; background: var(--wood); padding: 2px; }
.field input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--brass); }
.tabs { display: flex; gap: 6px; }
.tab { flex: 1; background: var(--wood); border: 1px solid rgba(234,223,198,.2); border-radius: 8px; padding: 6px; min-height: 40px; display: grid; place-items: center; gap: 2px; font-size: .85rem; }
.tab .cup { width: 40px; }
.tabs.wrap { display: grid; grid-template-columns: repeat(3, 1fr); }
.tab[aria-pressed="true"] { border-color: var(--brass); box-shadow: 0 0 0 2px var(--brass) inset; }
.note { color: var(--ink-dim); font-size: .88rem; }

@media (prefers-reduced-motion: reduce) {
  .cup, .cup.shake, .cup.slam, .thud, .d.hit { animation: none; transition: none; }
}

/* Menu and lobby */
.logo { font: 400 clamp(2.6rem, 14vw, 3.6rem)/1 var(--display); text-align: center; letter-spacing: .03em; text-shadow: 0 3px 0 rgba(0,0,0,.55); padding: 18px 0 6px; }
#menu > .tabs .tab { min-height: 46px; font: 400 1.1rem var(--display); letter-spacing: .04em; }
.pad { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.center { align-items: center; text-align: center; }
#preview { display: flex; align-items: flex-end; justify-content: center; gap: 14px; min-height: 96px; }
#preview .cup { width: 84px; }
#name, #code { background: var(--wood); border: 1px solid rgba(234,223,198,.25); border-radius: 8px; padding: 8px 10px; min-height: 42px; }
#name { width: 60%; }
.join-row { display: flex; gap: 8px; }
#code { flex: 1; min-width: 0; text-align: center; text-transform: uppercase; letter-spacing: .3em; font-family: var(--display); font-size: 1.15rem; }
.link { background: none; border: 0; padding: 4px; color: var(--ink-dim); text-decoration: underline; align-self: center; }
.error { color: #ffb4a8; text-align: center; min-height: 1.4em; }
.room-code { font: 400 3.4rem/1 var(--display); letter-spacing: .14em; }
#qr { width: 150px; line-height: 0; background: #fff; border-radius: 8px; padding: 4px; }
#qr svg, #tv-qr svg { display: block; width: 100%; height: auto; }
#qr:empty { display: none; }
.link-text { overflow-wrap: anywhere; }
.roster { display: flex; flex-direction: column; gap: 6px; }
.roster li { display: flex; align-items: center; gap: 10px; font: 400 1.15rem var(--display); }
.roster li.off { opacity: .45; }
.roster small { font: 700 .7rem var(--body); letter-spacing: .1em; color: var(--brass); border: 1px solid currentColor; border-radius: 99px; padding: 0 7px; }
.cup.xs { width: 30px; }
.field input:disabled { opacity: .5; }
#game header { display: flex; align-items: center; gap: 8px; }
#toast { position: fixed; z-index: 6; left: 50%; bottom: 18px; transform: translateX(-50%); max-width: min(92vw, 440px); background: #1b1408; color: var(--ink); border: 1px solid var(--brass); border-radius: 10px; padding: 10px 14px; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.5); }

/* Party view: sized in vh so it fills a TV whatever its resolution. */
body.tv { overflow: hidden; }
body.tv #app { max-width: none; height: 100%; }
#party, #party > div { height: 100%; box-sizing: border-box; }
#tv-lobby { display: grid; grid-template-columns: 1fr 1fr; gap: 3vw; padding: 4vh 4vw; align-items: center; }
.tv-join { display: flex; flex-direction: column; align-items: center; gap: 1.5vh; min-width: 0; }
.tv-join .logo { font-size: 11vh; padding: 0; }
.tv-join .eyebrow { font-size: 2.2vh; color: var(--ink); }
.tv-code { font: 400 15vh/1 var(--display); letter-spacing: .1em; }
#tv-qr { width: 26vh; line-height: 0; background: #fff; border-radius: 1vh; padding: .6vh; }
#tv-qr:empty { display: none; }
.tv-url { font: 500 2.6vh/1.2 var(--body); overflow-wrap: anywhere; text-align: center; }
.tv-players { max-height: 88vh; overflow: hidden; padding: 3vh; gap: 2vh; }
.tv-players .eyebrow { font-size: 2.2vh; }
.tv-players .note { font-size: 2.6vh; }
.roster.big { gap: 1.4vh; }
.roster.big li { font-size: 4.2vh; gap: 1.6vh; }
.roster.big .cup.xs { width: 6vh; }
.roster.big small { font-size: 1.8vh; }
#tv-play { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 2.5vw; padding: 4vh 3vw; align-items: center; }
#tv-opps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3vh 1vw; align-content: center; padding: 5vh 3vw; min-height: 70vh; border-radius: 50% / 46%;
  background: radial-gradient(ellipse at 50% 22%, rgba(255,214,150,.2), transparent 62%), repeating-linear-gradient(0deg, transparent 0 7.6vh, rgba(0,0,0,.3) 7.6vh 8vh), repeating-linear-gradient(0deg, rgba(0,0,0,.07) 0 2px, transparent 2px 6px), var(--table);
  box-shadow: inset 0 0 0 .8vh rgba(0,0,0,.3), inset 0 0 8vh rgba(0,0,0,.5), 0 1.8vh 0 color-mix(in srgb, var(--table) 50%, #000), 0 4vh 5vh rgba(0,0,0,.55); }
body.tv .opp { flex-direction: column; gap: 1vh; border: 0; min-height: 0; padding: 0; text-align: center; }
body.tv .spot, body.tv .cup.sm { width: 13vh; }
body.tv .spot::after { height: 1.4vh; bottom: -.4vh; }
body.tv .who { flex: none; align-items: center; }
body.tv .who b { font-size: 3.4vh; }
body.tv .who small { font-size: 2.2vh; color: var(--ink); }
body.tv .opp .dice { margin: 0; min-height: 4.6vh; justify-content: center; gap: .7vh; font-size: 2.6vh; color: var(--ink); }
body.tv .d { width: 4.2vh; height: 4.2vh; }
#tv-play aside { text-align: center; padding: 4vh 2.5vw; gap: 2vh; }
#tv-play aside .eyebrow { font-size: 2.2vh; }
#tv-plaque { position: relative; }
#tv-plaque .bid { font-size: 7.5vh; flex-wrap: wrap; }
#tv-plaque .bid .d { width: 7.5vh; height: 7.5vh; }
#tv-plaque .tag { font-size: 1.9vh; margin-bottom: 1.5vh; }
#tv-status { font-size: 3.4vh; line-height: 1.3; min-height: 9vh; text-wrap: balance; }
