@font-face { font-family: 'Rye'; src: url('fonts/rye.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Oswald'; src: url('fonts/oswald.woff2') format('woff2'); font-weight: 400 700; font-display: swap; }

:root {
  --ink: #1d1320; --cream: #f6e7c4; --paper: #fbf1d8; --red: #d9483b; --red-d: #9f2c25;
  --gold: #ffb83d; --gold-d: #c47d12; --teal: #19b3b1; --plum: #2a1a40;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #120d30; color: var(--cream);
  font-family: 'Oswald', 'Arial Narrow', Arial, sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hide { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* ---------- top HUD ---------- */
#top { position: fixed; z-index: 5; top: 0; left: 0; right: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start;
  padding: calc(10px + var(--sat)) calc(12px + var(--sar)) 0 calc(12px + var(--sal)); pointer-events: none; }
#top > * { pointer-events: auto; }
#bullTag { justify-self: start; background: rgba(29,19,32,.72); border: 2px solid rgba(246,231,196,.35); border-radius: 10px; padding: 5px 12px 6px; line-height: 1.1; }
#bullName { font-family: 'Rye', Georgia, serif; font-size: 18px; display: block; }
#bullTag small { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }
#clock { grid-column: 2; text-align: center; }
#time { font-family: 'Rye', Georgia, serif; font-size: clamp(42px, 9vmin, 76px); line-height: 1; color: #fff7e1; font-variant-numeric: tabular-nums;
  text-shadow: 0 3px 0 var(--ink), 3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 -3px 0 var(--ink), 0 7px 0 rgba(29,19,32,.55); min-width: 3.2em; }
#time.hot { color: var(--gold); }
#pips { display: flex; gap: 5px; justify-content: center; margin-top: 8px; }
#pips i { width: clamp(16px, 3.4vmin, 26px); height: 9px; border-radius: 3px; background: rgba(29,19,32,.6); border: 2px solid var(--ink); position: relative; overflow: hidden; }
#pips i::after { content: ''; position: absolute; inset: 0; background: var(--gold); transform-origin: left; transform: scaleX(var(--f, 0)); }
#pips i:last-child::after { background: var(--red); }
#topBtns { grid-column: 3; justify-self: end; display: flex; gap: 8px; }
.icon { width: 44px; height: 44px; border-radius: 12px; border: 2px solid rgba(246,231,196,.4); background: rgba(29,19,32,.72); display: grid; place-items: center; padding: 0; }
.icon svg { width: 24px; height: 24px; fill: var(--cream); stroke: var(--cream); }
.icon .mute { display: none; }
.icon[aria-pressed="false"] .wave { display: none; }
.icon[aria-pressed="false"] .mute { display: block; }
.icon:hover { background: rgba(60,36,70,.9); }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; }
#menu { justify-content: space-between; padding: calc(14px + var(--sat)) 12px calc(14px + var(--sab)); pointer-events: none;
  background: linear-gradient(to bottom, rgba(18,10,40,.55), rgba(18,10,40,0) 34%, rgba(18,10,40,0) 58%, rgba(18,10,40,.7)); }
#menu > * { pointer-events: auto; }
.logo { text-align: center; margin-top: clamp(0px, 2vh, 26px); animation: drop .7s cubic-bezier(.2,1.4,.4,1) both; }
.logo-top { font-size: clamp(11px, 2vmin, 16px); letter-spacing: .42em; text-transform: uppercase; color: var(--gold); }
.logo-top span { font-size: .8em; }
.logo h1 { margin: 2px 0 0; font-family: 'Rye', Georgia, serif; font-weight: 400; font-size: clamp(34px, 8.6vmin, 92px); line-height: 1; color: var(--cream); letter-spacing: .01em;
  text-shadow: 0 2px 0 var(--red), 0 4px 0 var(--red), 0 6px 0 var(--red-d), 0 8px 0 var(--ink), 0 10px 0 var(--ink), 0 16px 22px rgba(0,0,0,.5); }
