*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.35 Rubik, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
}
body { height: 100%; overflow: hidden; touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#app { height: 100%; padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left); }

h1 { font-size: 26px; font-weight: 700; line-height: 1.15; }
h2 { font-size: 15px; font-weight: 500; color: var(--mute); }
h3 { font-size: 15px; font-weight: 500; color: var(--mute); }
ol, ul { padding: 0; list-style: none; }

button, input { font: inherit; color: inherit; }
:is(.value, .total, .num, .table td, .tile, .lead b, .podium em, .item em) { font-variant-numeric: tabular-nums; }
button { background: none; border: 0; padding: 0; line-height: normal; cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid #2f7de1; outline-offset: 2px; }

input {
  width: 100%;
  height: 52px;
  padding: 0 14px;
  font-size: 17px;
  background: var(--surface);
  border: 1.5px solid var(--mute);
  border-radius: var(--radius);
  user-select: text;
  -webkit-user-select: text;
}

.btn {
  min-height: 52px;
  padding: 8px 18px;
  border-radius: var(--radius);
  background: var(--used);
  font-size: 17px;
  font-weight: 600;
}
.btn.primary { background: var(--go); color: #fff; }
.btn.strong { background: var(--ink); color: var(--bg); }
.btn.danger { background: none; color: var(--danger); box-shadow: inset 0 0 0 2px var(--danger); }
.btn:disabled { opacity: .4; }
.btn:not(:disabled):active, .pad button:active, button.card:active, .seg:not(.track) button:active, .player:active, .round:active, .pill:active, .lead button:active { transform: scale(.97); }
[data-theme='paper'] .btn { box-shadow: inset 0 0 0 1.5px var(--ink); }
[data-theme='paper'] .btn.danger { box-shadow: inset 0 0 0 2px var(--danger); }
[data-theme='paper'] .btn.primary, [data-theme='paper'] .btn.strong { box-shadow: none; }

.error { color: var(--danger); min-height: 22px; font-size: 15px; }
.hint { color: var(--mute); font-size: 15px; }

.center {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
}
.login .logo { display: flex; gap: 10px; }
.login .logo svg:nth-child(1) { color: #2457c5; transform: rotate(-9deg); }
.login .logo svg:nth-child(2) { color: #b3245f; transform: rotate(5deg); }
.login .logo svg:nth-child(3) { color: #1b7457; transform: rotate(-3deg); }
[data-theme='dark'] .login .logo svg { filter: brightness(1.7); }
.login h1 { font-size: 40px; }
.login form { width: 100%; max-width: 340px; display: grid; gap: 8px; text-align: left; }

.page { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: calc(18px + env(safe-area-inset-top)) 16px calc(var(--bar-room) + 16px); }
.page > * { max-width: 620px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; gap: 14px; }
.page h2 { margin-bottom: -7px; }
.top { display: flex; align-items: center; gap: 12px; }
.between { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; min-height: 36px; margin-bottom: -5px; }
.between h2 { margin: 0 0 2px; }

/* ---- the floating menu ---- */
:root { --bar-gap: max(12px, calc(env(safe-area-inset-bottom) - 8px)); --bar-room: calc(64px + var(--bar-gap)); }
.tabbar {
  position: fixed;
  z-index: 5;
  left: 0;
  right: 0;
  bottom: var(--bar-gap);
  width: calc(100% - 28px);
  max-width: 430px;
  height: 64px;
  margin: 0 auto;
  padding: 4px;
  border-radius: 32px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.8);
  backdrop-filter: blur(18px) saturate(1.8);
  box-shadow: var(--glass-shadow), inset 0 0 0 1px var(--glass-edge);
  transition: transform .25s cubic-bezier(.2, .9, .3, 1.2);
}
.tabbar[hidden] { display: none; }
.tabbar.touched { transform: scale(1.02); }
.slots-track { position: relative; height: 100%; display: flex; touch-action: none; cursor: pointer; }
.tabbar button {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 28px;
  color: var(--mute);
  font-size: 11.5px;
  font-weight: 500;
  transition: color .15s;
  pointer-events: none;
}
.tabbar button.on { color: var(--ink); font-weight: 600; }
.tabbar button svg { transition: transform .25s cubic-bezier(.2, .9, .3, 1.4); }
.tabbar button.on svg { transform: scale(1.08); }
.marker { position: absolute; inset: 0 auto 0 0; width: 25%; transition: transform .32s cubic-bezier(.25, 1, .35, 1.15); }
.marker::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 28px;
  background: var(--glass-mark);
  transition: inset .2s cubic-bezier(.2, .9, .3, 1.3), background .2s, box-shadow .2s;
}
/* A lens that swells under the finger. */
.touched .marker::before {
  inset: -7px -5px;
  border-radius: 36px;
  background: color-mix(in srgb, var(--glass-mark), transparent 35%);
  box-shadow: inset 0 0 0 1px var(--glass-edge), inset 0 2px 8px rgb(255 255 255 / .35), 0 4px 14px rgb(0 0 0 / .16);
}
.dragged .marker { transition-duration: .06s; }
[data-theme='paper'] .touched .marker::before { background: var(--glass-mark); box-shadow: none; inset: -2px; }

/* ---- surfaces and controls ---- */
.card { background: var(--surface); border-radius: var(--radius); padding: 13px 14px; }
button.card { width: 100%; text-align: left; }
[data-theme='paper'] .card { box-shadow: inset 0 0 0 1.5px var(--ink); }
.card.now { background: var(--pc); color: #fff; display: grid; gap: 3px; padding: 16px; box-shadow: none; overflow-wrap: anywhere; }
.card.now .who { font-size: 24px; font-weight: 600; line-height: 1.15; }
[data-theme='paper'] .card.now { background: none; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink), inset 0 -6px var(--pc); }
[data-theme='paper'] .card.now .who { font-family: var(--hand); color: var(--pc); }
.ico { flex: none; display: block; }
.rule .ico, .line > .ico { color: var(--mute); }

.tile {
  flex: none;
  min-width: 34px;
  height: 34px;
  padding: 0 5px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--c);
  color: #fff;
  font-style: normal;
  font-weight: 700;
  line-height: normal;
}
.tile.plus { background: none; color: var(--mute); border: 2px dashed var(--mute); padding: 0; }

.seg { display: flex; gap: 9px; }
.seg button { flex: 1; min-height: 62px; padding: 4px 6px; border-radius: var(--radius); background: var(--surface); font-size: 18px; font-weight: 600; }
.seg button.on { background: var(--ink); color: var(--bg); }
[data-theme='paper'] .seg:not(.track) button { box-shadow: inset 0 0 0 1.5px var(--ink); }
.seg.track { gap: 0; padding: 3px; border-radius: 12px; background: var(--used); }
.seg.track button { min-height: 42px; border-radius: 9px; background: none; font-size: 16px; font-weight: 500; }
.seg.track button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgb(10 20 26 / .18); }
.sheet .seg.track { background: var(--key); }
[data-theme='dark'] .seg.track { background: #101a21; }
[data-theme='dark'] .sheet .seg.track { background: #1c2a34; }
[data-theme='dark'] .seg.track button.on { background: var(--key); }
[data-theme='paper'] .seg.track { background: none; box-shadow: inset 0 0 0 1.5px var(--ink); border-radius: 6px; }
[data-theme='paper'] .seg.track button { border-radius: 4px; }
[data-theme='paper'] .seg.track button.on { background: var(--ink); color: var(--bg); box-shadow: none; }

.group { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.sheet .group { background: var(--key); }
[data-theme='paper'] .group { box-shadow: inset 0 0 0 1.5px var(--ink); }
.line { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 9px 14px; text-align: left; font-weight: 500; }
.line + .line { border-top: 1px solid var(--line); }
.sheet .line + .line { border-top-color: color-mix(in srgb, var(--ink) 12%, transparent); }
.line:active { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.line .text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.line small { display: block; margin-top: 1px; font-size: 14px; font-weight: 400; color: var(--mute); }
.line em { font-style: normal; font-weight: 400; font-size: 14px; color: var(--mute); }
.line.off .tile { opacity: .4; }
.line.off .text { color: var(--mute); }
.line[aria-checked='true'] > .ico { color: var(--ink); }
.switch { flex: none; width: 52px; height: 32px; padding: 3px; border-radius: 16px; background: color-mix(in srgb, var(--mute) 45%, transparent); }
.switch::after { content: ''; display: block; width: 26px; height: 26px; border-radius: 13px; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); }
[aria-checked='true'] > .switch { background: var(--go); }
[aria-checked='true'] > .switch::after { margin-left: 20px; animation: flick .16s ease-out; }
[aria-checked='false'] > .switch::after { animation: flick-off .16s ease-out; }
@keyframes flick { from { margin-left: 0; } }
@keyframes flick-off { from { margin-left: 20px; } }

.round { flex: none; width: 44px; height: 44px; border-radius: 22px; display: grid; place-items: center; background: var(--surface); }
.round svg { margin-left: -2px; }
.pill { display: flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 10px 0 14px; border-radius: 18px; background: var(--surface); font-size: 14px; font-weight: 500; position: relative; }
.pill::after { content: ''; position: absolute; inset: -5px 0; }
[data-theme='paper'] :is(.round, .pill) { box-shadow: inset 0 0 0 1.5px var(--ink); }

dialog.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 24px 16px calc(20px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 22px 22px 0 0;
  background: var(--sheet);
  color: var(--ink);
  overflow-y: auto;
}
dialog.sheet::before { content: ''; position: absolute; top: 8px; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: color-mix(in srgb, var(--mute) 45%, transparent); }
dialog.sheet:has(input)::before { display: none; }
dialog.sheet:focus-visible { outline: none; }
dialog.sheet[open] { animation: rise .2s cubic-bezier(.2, .8, .3, 1); }
dialog.sheet::backdrop { background: rgb(10 20 26 / .5); }
dialog.sheet > h2 { font-size: 20px; font-weight: 600; color: var(--ink); margin-bottom: 14px; }
dialog.sheet form, dialog.sheet .rules { display: grid; gap: 10px; }
[data-theme='paper'] dialog.sheet { border-radius: 6px 6px 0 0; border-top: 2px solid var(--ink); }
/* Text fields sit at the top so the phone keyboard never covers them. */
dialog.sheet:has(input) {
  margin: 0 auto auto;
  padding-top: calc(20px + env(safe-area-inset-top));
  border-radius: 0 0 22px 22px;
}
dialog.sheet:has(input)[open] { animation-name: drop; }
@keyframes drop { from { transform: translateY(-40%); opacity: 0; } }
@keyframes rise { from { transform: translateY(40%); opacity: 0; } }
.act { display: flex; gap: 10px; margin-top: 14px; }
.act .btn { flex: 1; padding-inline: 8px; }
.stack { display: grid; gap: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bar-room) + 16px);
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 13px 18px;
  border-radius: 14px;
  background: #17252e;
  color: #fff;
  box-shadow: 0 0 0 1px rgb(255 255 255 / .25);
  z-index: 10;
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.group .line:focus-visible { outline-offset: -3px; border-radius: var(--radius); }
@media (max-width: 350px) { .tabbar { width: calc(100% - 16px); } .tabbar button { font-size: 10.5px; } }

/* A phone lying down: a low menu and wider pages. */
@media (orientation: landscape) and (min-width: 480px) and (max-height: 500px) {
  :root { --bar-gap: max(8px, calc(env(safe-area-inset-bottom) - 10px)); --bar-room: calc(46px + var(--bar-gap)); }
  .tabbar { height: 46px; max-width: 520px; padding: 3px; border-radius: 23px; }
  .tabbar button { flex-direction: row; gap: 7px; border-radius: 20px; font-size: 13.5px; }
  .tabbar button svg { width: 21px; height: 21px; }
  .marker::before { border-radius: 20px; }
  .touched .marker::before { inset: -4px; border-radius: 26px; }
  .page { padding-top: calc(12px + env(safe-area-inset-top)); padding-bottom: calc(var(--bar-room) + 10px); }
  .page > * { max-width: 760px; gap: 11px; }
  .center { gap: 10px; padding: 12px 24px; }
  .login .logo { display: none; }
  .login h1 { font-size: 28px; }
}
