@font-face { font-family: 'Oleo Script Swash Caps'; font-weight: 700; font-display: swap; src: url(fonts/oleo-script-swash-caps-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Alegreya Sans'; font-weight: 500; font-display: swap; src: url(fonts/alegreya-sans-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Alegreya Sans'; font-weight: 800; font-display: swap; src: url(fonts/alegreya-sans-latin-800-normal.woff2) format('woff2'); }
:root {
  --wall: #f7c6d0; --ink: #43102b; --card: #fff6f8; --accent: #d81e5b; --accent2: #ffd761; --mint: #a6e8ce; --on-accent: #fff6f8; --line: #1e0a1e;
  --display: 'Oleo Script Swash Caps', 'Brush Script MT', Georgia, serif; --body: 'Alegreya Sans', system-ui, -apple-system, 'Segoe UI', 'Noto Sans', sans-serif;
  --gut: max(12px, env(safe-area-inset-left)); --col: 248px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--wall); color: var(--ink); font: 500 17px/1.3 var(--body); overscroll-behavior: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; outline: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

/* ---------- in play ---------- */
#hud { position: fixed; top: max(8px, env(safe-area-inset-top)); left: var(--gut); right: var(--gut); height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 8px; pointer-events: none; }
#hud > * { pointer-events: auto; }
#clockWrap { display: flex; flex-direction: column; align-items: center; line-height: 1; min-width: 0; }
#clock { font: 800 34px/1 var(--body); font-variant-numeric: tabular-nums lining-nums; }
#rival { font-size: 15px; font-variant-numeric: tabular-nums lining-nums; margin-top: 2px; background: var(--card); border-radius: 9px; padding: 1px 8px; border: 2px solid var(--line); white-space: nowrap; }
#rival.over { background: var(--accent); color: var(--on-accent); }
#hudEnd { display: flex; align-items: center; gap: 6px; flex: none; }
.cakes { display: inline-flex; align-items: flex-end; flex-direction: column-reverse; min-width: 48px; }
.cakes svg { display: block; width: 46px; height: 44px; }
#strip { position: fixed; top: calc(max(8px, env(safe-area-inset-top)) + 54px); left: var(--gut); right: var(--gut); height: 34px; pointer-events: none; }
#bottom { position: fixed; left: var(--gut); right: var(--gut); bottom: max(10px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 6px; }
#joke { margin: 0; min-height: 52px; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 16px; line-height: 1.15; opacity: 0; transition: opacity .18s; }
#joke.on { opacity: 1; }
#hintBar { display: flex; align-items: center; gap: 8px; background: var(--card); border: 3px solid var(--line); border-radius: 14px; padding: 4px 6px 4px 12px; min-height: 58px; margin-top: -64px; position: relative; }
#hintText { margin: 0; flex: 1; font-size: 16px; line-height: 1.12; }
#tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tool { position: relative; min-height: 62px; background: var(--card); border: 3px solid var(--line); border-radius: 16px; box-shadow: 0 4px 0 var(--line); padding: 4px 2px 3px; display: flex; flex-direction: column; align-items: center; justify-content: center; touch-action: manipulation; }
.tool:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.tool .ic svg { display: block; width: 28px; height: 28px; }
.tool .lb { font-size: 14px; line-height: 1; margin-top: 2px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 3px; }
.tool:disabled { opacity: .45; cursor: default; }
.tool.on { background: var(--mint); color: var(--line); }
.hintTool { background: var(--accent2); color: var(--line); }
#hintCount { position: absolute; top: -9px; right: -5px; min-width: 26px; height: 26px; line-height: 21px; padding: 0 5px; border-radius: 13px; background: var(--accent); color: var(--on-accent); border: 2.5px solid var(--line); font-size: 15px; font-variant-numeric: tabular-nums lining-nums; }
#hintCount.bump { animation: bump .35s; }
@keyframes bump { 40% { transform: scale(1.6) rotate(-8deg); } }
.icon { width: 48px; height: 48px; border-radius: 50%; background: var(--card); border: 3px solid var(--line); box-shadow: 0 3px 0 var(--line); display: inline-flex; align-items: center; justify-content: center; padding: 0; flex: none; touch-action: manipulation; }
.icon:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.icon svg { width: 26px; height: 26px; display: block; }
.icon.small { width: 44px; height: 44px; box-shadow: none; }
.icon.go { background: var(--mint); color: var(--line); }

/* Short of room upright: smaller furniture, more hall. */
body.compact #hud { top: max(4px, env(safe-area-inset-top)); height: 44px; }
body.compact #hud .icon { width: 42px; height: 42px; box-shadow: 0 2px 0 var(--line); }
body.compact #hud .icon svg { width: 23px; height: 23px; }
body.compact #clock { font-size: 28px; }
body.compact .cakes { min-width: 40px; }
body.compact .cakes svg { width: 40px; height: 38px; }
body.compact #strip { top: calc(max(4px, env(safe-area-inset-top)) + 46px); height: 24px; }
body.compact #bottom { bottom: max(7px, env(safe-area-inset-bottom)); gap: 4px; }
body.compact #tools { gap: 6px; }
body.compact .tool { min-height: 50px; border-radius: 14px; box-shadow: 0 3px 0 var(--line); padding: 2px; }
body.compact .tool .ic svg { width: 23px; height: 23px; }
body.compact .tool .lb { font-size: 13px; margin-top: 1px; }
body.compact #joke { min-height: 40px; font-size: 15px; }
body.compact #hintBar { min-height: 50px; margin-top: -50px; padding: 3px 5px 3px 10px; }
body.compact #hintText { font-size: 14.5px; line-height: 1.08; }
/* Zoomed: the board has this space to itself, so a joke floats over it and takes no room. */
body.zoomed #joke { position: absolute; left: 0; right: 0; bottom: calc(100% + 40px); min-height: 0; padding: 5px 9px; background: var(--card); border: 2px solid var(--line); border-radius: 12px; pointer-events: none; }
#rail { position: fixed; background: var(--card); border: 2px solid var(--line); border-radius: 13px; touch-action: none; cursor: grab; z-index: 2; }
#rail::before { content: ''; position: absolute; inset: -6px -3px; }
#railThumb { position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: var(--accent2); border: 2px solid var(--line); border-radius: 11px; pointer-events: none; }

body.land #hud { left: auto; right: var(--gut); width: var(--col); }
body.land #strip { left: auto; right: var(--gut); width: var(--col); height: 64px; }
body.land #bottom { left: auto; right: var(--gut); width: var(--col); }
body.land #joke { min-height: 0; font-size: 15px; }
body.land #hintBar { margin-top: 0; }
body.land #tools { gap: 6px; }
body.land .tool { min-height: 50px; }
body.land .tool .ic svg { width: 22px; height: 22px; }
body.land .tool .lb { font-size: 13px; }
body.land.zoomed #joke { position: static; padding: 2px 6px; font-size: 14px; }
@media (max-height: 400px) { body.land .tool .lb { display: none; } body.land #hintText { font-size: 14px; } body.land #strip { height: 38px; } body.land #hintBar { min-height: 0; padding: 2px 4px 2px 8px; } body.land .tool { min-height: 44px; } }

/* ---------- menu ---------- */
#menu { position: fixed; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: max(10px, env(safe-area-inset-top)) var(--gut) max(14px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; touch-action: pan-y; }
.menu-head, .menu-actions { width: 100%; max-width: 440px; text-align: center; flex: none; }
#menu::before, #menu::after { content: ''; margin: auto; }
#hero { display: block; width: 100%; height: 118px; margin: 0 auto -2px; }
#title { margin: 0; font: 700 clamp(46px, 13.5vw, 66px)/.92 var(--display); letter-spacing: .005em; color: var(--ink); text-shadow: 0 3px 0 var(--card), 0 -1px 0 var(--card), 2px 0 0 var(--card), -2px 0 0 var(--card); }
#tagline { margin: 7px auto 10px; max-width: 26em; font-size: 18px; line-height: 1.18; }
.invite { display: block; width: 100%; position: relative; text-align: center; background: var(--card); border: 3px solid var(--line); border-radius: 22px; box-shadow: 0 6px 0 var(--line); padding: 16px 14px 14px; transform: rotate(-.8deg); transition: transform .08s; }
.invite:active { transform: rotate(-.8deg) translateY(4px); box-shadow: 0 2px 0 var(--line); }
.invite::before { content: ''; position: absolute; inset: 5px; border-radius: 15px; border: 2px dotted var(--accent); pointer-events: none; }
.invite .big { display: block; font: 700 34px/1 var(--display); color: var(--accent); }
.invite .date { display: block; font-size: 17px; margin-top: 3px; }
.invite .row { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 7px; font-weight: 800; font-size: 19px; font-variant-numeric: lining-nums; }
.invite .row svg { width: 52px; height: 48px; display: block; }
.invite .state { display: block; margin-top: 4px; font-size: 15px; }
.invite .state.done { color: var(--accent); font-weight: 800; font-size: 17px; }
.beat { display: block; width: 100%; background: var(--accent); color: var(--on-accent); border: 3px solid var(--line); border-radius: 18px; box-shadow: 0 5px 0 var(--line); padding: 10px 12px; margin-bottom: 12px; line-height: 1.15; }
.beat b { display: block; font: 700 27px/1.1 var(--display); }
.trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.sq { color: var(--line); background: var(--accent2); border: 3px solid var(--line); border-radius: 18px; box-shadow: 0 4px 0 var(--line); padding: 7px 3px 6px; line-height: 1.05; font-size: 15.5px; font-weight: 800; min-height: 82px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; overflow: hidden; }
.sq:nth-child(2) { background: var(--mint); }
.sq:nth-child(3) { background: var(--card); color: var(--ink); }
.sq:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.sq svg { width: 38px; height: 38px; display: block; flex: none; }
#stats { margin: 12px 0 2px; font-weight: 800; font-variant-numeric: lining-nums; min-height: 1.2em; line-height: 1.15; }
#menuLinks { margin: 4px 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 8px; }
.link { background: none; border: 0; text-decoration: underline; text-underline-offset: 3px; padding: 6px 6px; min-height: 38px; font-size: 16px; }
#byline { margin: 2px 0 0; font-size: 14px; opacity: .85; }

/* ---------- panels ---------- */
#panel { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: max(10px, env(safe-area-inset-top)) var(--gut) max(10px, env(safe-area-inset-bottom)); background: rgba(30, 10, 30, .42); z-index: 5; }
#panel.sheet { background: transparent; align-items: flex-end; pointer-events: none; }
#panel.sheet .card { pointer-events: auto; }
.card { width: 100%; max-width: 480px; max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--card); border: 3px solid var(--line); border-radius: 22px; box-shadow: 0 6px 0 var(--line); padding: 14px 16px 12px; touch-action: pan-y; }
#pTitle { margin: 0 0 8px; font: 700 31px/1.02 var(--display); color: var(--accent); text-align: center; }
#pBody { font-size: 17px; line-height: 1.22; }
#pBody p { margin: 6px 0; }
#pBtns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
#pToast { margin: 6px 0 0; min-height: 1.2em; text-align: center; font-weight: 800; font-size: 15px; }
/* The result card stays clear of the hall. If it holds a lot, the middle scrolls and the buttons stay put. */
#panel.sheet .card { display: flex; flex-direction: column; overflow: hidden; }
#panel.sheet #pBody { flex: 0 1 auto; min-height: 42px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#panel.sheet #pBtns, #panel.sheet #pTitle { flex: none; }
#panel.sheet #pToast:empty { display: none; }
.stats3.with-couple { grid-template-columns: 54px repeat(3, 1fr); align-items: end; }
.couple { display: block; width: 54px; height: 48px; }
.btn { background: var(--card); border: 3px solid var(--line); border-radius: 15px; box-shadow: 0 3px 0 var(--line); padding: 9px 14px; min-height: 48px; font-weight: 800; flex: 1 1 42%; line-height: 1.05; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.btn.main { background: var(--accent); color: var(--on-accent); flex-basis: 100%; font-size: 19px; }
.btn.alt { background: var(--accent2); color: var(--line); }
.btn.hot { background: var(--accent); color: var(--on-accent); }
.note { font-size: 15px; opacity: .92; }
.rules { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.rule { margin: 0; text-align: center; font-size: 15px; line-height: 1.1; }
.rule canvas { display: block; width: 100%; height: auto; margin-bottom: 3px; }
.gest { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.keys { margin: 8px 0 0; font-size: 14px; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; }
.stats3 b { display: block; font: 800 30px/1 var(--body); font-variant-numeric: tabular-nums lining-nums; }
.stats3 span { font-size: 14px; }
.res-line { text-align: center; margin: 7px 0 0 !important; font-weight: 800; }
.res-note { text-align: center; font-size: 15px; margin: 6px 0 0 !important; }
.duel { color: var(--line); margin-top: 8px; border: 3px solid var(--line); border-radius: 14px; padding: 7px 10px; background: var(--mint); text-align: center; }
.duel.lose { background: var(--accent2); }
.duel b { display: block; font: 700 24px/1.08 var(--display); }
.duel small { font-size: 14px; display: block; font-variant-numeric: tabular-nums lining-nums; line-height: 1.2; }
.newlook { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 8px; font-weight: 800; }
.newlook canvas { width: 46px; height: 46px; }
.shareBox { width: 100%; height: 118px; font: 500 15px/1.25 var(--body); margin-top: 6px; border: 2px solid var(--line); border-radius: 10px; padding: 6px; background: #fff; color: #1e0a1e; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-weight: 800; font-size: 19px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .dow { text-align: center; font-size: 13px; opacity: .8; }
.day { color: #1e0a1e; min-height: 52px; background: #fff; border: 2px solid var(--line); border-radius: 10px; padding: 1px 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; font-weight: 800; font-size: 15px; line-height: 1.1; font-variant-numeric: lining-nums; overflow: hidden; }
.day svg { width: 26px; height: 24px; display: block; }
.day:disabled { opacity: .3; cursor: default; }
.day.done { background: var(--mint); }
.day.today { outline: 3px solid var(--accent); outline-offset: -1px; }
.day.blank { visibility: hidden; }
.tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-bottom: 8px; }
.tab { color: #1e0a1e; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 2px 0; min-height: 48px; display: flex; align-items: center; justify-content: center; }
.tab svg { width: 38px; height: 36px; display: block; }
.tab.sel { background: var(--accent2); border-width: 3px; }
.levels { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
.lvl { color: #1e0a1e; min-height: 50px; background: #fff; border: 2px solid var(--line); border-radius: 10px; padding: 1px 0; font-weight: 800; line-height: 1.05; font-size: 15px; font-variant-numeric: lining-nums; }
.lvl small { display: block; font-weight: 500; font-size: 12.5px; }
.lvl.done { background: var(--mint); }
.lvl.clean { background: var(--accent2); }
.looks-h { font: 700 24px/1 var(--display); margin: 10px 0 5px; }
.looks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.look { color: #1e0a1e; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 4px 3px; font-size: 13.5px; line-height: 1.05; display: flex; flex-direction: column; align-items: center; gap: 3px; overflow: hidden; min-height: 112px; }
.look canvas { width: 100%; max-width: 92px; height: auto; aspect-ratio: 1.4; border-radius: 8px; }
.look b { font-size: 14.5px; }
.look.sel { border-width: 3px; border-color: var(--accent); background: var(--mint); }
.look:disabled { cursor: default; background: #f1e8ea; }
.look:disabled canvas { filter: saturate(.7) opacity(.7); }
@media (prefers-reduced-motion: reduce) { .invite, #joke { transition: none; } #hintCount.bump { animation: none; } }
@media (max-height: 640px) { #hero { height: 74px; } #tagline { font-size: 16px; margin: 4px auto 7px; } .trio { margin-top: 12px; } .sq { min-height: 70px; font-size: 14.5px; } .sq svg { width: 30px; height: 30px; } .invite { padding: 11px 12px 10px; } .invite .row svg { width: 40px; height: 36px; } #byline { font-size: 13px; } }
@media (orientation: portrait) and (max-height: 700px) {
  #panel.sheet { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  #panel.sheet .card { padding: 7px 11px 8px; border-radius: 18px; box-shadow: 0 4px 0 var(--line); }
  #panel.sheet #pTitle { font-size: 24px; margin-bottom: 1px; }
  #panel.sheet #pBody { font-size: 15px; line-height: 1.12; }
  #panel.sheet .stats3 b { font-size: 23px; }
  #panel.sheet .stats3 span { font-size: 13px; line-height: 1; display: block; }
  #panel.sheet .res-line { margin: 3px 0 0 !important; font-size: 14.5px; }
  #panel.sheet .res-note { margin: 2px 0 0 !important; font-size: 13.5px; }
  #panel.sheet .newlook { margin-top: 2px; font-size: 14.5px; } #panel.sheet .newlook canvas { width: 30px; height: 30px; }
  #panel.sheet .duel { margin-top: 3px; padding: 3px 8px; } #panel.sheet .duel b { font-size: 19px; } #panel.sheet .duel small { font-size: 12.5px; }
  #panel.sheet .couple { width: 45px; height: 40px; } #panel.sheet .stats3.with-couple { grid-template-columns: 45px repeat(3, 1fr); }
  #panel.sheet #pBtns { margin-top: 5px; gap: 5px; }
  #panel.sheet .btn { min-height: 40px; padding: 3px 7px; font-size: 15px; box-shadow: 0 2px 0 var(--line); border-radius: 12px; }
  #panel.sheet .btn.main { font-size: 16px; }
  #panel.sheet #pBtns.many .btn:not(.main) { flex-basis: 30%; font-size: 14px; }
  #panel.sheet #pToast { margin-top: 3px; font-size: 14px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  #menu { flex-direction: row; gap: 18px; align-items: center; }
  #menu::before, #menu::after { display: none; }
  .menu-head { max-width: 40%; margin-left: auto; } .menu-actions { max-width: 52%; margin-right: auto; }
  #hero { height: 80px; } #title { font-size: 44px; } #tagline { font-size: 15px; margin-bottom: 0; }
  .invite { padding: 9px 10px; } .invite .row { margin-top: 3px; } .invite .row svg { width: 34px; height: 30px; } .invite .big { font-size: 26px; } .invite .date { font-size: 15px; margin: 0; }
  .trio { margin-top: 9px; } .sq { min-height: 48px; flex-direction: row; font-size: 14px; gap: 4px; } .sq svg { width: 24px; height: 24px; }
  #stats { margin: 5px 0 0; font-size: 15px; } #menuLinks { margin: 0; } .link { min-height: 30px; padding: 2px 6px; font-size: 15px; } #byline { display: none; }
  .card { max-width: 660px; }
  .rules { grid-template-columns: repeat(4, 1fr); }
  .looks { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .levels { grid-template-columns: repeat(10, minmax(0, 1fr)); }
  #panel.sheet { justify-content: flex-end; align-items: center; }
  #panel.sheet .card { max-width: min(380px, 52%); padding: 9px 12px; }
  #panel.sheet #pTitle { font-size: 24px; margin-bottom: 4px; } #panel.sheet .stats3 b { font-size: 23px; }
  #panel.sheet #pBtns { margin-top: 6px; gap: 5px; } #panel.sheet .btn { min-height: 38px; padding: 5px 8px; font-size: 15px; } #panel.sheet .btn.main { font-size: 16px; }
}
@media (min-width: 900px) and (orientation: landscape) and (min-height: 501px) {
  #panel.sheet { justify-content: flex-end; align-items: center; padding-right: 22px; }
  #panel.sheet .card { max-width: 340px; }
}