.logo h1 b { font-weight: 400; color: var(--gold); font-size: 1.25em; }
.logo p { margin: 16px 0 0; font-size: clamp(13px, 2.3vmin, 19px); letter-spacing: .18em; text-transform: uppercase; opacity: .95; text-shadow: 0 2px 6px rgba(0,0,0,.6); }
@keyframes drop { from { opacity: 0; transform: translateY(-40px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }

.menu-bottom { width: 100%; max-width: 760px; display: flex; flex-direction: column; align-items: center; gap: 12px; animation: rise .6s .15s ease-out both; }
#cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.bull { position: relative; text-align: left; background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: 14px; padding: 8px 10px 9px;
  box-shadow: 0 5px 0 var(--ink); transition: transform .12s, box-shadow .12s, background .12s; min-width: 0; }
.bull canvas { position: static; display: block; width: 100%; height: auto; aspect-ratio: 16/9; border-radius: 8px; background: linear-gradient(#f1c98a, #d99a5b); margin-bottom: 6px; }
.bull .nm { font-family: 'Rye', Georgia, serif; font-size: clamp(14px, 2.6vmin, 20px); line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bull .tg { font-size: 12px; opacity: .75; line-height: 1.2; min-height: 1.2em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bull .rw { display: flex; justify-content: space-between; align-items: center; margin-top: 5px; font-size: 13px; gap: 4px; }
.bull .lv { letter-spacing: .08em; text-transform: uppercase; font-weight: 700; color: var(--red-d); }
.bull .bs { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bull .bs em { font-style: normal; color: var(--gold-d); letter-spacing: -1px; }
.bull[aria-checked="true"] { background: #fff; transform: translateY(-6px); box-shadow: 0 11px 0 var(--ink), 0 0 0 4px var(--gold); }
.bull.locked { filter: grayscale(.85) brightness(.82); }
.bull.locked .bs { color: var(--ink); }
.bull:hover:not([aria-checked="true"]) { transform: translateY(-2px); box-shadow: 0 7px 0 var(--ink); }

.btn { font-family: 'Rye', Georgia, serif; font-size: 18px; padding: 11px 22px 12px; border-radius: 14px; border: 3px solid var(--ink); background: var(--paper); color: var(--ink);
  box-shadow: 0 5px 0 var(--ink); transition: transform .08s, box-shadow .08s; min-height: 48px; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--red); color: #fff7e1; text-shadow: 0 2px 0 var(--red-d); }
.btn.gold { background: var(--gold); }
.btn.big { font-size: clamp(22px, 4vmin, 30px); padding: 12px 44px 14px; animation: pulse 1.6s ease-in-out infinite; }
.btn:disabled { filter: grayscale(1); opacity: .7; animation: none; cursor: not-allowed; }
@keyframes pulse { 50% { transform: scale(1.045); } }
.how { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; justify-content: center; font-size: 14px; letter-spacing: .04em; text-shadow: 0 1px 4px rgba(0,0,0,.8); }
kbd { font: inherit; font-size: 12px; background: var(--cream); color: var(--ink); border-radius: 5px; padding: 1px 6px; margin-right: 3px; box-shadow: 0 2px 0 rgba(0,0,0,.5); }
body.touch .how kbd { display: none; }

/* ---------- result ---------- */
#result, #pause { justify-content: center; padding: 12px; background: rgba(18,10,40,.5); }
#result { animation: fade .3s both; }
@keyframes fade { from { background: rgba(18,10,40,0); } }
.card { width: min(430px, 100%); max-height: 100%; overflow: auto; background: var(--paper); color: var(--ink); border: 4px solid var(--ink); border-radius: 18px; padding: 0 18px 16px;
  box-shadow: 0 8px 0 var(--ink), 0 24px 50px rgba(0,0,0,.5); text-align: center; animation: pop .45s cubic-bezier(.2,1.5,.4,1) both;
  background-image: radial-gradient(rgba(160,110,50,.13) 1px, transparent 1.4px); background-size: 9px 9px; }
.card.small { width: min(300px, 100%); }
@keyframes pop { from { opacity: 0; transform: scale(.8) rotate(-2deg); } }
.card-head { margin: 0 -18px; padding: 11px 10px 12px; background: var(--red); color: #fff7e1; font-family: 'Rye', Georgia, serif; font-size: clamp(22px, 5vmin, 30px); border-bottom: 4px solid var(--ink); border-radius: 13px 13px 0 0; text-shadow: 0 2px 0 var(--red-d); }
.card.fail .card-head { background: var(--plum); text-shadow: none; }
.score-row { margin-top: 10px; }
.score { font-family: 'Rye', Georgia, serif; font-size: clamp(52px, 13vmin, 78px); line-height: 1; font-variant-numeric: tabular-nums; }
.card.fail .score { font-size: clamp(38px, 9vmin, 52px); color: var(--red-d); padding: 6px 0; }
.stars { font-size: 34px; line-height: 1; letter-spacing: 6px; margin-top: 2px; }
.stars span { color: rgba(29,19,32,.18); display: inline-block; }
.stars span.on { color: var(--gold); -webkit-text-stroke: 2px var(--ink); animation: star .4s cubic-bezier(.2,1.8,.4,1) both; }
@keyframes star { from { transform: scale(2.4) rotate(-40deg); opacity: 0; } }
.sub { font-size: 15px; letter-spacing: .06em; text-transform: uppercase; margin-top: 6px; min-height: 1.2em; }
.sub b { color: var(--red-d); }
.break { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.break div { background: rgba(29,19,32,.07); border-radius: 9px; padding: 5px 2px 6px; }
.break label { display: block; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; opacity: .7; }
.break b { font-size: 19px; font-variant-numeric: tabular-nums; }
.bars { margin-top: 10px; display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: 62px 1fr; align-items: center; gap: 8px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; text-align: left; }
.bar i { height: 12px; border: 2px solid var(--ink); border-radius: 7px; background: #fff; overflow: hidden; }
.bar em { display: block; height: 100%; width: 0; background: var(--teal); transition: width .9s .3s cubic-bezier(.2,.8,.2,1); }
.bar:last-child em { background: var(--gold); }
.tip { margin: 10px 0 0; font-size: 14px; line-height: 1.35; min-height: 1.3em; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.actions.col { flex-direction: column; margin-top: 18px; }

/* ---------- touch controls ---------- */
#touch { position: fixed; z-index: 3; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end;
  padding: 0 calc(14px + var(--sar)) calc(16px + var(--sab)) calc(14px + var(--sal)); pointer-events: none; }
#touch button { pointer-events: auto; border: 3px solid var(--ink); background: rgba(246,231,196,.9); color: var(--ink); box-shadow: 0 5px 0 var(--ink); touch-action: none; }
#touch .lean { display: flex; gap: 12px; }
#touch .lean button { width: 78px; height: 78px; border-radius: 22px; display: grid; place-items: center; padding: 0; }
#touch .lean svg { width: 40px; height: 40px; stroke: var(--ink); }
#tSpur { width: 104px; height: 104px; border-radius: 50%; font-family: 'Rye', Georgia, serif; font-size: 22px; background: var(--gold) !important; }
#touch button.down { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); background: #fff; }
#touch button.warn { background: var(--red); animation: warn .3s linear infinite; }
#touch button.warn svg { stroke: #fff; }
@keyframes warn { 50% { transform: scale(1.08); } }

/* landscape: bull on the left, picker on the right */
body.wide #menu { align-items: flex-end; padding-right: calc(3vw + var(--sar)); background: linear-gradient(to bottom, rgba(18,10,40,.6), rgba(18,10,40,0) 36%), linear-gradient(to left, rgba(18,10,40,.6), rgba(18,10,40,0) 55%); }
body.wide .logo { align-self: center; }
body.wide .menu-bottom { width: min(380px, 42vw); }
body.wide #cards { grid-template-columns: 1fr; gap: 9px; }
body.wide .bull { display: grid; grid-template-columns: 104px 1fr; grid-template-rows: auto auto auto; column-gap: 10px; align-items: center; padding: 6px 10px 6px 6px; }
body.wide .bull canvas { grid-row: 1 / 4; margin: 0; }
body.wide .bull .rw { margin-top: 1px; }
body.wide .bull[aria-checked="true"] { transform: translateX(-8px); box-shadow: 0 5px 0 var(--ink), 0 0 0 4px var(--gold); }
body.wide .bull:hover:not([aria-checked="true"]) { transform: translateX(-3px); }
body.wide .how { flex-direction: column; align-items: center; }

@media (max-height: 520px) {
  body.wide .bull { display: block; padding: 4px 10px 5px; }
  body.wide .menu-bottom { flex-direction: column; flex-wrap: nowrap; gap: 7px; width: min(300px, 40vw); }
  body.wide #cards { flex: none; width: 100%; gap: 6px; }
  body.wide .how { display: none; }
  .bull .nm { display: inline; }
  .bull .rw { display: inline-flex; float: right; margin-top: 2px; gap: 8px; }
  .logo p { display: none; }
  .bull canvas { display: none; }
  .bull .tg { display: none; }
  .menu-bottom { gap: 8px; flex-direction: row; flex-wrap: wrap; justify-content: center; max-width: 900px; }
  #cards { flex: 1 1 380px; width: auto; }
  .how { flex-basis: 100%; font-size: 12px; }
  .btn.big { padding: 9px 26px 10px; }
  .card { padding-bottom: 10px; }
  .bars, .tip { display: none; }
  .score { font-size: 46px; }
  .stars { font-size: 26px; display: inline-block; }
  .score-row { display: flex; align-items: center; justify-content: center; gap: 14px; }
  #touch .lean button { width: 68px; height: 68px; }
  #tSpur { width: 88px; height: 88px; font-size: 19px; }
}
@media (max-width: 480px) {
  #cards { gap: 7px; }
  .bull { padding: 6px 7px 7px; }
  .bull .tg { display: none; }
  .bull .rw { flex-direction: column; align-items: flex-start; gap: 0; }
  #bullTag { padding: 4px 8px; }
  #bullName { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .btn.big, #touch button.warn { animation: none; }
  .logo, .menu-bottom, .card { animation-duration: .01s; }
}
