/* Phone: a controller tinted in the player's own colour. During the race nothing
   to read but a number. */
/* no double-tap zoom anywhere on the phone (the pad itself goes further: touch-action none) */
html, body { height: 100%; touch-action: manipulation; }
body { background: var(--grass-deep); overscroll-behavior: none; }
body.racing { overflow: hidden; position: fixed; inset: 0; }
* { -webkit-tap-highlight-color: transparent; }
button, input, select, label, a, .look { touch-action: manipulation; }
.screen { min-height: 100dvh; display: flex; flex-direction: column; padding: calc(22px + env(safe-area-inset-top)) 22px calc(22px + env(safe-area-inset-bottom)); }

/* ---------------------------------------------------------------- join */
.join { gap: 16px; background: var(--grass-deep) radial-gradient(120% 60% at 50% 0%, #6aa843 0%, transparent 70%); }
.join h1 { font-size: 44px; font-weight: 800; letter-spacing: -.03em; line-height: .95; margin: 18px 0 0; }
.join .lead { font-size: 18px; color: var(--chalk-dim); margin: 0; line-height: 1.35; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 15px; font-weight: 600; color: var(--chalk-dim); }
.input, .select { width: 100%; height: 54px; border-radius: 12px; border: 3px solid transparent; background: var(--chalk); color: var(--ink); font: 600 18px var(--f-ui); padding: 0 14px; appearance: none; }
.select { background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(-45deg, transparent 50%, var(--ink) 50%); background-position: right 22px center, right 16px center; background-size: 6px 6px; background-repeat: no-repeat; }
.input:focus, .select:focus { outline: none; border-color: var(--hivis); }
.hint { font-size: 15px; color: var(--chalk-dim); line-height: 1.4; margin: 0; }
.sub-hint { font-size: 13px; color: var(--chalk-dim); }
.field .lbl { font-size: 15px; font-weight: 600; color: var(--chalk-dim); }
.looks { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.look { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px 8px; border-radius: 12px; border: 3px solid transparent; background: rgba(0, 0, 0, .18); color: var(--chalk); font-size: 12px; font-weight: 700; cursor: pointer; }
.look canvas { width: 100%; max-width: 64px; aspect-ratio: 1; }
.look.on { border-color: var(--hivis); background: rgba(255, 210, 63, .18); }
.look:focus-visible { outline: 3px solid var(--chalk); outline-offset: 2px; }
.join .btn { margin-top: auto; }
.btn { height: 60px; border: 0; border-radius: 16px; background: var(--hivis); color: var(--ink); font-size: 22px; font-weight: 800; letter-spacing: -.01em; box-shadow: 0 5px 0 #b8901b; }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #b8901b; }
.btn:disabled { opacity: .6; }
.btn:focus-visible { outline: 3px solid var(--chalk); outline-offset: 3px; }
.err { color: var(--hivis); font-weight: 700; font-size: 15px; min-height: 1em; margin: 0; }

/* ---------------------------------------------------------------- me: your tractor in your colour */
.me { align-items: center; justify-content: center; text-align: center; gap: 12px; background: var(--c); color: var(--ink); }
.me .code { font-size: clamp(36px, 12vw, 64px); font-weight: 800; letter-spacing: -.02em; line-height: 1.05; overflow-wrap: anywhere; max-width: 100%; }
.me .who { font-size: 18px; font-weight: 600; opacity: .75; }
.me canvas.trac { width: 200px; height: 200px; }
.me .msg { font-size: 22px; font-weight: 700; max-width: 18ch; line-height: 1.3; }
.me .big { font-size: 140px; font-weight: 800; line-height: .9; letter-spacing: -.04em; }
.me .sub { font-size: 22px; font-weight: 700; }
.me .pill { display: inline-block; background: var(--ink); color: var(--chalk); border-radius: 30px; padding: 8px 18px; font-size: 20px; font-weight: 700; }
.me .num { font-size: 120px; font-weight: 800; line-height: 1; color: var(--ink); }
.me .num.tick { animation: tick .8s var(--ease-out) both; }
@keyframes tick { from { transform: scale(1.6); opacity: 0; } to { transform: none; opacity: 1; } }

.tiltsw { display: inline-flex; align-items: center; gap: 12px; margin-top: 10px; padding: 10px 18px 10px 10px; border-radius: 30px; border: 0; background: rgba(29, 42, 23, .85); color: var(--chalk); font-size: 18px; font-weight: 700; cursor: pointer; }
.tiltsw i { width: 44px; height: 26px; border-radius: 13px; background: rgba(255, 255, 255, .3); position: relative; transition: background-color .15s; }
.tiltsw i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--chalk); transition: transform .15s var(--ease-out); }
.tiltsw.on i { background: var(--grip); }
.tiltsw.on i::after { transform: translateX(18px); }
.tiltsw:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.tiltmsg { margin: 0; font-size: 15px; font-weight: 600; min-height: 1.3em; max-width: 26ch; }

/* ---------------------------------------------------------------- the steering pad */
.pad { position: fixed; inset: 0; background: var(--c); color: var(--ink); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; overflow: hidden; }
.pad.mud { box-shadow: inset 0 0 0 14px #6b4a2a; }
.half { position: absolute; top: 0; bottom: 0; width: 50%; display: flex; align-items: flex-end; justify-content: center; padding-bottom: calc(60px + env(safe-area-inset-bottom)); transition: background-color .08s; }
.half.l { left: 0; border-right: 2px dashed rgba(29, 42, 23, .25); }
.half.r { right: 0; }
.half.on { background: rgba(29, 42, 23, .22); }
.half svg { width: 110px; height: 110px; opacity: .8; }
.hud { position: absolute; left: 0; right: 0; top: 0; padding: calc(14px + env(safe-area-inset-top)) 18px 0; display: flex; align-items: flex-start; justify-content: space-between; pointer-events: none; }
.hud .rank { font-size: 92px; font-weight: 800; line-height: .9; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.hud .lap { font-size: 46px; font-weight: 800; line-height: 1; text-align: right; font-variant-numeric: tabular-nums; }
.hud .lap small { display: block; font-size: 16px; font-weight: 700; opacity: .7; }
.mid { position: absolute; left: 0; right: 0; top: calc(130px + env(safe-area-inset-top)); display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: none; }
.mini { width: min(78vw, 330px); aspect-ratio: 1540 / 1080; border-radius: 14px; border: 4px solid var(--ink); background: var(--grass); }
.tag { display: flex; align-items: center; gap: 10px; background: var(--ink); color: var(--chalk); border-radius: 30px; padding: 6px 16px 6px 6px; font-size: 26px; font-weight: 800; }
.tag canvas { width: 40px; height: 40px; }
.fxbar { width: min(78vw, 330px); height: 44px; border-radius: 12px; background: rgba(29, 42, 23, .25); overflow: hidden; position: relative; display: none; }
.fxbar.on { display: block; }
.fxbar i { position: absolute; inset: 0 auto 0 0; background: var(--fxc, var(--hivis)); }
.fxbar b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 800; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
.tiltbar { position: absolute; left: 12%; right: 12%; bottom: calc(24px + env(safe-area-inset-bottom)); height: 14px; border-radius: 7px; background: rgba(29, 42, 23, .25); pointer-events: none; display: none; }
.tiltbar.on { display: block; }
.tiltbar i { position: absolute; top: -7px; width: 28px; height: 28px; margin-left: -14px; border-radius: 50%; background: var(--ink); border: 3px solid var(--chalk); transition: left .08s linear; }
.finish { position: absolute; inset: auto 0 calc(190px + env(safe-area-inset-bottom)) 0; text-align: center; pointer-events: none; font-size: 64px; font-weight: 800; display: none; }
.finish.on { display: block; animation: tick .6s var(--ease-out) both; }

/* ---------------------------------------------------------------- product card: what you just picked up */
#card { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; z-index: 20; }
.prod { width: min(84vw, 360px); background: var(--chalk); color: var(--ink); border-radius: 22px; border: 6px solid var(--fxc); box-shadow: 0 12px 0 rgba(0, 0, 0, .25); padding: 18px 18px 14px; display: flex; flex-direction: column; align-items: center; gap: 8px; animation: card .35s var(--ease-out) both; }
.prod.out { opacity: 0; transform: scale(.9) translateY(30px); transition: opacity .3s, transform .3s; }
.prod .logo { width: 100%; height: 120px; border-radius: 12px; background: #fff center / contain no-repeat; background-origin: content-box; padding: 10px; }
.prod .logo.dark { background-color: var(--ink); }
.prod .pn { font-size: 26px; font-weight: 800; }
.prod canvas.hz { width: 120px; height: 120px; }
/* prank and event cards sit on their icon's colour, not on white */
.prod.prank { background: var(--fxc); border-color: rgba(255, 255, 255, .85); color: #fff; }
.prod.prank .fx { background: rgba(0, 0, 0, .25); }
.prod.prank .pn { color: #fff; }
/* the pad during a clover event */
.pad.ev-reverse .half svg { transform: scaleX(-1); color: #7a4cff; opacity: 1; }
.pad.ev-reverse { box-shadow: inset 0 0 0 10px #7a4cff; }
.pad.ev-turboAll { box-shadow: inset 0 0 0 10px #ff7a1a; animation: hot .4s steps(2) infinite; }
@keyframes hot { 50% { box-shadow: inset 0 0 0 16px #ffd23f; } }
.pad.ev-storm::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(105deg, rgba(160, 200, 255, .35) 0 2px, transparent 2px 22px), rgba(20, 40, 70, .45); animation: rain .35s linear infinite; }
@keyframes rain { from { background-position: 0 0, 0 0; } to { background-position: -40px 120px, 0 0; } }
.prod .fx { font-size: 46px; font-weight: 800; color: #fff; background: var(--fxc); border-radius: 12px; padding: 4px 18px; letter-spacing: -.01em; }
@keyframes card { from { opacity: 0; transform: scale(.6) rotate(-6deg); } to { opacity: 1; transform: none; } }

.conn { position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--barn); color: #fff; font-size: 15px; font-weight: 600; padding: 8px 14px; border-radius: 10px; display: none; z-index: 30; }
.conn.on { display: block; }

@media (prefers-reduced-motion: reduce) {
  .prod, .finish.on, .me .num.tick { animation: none; }
}
