:root {
  --hot: #ff4f9a;
  --rose: #ff8fc7;
  --blush: #ffc2dd;
  --cream: #fff3e6;
  --plum: #3a0d27;
  --ink: #2b0b1e;
  --mint: #9fe8c7;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #ffd8e7; color: var(--ink); font-family: var(--font); -webkit-tap-highlight-color: transparent; }
canvas#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; cursor: pointer; }
kbd { display: inline-block; min-width: 1.5em; padding: 0 .35em; border-radius: 6px; background: var(--plum); color: var(--blush); font: 700 .78em/1.6 ui-monospace, Menlo, monospace; text-align: center; }
[hidden] { display: none !important; }

/* ---- screens */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; gap: 20px; padding: 20px; z-index: 20; }
.menu { justify-content: flex-start; padding-left: max(24px, 5vw); background: linear-gradient(90deg, rgba(255, 216, 231, .92) 0%, rgba(255, 216, 231, .55) 42%, rgba(255, 216, 231, 0) 70%); }
.end, .pause { background: rgba(58, 13, 39, .55); backdrop-filter: blur(4px); }
.menu-card { width: min(420px, 100%); background: rgba(255, 246, 250, .94); border: 2px solid #fff; border-radius: 28px; padding: 26px 26px 20px; box-shadow: 0 18px 50px rgba(58, 13, 39, .22); }
.menu-card.small { width: min(320px, 100%); text-align: center; }
.kicker { margin: 0 0 4px; font: 700 12px/1 ui-monospace, Menlo, monospace; letter-spacing: .18em; text-transform: uppercase; color: var(--hot); }
.logo { margin: 0; font-size: clamp(34px, 6vw, 48px); line-height: .98; letter-spacing: -.03em; color: var(--plum); }
.logo span { color: var(--hot); }
.logo.small { font-size: 34px; margin-bottom: 6px; }
.tagline { margin: 12px 0 14px; font-size: 15px; line-height: 1.45; color: #6b3a55; }
.greeting { margin: 0 0 10px; font-weight: 700; font-size: 16px; }
.greeting:empty { display: none; }
.greeting small { font-weight: 600; opacity: .6; }
.buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { border: 0; border-radius: 999px; padding: 12px 20px; background: #fff; color: var(--plum); font-weight: 800; font-size: 15px; box-shadow: inset 0 0 0 2px var(--blush); transition: transform .12s ease, box-shadow .12s ease; }
.btn:hover { transform: translateY(-1px); box-shadow: inset 0 0 0 2px var(--rose); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--hot); color: #fff; box-shadow: 0 6px 0 #c22a6c; }
.btn.primary:hover { box-shadow: 0 7px 0 #c22a6c; }
.btn.primary:active { box-shadow: 0 3px 0 #c22a6c; }
.btn:focus-visible { outline: 3px solid var(--plum); outline-offset: 2px; }
.note { margin: 10px 0 0; font-size: 13px; color: #8a5872; }
.apron { display: flex; align-items: center; gap: 12px; margin: 16px 0 6px; font-weight: 700; font-size: 14px; }
.swatches { display: flex; gap: 8px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--blush); padding: 0; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--hot); }
.how { margin-top: 10px; font-size: 14px; }
.how summary { cursor: pointer; font-weight: 800; color: var(--plum); }
.how ul { margin: 8px 0 0; padding-left: 18px; line-height: 1.6; color: #6b3a55; }

/* ---- leaderboard */
.board-card { width: min(300px, 100%); background: rgba(58, 13, 39, .9); color: var(--cream); border-radius: 24px; padding: 18px 18px 12px; box-shadow: 0 18px 50px rgba(58, 13, 39, .25); align-self: center; }
.menu .board-card { margin-left: auto; margin-right: max(16px, 3vw); }
.board-card h2 { margin: 0 0 10px; font-size: 16px; letter-spacing: .02em; color: var(--rose); }
.board { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.board li { display: grid; grid-template-columns: 2em 1fr auto auto; gap: 8px; align-items: center; padding: 7px 8px; border-radius: 10px; }
.board li:nth-child(odd) { background: rgba(255, 255, 255, .05); }
.board li.me { background: var(--hot); color: #fff; }
.board .rank { font-weight: 800; color: var(--rose); }
.board li.me .rank { color: #fff; }
.board .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .name i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.board .num { font-weight: 800; font-variant-numeric: tabular-nums; }
.board .sub { font-size: 12px; opacity: .7; font-variant-numeric: tabular-nums; }
.board .empty { display: block; opacity: .7; font-size: 13px; padding: 4px 2px 8px; }

/* ---- end */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.stats div { background: #fff; border-radius: 16px; padding: 10px 4px; text-align: center; box-shadow: inset 0 0 0 2px var(--blush); }
.stats b { display: block; font-size: 22px; color: var(--hot); font-variant-numeric: tabular-nums; }
.stats span { font-size: 11px; font-weight: 700; color: #8a5872; text-transform: uppercase; letter-spacing: .06em; }
.save { min-height: 1.4em; margin: 0 0 14px; font-weight: 700; }
.save .btn { margin-top: 8px; }

/* ---- player card (start.ng) */
.player { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 12px; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; border-radius: 999px; background: var(--plum); color: var(--cream); box-shadow: 0 6px 18px rgba(58, 13, 39, .25); max-width: 60vw; }
.player img { width: 40px; height: 40px; border-radius: 50%; background: var(--blush); object-fit: cover; }
.player img:not([src]), .player img[src=""] { display: none; }
.player b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player span { font-size: 12px; opacity: .7; }

/* ---- HUD */
.hud { position: fixed; top: max(12px, env(safe-area-inset-top)); right: 12px; z-index: 25; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100vw - 24px); }
.hud-pill { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; background: rgba(255, 246, 250, .95); box-shadow: 0 4px 0 rgba(194, 42, 108, .25); font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; }
.hud-icon { color: var(--hot); }
.hearts { color: var(--hot); letter-spacing: 2px; }
.hearts .lost { color: #e9c3d4; }
.combo { background: var(--hot); color: #fff; animation: pop .35s ease; }
.hud-pill.low { background: #ffe1e1; color: #c0263c; animation: pulse 1s ease-in-out infinite; }
.hud-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--plum); color: var(--blush); font-weight: 800; }
@keyframes pulse { 50% { transform: scale(1.06); } }
@keyframes pop { 0% { transform: scale(.6); } 70% { transform: scale(1.12); } 100% { transform: scale(1); } }

.tray { position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 25; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 16px; border-radius: 999px; background: rgba(58, 13, 39, .92); color: var(--cream); box-shadow: 0 10px 26px rgba(58, 13, 39, .3); }
.tray-label { font-weight: 800; font-size: 13px; color: var(--rose); text-transform: uppercase; letter-spacing: .1em; }
.tray-slots { display: flex; gap: 6px; }
.tray-slot { display: flex; align-items: center; gap: 6px; min-width: 44px; height: 38px; padding: 0 10px; border-radius: 999px; border: 2px dashed rgba(255, 194, 221, .35); font-size: 13px; font-weight: 700; }
.tray-slot.full { border: 0; background: #fff; color: var(--plum); }
.tray-slot i { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .12); }
.tray-bin { border: 0; border-radius: 999px; padding: 8px 12px; background: rgba(255, 255, 255, .1); color: var(--cream); font-weight: 700; }

/* ---- labels drawn over the 3D scene */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 10; overflow: hidden; }
.label { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); pointer-events: auto; white-space: nowrap; }
.station { display: flex; align-items: center; gap: 6px; padding: 5px 10px 5px 5px; border: 0; border-radius: 999px; background: rgba(255, 246, 250, .92); color: var(--plum); font-weight: 800; font-size: 12px; box-shadow: 0 3px 0 rgba(194, 42, 108, .25); }
.station i { width: 12px; height: 12px; border-radius: 50%; }
.station:hover { background: #fff; }
.ticket { width: 168px; padding: 8px 10px 9px; border: 0; border-radius: 16px; background: #fff; color: var(--plum); text-align: left; box-shadow: 0 6px 0 rgba(194, 42, 108, .22), 0 10px 24px rgba(58, 13, 39, .15); white-space: normal; transition: transform .12s ease; }
.ticket:hover { transform: translate(-50%, -100%) scale(1.03); }
.ticket .who { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 800; margin-bottom: 5px; }
.ticket .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket ul { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.ticket li { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }
.ticket li i { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.ticket li.done { opacity: .4; text-decoration: line-through; }
.patience { height: 7px; border-radius: 99px; background: #ffe3ef; overflow: hidden; }
.patience b { display: block; height: 100%; width: 100%; border-radius: 99px; background: var(--mint); transform-origin: left; transition: background .3s; }
.patience.mid b { background: #ffd166; }
.patience.low b { background: #ff5b6e; }
.ticket.hurry { animation: shake .4s ease-in-out infinite; }
@keyframes shake { 25% { margin-left: -2px; } 75% { margin-left: 2px; } }
.bubble { max-width: 200px; margin-left: 110px; padding: 7px 11px; border-radius: 4px 14px 14px 14px; background: var(--plum); color: var(--cream); font-size: 13px; font-weight: 700; white-space: normal; pointer-events: none; animation: pop .3s ease; }
.bubble.surprise { background: var(--hot); color: #fff; }
.bubble.angry { background: #c0263c; }
.popup { position: absolute; transform: translate(-50%, -50%); font-weight: 900; font-size: 20px; color: var(--hot); text-shadow: 0 2px 0 #fff, 0 0 12px #fff; pointer-events: none; animation: float 1.1s ease-out forwards; white-space: nowrap; }
.popup.big { font-size: 26px; }
.popup.bad { color: #c0263c; }
@keyframes float { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.7); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.05); } 100% { opacity: 0; transform: translate(-50%, -220%) scale(1); } }
.marker { position: absolute; width: 26px; height: 26px; transform: translate(-50%, -50%); border-radius: 50%; border: 3px solid var(--hot); pointer-events: none; animation: ping .6s ease-out forwards; }
@keyframes ping { from { opacity: 1; transform: translate(-50%, -50%) scale(.4); } to { opacity: 0; transform: translate(-50%, -50%) scale(1.6); } }

.toasts { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); z-index: 26; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { padding: 8px 14px; border-radius: 999px; background: var(--plum); color: var(--cream); font-weight: 700; font-size: 14px; animation: toast 2.2s ease forwards; }
@keyframes toast { 0% { opacity: 0; transform: translateY(8px); } 10%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* ---- phones */
@media (max-width: 760px) {
  .menu { justify-content: flex-end; flex-direction: column; align-items: stretch; padding: 12px; gap: 10px; overflow-y: auto; background: linear-gradient(0deg, rgba(255, 216, 231, .95) 0%, rgba(255, 216, 231, .7) 55%, rgba(255, 216, 231, 0) 80%); }
  .menu .board-card { display: none; }
  .menu-card { padding: 18px; border-radius: 22px; }
  .tagline { font-size: 14px; margin: 8px 0 10px; }
  .end { flex-direction: column; overflow-y: auto; justify-content: flex-start; padding-top: 40px; }
  .stats b { font-size: 18px; }
  .hud-pill { padding: 6px 10px; font-size: 14px; }
  .player { max-width: 46vw; padding-right: 10px; }
  .player img { width: 32px; height: 32px; }
  .ticket { width: 98px; padding: 5px 7px 6px; border-radius: 12px; }
  .ticket .who { font-size: 11px; margin-bottom: 3px; }
  .ticket .who kbd { display: none; }
  .ticket li { font-size: 10px; gap: 4px; }
  .bubble { margin-left: 0; max-width: 130px; font-size: 11px; padding: 5px 8px; border-radius: 12px; }
  .station { font-size: 11px; padding: 4px 8px 4px 4px; }
  .station .nm { display: none; }
  .tray-label { display: none; }
  .tray-slot { min-width: 38px; padding: 0 8px; font-size: 11px; }
  .tray-slot .nm { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
