@font-face { font-family: 'Abril Fatface'; src: url('fonts/abril-fatface-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Alegreya Sans'; src: url('fonts/alegreya-sans-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Alegreya Sans'; src: url('fonts/alegreya-sans-latin-800-normal.woff2') format('woff2'); font-weight: 800; font-display: swap; }
:root {
  --paper: #E8483A; --ink: #2B1A4D; --tint: #F4765F; --accent: #FFD23F; --white: #FFFFFF;
  --display: 'Abril Fatface', 'Didot', 'Bodoni MT', Georgia, 'Noto Serif', serif;
  --body: 'Alegreya Sans', 'Trebuchet MS', 'Noto Sans', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); font: 500 17px/1.35 var(--body); overflow: hidden; -webkit-text-size-adjust: 100%; }
body { position: fixed; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
canvas#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, canvas:focus-visible { outline: 3px solid var(--white); outline-offset: 2px; box-shadow: 0 0 0 6px var(--ink); }
[hidden] { display: none !important; }

/* ---- during play ---- */
#hud { position: absolute; top: max(8px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); display: flex; align-items: flex-start; gap: 10px; pointer-events: none; }
.h-btns { display: flex; gap: 6px; pointer-events: auto; }
.icon { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--ink); color: var(--white); display: grid; place-items: center; padding: 0; }
.icon svg { width: 22px; height: 22px; fill: currentColor; }
.icon .off { display: none; } .muted .on { display: none; } .muted .off { display: block; }
.h-time { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
#timer { background: var(--ink); color: var(--white); padding: 6px 12px 7px; border-radius: 22px; font-weight: 800; font-size: 22px; line-height: 31px; font-variant-numeric: tabular-nums; min-width: 92px; text-align: center; }
#delta { font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--white); background: var(--ink); padding: 1px 10px; border-radius: 12px; }
#delta:empty { display: none; }
#title { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); width: min(92vw, 620px); text-align: center; pointer-events: none; color: var(--white); }
#title h2 { margin: 0; font: 400 clamp(34px, 9vw, 62px)/1.02 var(--display); text-shadow: 3px 3px 0 var(--ink); }
#title p { margin: 8px auto 0; max-width: 34em; font-weight: 800; font-size: 18px; color: var(--ink); background: var(--white); display: table; padding: 3px 12px 4px; border-radius: 3px; }
#title #tMedals { font-weight: 500; font-size: 15px; background: var(--ink); color: var(--white); }
#title p:empty { display: none; }
#caption { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); width: min(90vw, 620px); text-align: center; pointer-events: none; color: var(--white); }
#caption b { display: block; font: 400 clamp(28px, 7vw, 46px)/1.06 var(--display); text-shadow: 3px 3px 0 var(--ink); }
#caption span { display: table; margin: 10px auto 0; background: var(--ink); color: var(--white); padding: 4px 12px; border-radius: 3px; font-weight: 800; }
#toast { position: absolute; left: 50%; bottom: 44%; transform: translateX(-50%); background: var(--accent); color: var(--ink); font-weight: 800; padding: 6px 14px; border-radius: 3px; box-shadow: 3px 3px 0 var(--ink); pointer-events: none; text-align: center; max-width: 90vw; }
#pads { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; padding: 0 max(10px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); pointer-events: none; gap: 12px; }
.pad { position: relative; display: flex; gap: 6px; width: min(46vw, 250px); padding-top: 20px; }
.pad small { position: absolute; top: 0; left: 0; right: 0; text-align: center; font-weight: 800; font-size: 14px; color: var(--white); text-shadow: 1px 1px 0 var(--ink); overflow: hidden; white-space: nowrap; }
.half { flex: 1; height: min(19vh, 104px); min-height: 66px; border-radius: 16px; background: color-mix(in srgb, var(--ink) 62%, transparent); color: var(--white); display: grid; place-items: center; border: 2px solid transparent; }
.half svg { width: 62%; max-width: 52px; }
.half.on { background: var(--white); color: var(--ink); border-color: var(--ink); }

/* ---- the result: a slip of paper laid over the game ---- */
#banner { position: absolute; left: 50%; top: max(60px, 9vh); transform: translateX(-50%); width: min(94vw, 480px); background: var(--white); color: var(--ink); padding: 14px 16px 16px; box-shadow: 6px 6px 0 var(--ink); max-height: calc(100vh - 70px); overflow: auto; touch-action: pan-y; }
#banner h2 { margin: 0 0 4px; font: 400 clamp(25px, 6vw, 33px)/1.08 var(--display); }
#banner p { margin: 3px 0; }
#banner p:empty { display: none; }
#bMedal { font-weight: 800; }
.b-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn { flex: 1 1 40%; min-height: 46px; padding: 8px 12px; background: var(--white); color: var(--ink); border: 3px solid var(--ink); font-weight: 800; font-size: 17px; }
.btn.solid { background: var(--ink); color: var(--white); }
.btn kbd { font: inherit; font-weight: 500; opacity: .75; margin-left: 4px; }

/* ---- the menu is a menu ---- */
#menu { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; background: var(--paper); color: var(--ink); touch-action: pan-y; -webkit-overflow-scrolling: touch; padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); align-content: start; }
.m-head { display: flex; flex-direction: column; min-width: 0; }
#logo { margin: 0; font: 400 clamp(52px, 16.5vw, 100px)/0.92 var(--display); color: var(--white); text-shadow: 4px 4px 0 var(--ink); letter-spacing: -0.01em; }
#tagline { margin: 10px 0 0; font-weight: 800; font-size: 19px; color: var(--ink); }
#hero { width: 100%; height: 200px; display: block; }
.m-main { display: grid; gap: 10px; margin-top: 0; }
.tile { text-align: left; border: 0; padding: 12px 16px 13px; background: var(--white); color: var(--ink); box-shadow: 5px 5px 0 var(--ink); min-height: 56px; }
.tile .t { display: block; font: 400 26px/1.08 var(--display); }
.tile .s { display: block; font-size: 16px; margin-top: 2px; }
.t-serve { background: var(--ink); color: var(--white); box-shadow: 5px 5px 0 var(--white); }
.t-daily { background: var(--accent); }
.t-chal { background: #7BE0E8; }
.tile:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }
#menuLinks { margin: 18px 0 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.link { background: none; border: 0; padding: 8px 0; font-weight: 800; font-size: 17px; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; min-height: 44px; min-width: 44px; }
#stats, #byline { margin: 4px 0 0; font-size: 15px; }
#carte { background: var(--white); padding: 16px 18px 20px; box-shadow: 6px 6px 0 var(--ink); min-width: 0; align-self: start; }
#carte h3 { margin: 18px 0 2px; font: 400 25px/1.1 var(--display); color: var(--ink); }
#carte h3:first-child { margin-top: 0; }
.row { display: flex; align-items: baseline; width: 100%; background: none; border: 0; padding: 9px 0; min-height: 44px; color: var(--ink); text-align: left; font-size: 18px; gap: 6px; }
.row .nm { flex: 0 1 auto; font-weight: 800; }
.row .ld { flex: 1 1 12px; min-width: 12px; border-bottom: 2px dotted var(--ink); transform: translateY(-4px); opacity: .55; }
.row .tm { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.row .pips { flex: 0 0 auto; display: inline-flex; gap: 2px; transform: translateY(-1px); align-self: center; }
.row i { display: block; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--ink); }
.row i.f { background: var(--ink); }
.row[disabled] { opacity: .42; cursor: default; }
.row.cur .nm { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 3px; }
@media (min-width: 900px) {
  #menu { grid-template-columns: minmax(360px, 1fr) minmax(420px, 1fr); gap: 34px; padding: 34px 48px; }
  #logo { font-size: clamp(70px, 7vw, 110px); }
  #hero { height: 260px; }
}

/* ---- panels ---- */
#panel { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--ink) 55%, transparent); padding: 16px; overflow-y: auto; touch-action: pan-y; }
.card { background: var(--white); color: var(--ink); width: min(100%, 560px); padding: 18px 20px 20px; box-shadow: 7px 7px 0 var(--accent); max-height: calc(100vh - 32px); overflow-y: auto; touch-action: pan-y; }
.card h2 { margin: 0 0 8px; font: 400 32px/1.08 var(--display); }
.card p { margin: 6px 0; }
.card h3 { margin: 14px 0 4px; font: 400 22px/1.1 var(--display); }
#pBtns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
#pToast { min-height: 1.3em; font-weight: 800; margin: 8px 0 0; }
#pToast:empty { display: none; }
.looks { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.look { background: var(--white); border: 3px solid var(--ink); padding: 6px; text-align: center; color: var(--ink); min-height: 150px; }
.look canvas { display: block; margin: 0 auto; width: 100%; height: 86px; }
.look b { display: block; font-size: 16px; line-height: 1.15; }
.look small { display: block; font-size: 14px; line-height: 1.15; margin-top: 2px; }
.look.on { background: var(--ink); color: var(--white); }
.look[disabled] { opacity: .75; cursor: default; border-style: dashed; }
textarea.sharebox { width: 100%; font: 500 15px/1.3 var(--body); height: 96px; border: 2px solid var(--ink); padding: 6px; color: var(--ink); background: var(--white); user-select: text; -webkit-user-select: text; touch-action: auto; }
@media (max-height: 520px) and (orientation: landscape) {
  .half { height: 76px; min-height: 60px; } #title { top: 62px; } #title h2 { font-size: 34px; } #title p { font-size: 15px; margin-top: 4px; }
  #caption { top: 58px; } #banner { top: 8px; width: min(70vw, 480px); max-height: calc(100vh - 16px); } .pad { width: min(26vw, 220px); }
}
@media (prefers-reduced-motion: reduce) { .tile:active { transform: none; } }
