/* Fonts are bundled, SIL Open Font License: see fonts/OFL-Sniglet.txt */
@font-face { font-family: 'Sniglet'; font-weight: 400; src: url(fonts/sniglet-latin-400-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Sniglet'; font-weight: 800; src: url(fonts/sniglet-latin-800-normal.woff2) format('woff2'); font-display: swap; }

:root {
  --ink: #17134a; --night: #2b2158; --quilt: #2f2488; --quilt2: #1f3a80; --hem: #5a3fc0; --stitch: #aab2ff;
  --cream: #fff6dd; --butter: #ffe9a8; --gold: #ffc531; --rose: #ff6f91; --apricot: #ffb56f; --mint: #5ae6b5; --lilac: #e4ddff;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --font: Sniglet, 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, 'Noto Sans', sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--cream); font: 400 16px/1.4 var(--font); overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.icon { position: fixed; width: 44px; height: 44px; padding: 9px; background: transparent; border: 0; color: var(--cream); z-index: 6; touch-action: manipulation; }
.icon svg { width: 100%; height: 100%; display: block; fill: currentColor; }
#btnPause { top: calc(2px + var(--safe-t)); left: calc(2px + var(--safe-l)); }
#btnMute { top: calc(2px + var(--safe-t)); left: calc(46px + var(--safe-l)); }
#btnPause[hidden] + #btnMute { left: auto; right: calc(2px + var(--safe-r)); }
#btnMute .off { display: none; }
#btnMute.muted .off { display: inline; }
#btnMute.muted .on { display: none; }

/* A patch of fabric with a running stitch. Every control in the game is one of these. */
.btn { position: relative; display: block; width: 100%; padding: 11px 18px 12px; border: 2.5px solid var(--ink); border-radius: 13px; background: var(--quilt); color: var(--cream); text-align: left; box-shadow: 0 4px 0 var(--ink); touch-action: manipulation; }
.btn::after { content: ''; position: absolute; inset: 4px; border: 1.5px dashed var(--stitch); border-radius: 8px; opacity: .55; pointer-events: none; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn .t { display: block; font-weight: 800; font-size: 19px; line-height: 1.15; }
.btn .s { display: block; font-size: 14px; line-height: 1.25; opacity: .9; margin-top: 2px; }
.btn.big .t { font-size: clamp(19px, 2.6vh, 24px); }
.btn.butter { background: var(--butter); color: var(--ink); }
.btn.butter::after { border-color: #c98a2c; }
.btn.mint { background: var(--mint); color: var(--ink); }
.btn.mint::after { border-color: #157a5c; }
.btn.rose { background: var(--rose); color: var(--ink); }
.btn.rose::after { border-color: #93203f; }
.btn.small { padding: 8px 14px 9px; }
.btn.small .t { font-size: 16px; }
.link { background: none; border: 0; padding: 8px 6px; color: var(--cream); text-decoration: underline; text-decoration-style: dashed; text-underline-offset: 4px; touch-action: manipulation; }

/* Menu: the quilt plays by itself behind it */
#menu { position: fixed; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: calc(10px + var(--safe-t)) calc(16px + var(--safe-r)) calc(10px + var(--safe-b)) calc(16px + var(--safe-l)); z-index: 3; pointer-events: none; }
#menu > * { pointer-events: auto; }
.menu-head { text-align: center; pointer-events: none !important; }
#logo { display: block; margin: 0 auto; max-width: 100%; }
#tagline { margin: -4px auto 0; max-width: 40ch; font-weight: 400; font-size: clamp(15px, 2.2vh, 19px); line-height: 1.2; text-shadow: 0 2px 0 var(--ink), 0 0 10px var(--ink); }
.menu-actions { width: 100%; max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; gap: 9px; }
#menuLinks { margin: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 8px; text-shadow: 0 1px 2px var(--ink); }
#stats, #byline { margin: 0; text-align: center; font-size: 13.5px; line-height: 1.25; text-shadow: 0 1px 2px var(--ink); }
#byline { opacity: .85; font-size: 12.5px; }
@media (min-aspect-ratio: 11/10) {
  #menu { justify-content: center; width: min(44vw, 480px); left: 0; right: auto; gap: 14px; background: linear-gradient(90deg, rgba(23,19,74,.72) 72%, rgba(23,19,74,0)); padding-right: 34px; }
  .menu-head { text-align: left; }
  #tagline { margin-left: 8px; text-align: left; }
}
@media (min-aspect-ratio: 11/10) and (max-height: 520px) {
  #menu { width: min(62vw, 560px); justify-content: flex-start; overflow-y: auto; gap: 6px; }
  .menu-actions { gap: 6px; max-width: none; }
  .btn.big { padding: 6px 14px 7px; }
  .btn .s { font-size: 12.5px; }
  #tagline { font-size: 13px; }
}

/* HUD pieces in the DOM */
#banner { position: fixed; left: 50%; top: var(--banner-y, 40%); transform: translate(-50%, -50%); z-index: 4; width: max-content; max-width: min(92vw, 560px); padding: 10px 22px 12px; text-align: center; background: var(--cream); color: var(--ink); border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 5px 0 var(--ink); pointer-events: none; }
#bannerMain { font-weight: 800; font-size: clamp(22px, 4vmin, 34px); line-height: 1.1; }
#bannerSub { font-size: clamp(14px, 2.3vmin, 18px); line-height: 1.25; margin-top: 3px; }
#bannerSub:empty { display: none; }
#hint { position: fixed; left: 50%; transform: translateX(-50%); top: var(--hint-y, 62%); z-index: 4; width: max-content; max-width: min(92vw, 520px); padding: 6px 14px 7px; font-size: 15px; line-height: 1.25; text-align: center; color: var(--cream); background: var(--ink); border: 1.5px dashed var(--stitch); border-radius: 10px; pointer-events: none; }
.chip { background: var(--cream); color: var(--ink); border: 2.5px solid var(--ink); border-radius: 12px; font-weight: 800; padding: 6px 14px 7px; box-shadow: 0 3px 0 var(--ink); touch-action: manipulation; }
#btnSkip { position: fixed; z-index: 5; left: 50%; transform: translateX(-50%); top: var(--skip-y, 8px); white-space: nowrap; }

/* Touch controls: a cross of fabric. Where your thumb is relative to the middle is the direction. */
.pad, .drop { position: fixed; z-index: 2; touch-action: none; }
.pad { border-radius: 50%; background: rgba(90, 63, 192, .3); border: 2.5px dashed rgba(170, 178, 255, .6); }
.pad .arr { position: absolute; width: 0; height: 0; border: 11px solid transparent; pointer-events: none; opacity: .85; }
.pad .u { left: 50%; top: 8%; margin-left: -11px; border-bottom: 16px solid var(--cream); border-top: 0; }
.pad .d { left: 50%; bottom: 8%; margin-left: -11px; border-top: 16px solid var(--cream); border-bottom: 0; }
.pad .l { top: 50%; left: 8%; margin-top: -11px; border-right: 16px solid var(--cream); border-left: 0; }
.pad .r { top: 50%; right: 8%; margin-top: -11px; border-left: 16px solid var(--cream); border-right: 0; }
.pad .arr.lit { opacity: 1; filter: drop-shadow(0 0 4px var(--gold)); }
.pad.a { background: rgba(255, 138, 112, .22); }
.pad.b { background: rgba(90, 230, 181, .2); }
.drop { display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--butter); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); }
.drop svg { display: block; width: 68%; height: 68%; pointer-events: none; }
.drop.flip svg { transform: rotate(180deg); }
.drop.down { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); background: var(--gold); }

/* Panels */
#panel { position: fixed; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center; padding: calc(8px + var(--safe-t)) calc(8px + var(--safe-r)) calc(8px + var(--safe-b)) calc(8px + var(--safe-l)); background: rgba(23, 19, 74, .68); }
.card { position: relative; width: 100%; max-width: 480px; max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 16px 14px; background: var(--quilt); border: 3px solid var(--ink); border-radius: 18px; box-shadow: 0 6px 0 var(--ink); outline: 2px dashed var(--stitch); outline-offset: -8px; }
.card.wide { max-width: 680px; }
#pTitle { margin: 4px 8px 8px; font-weight: 800; font-size: clamp(23px, 4.6vmin, 32px); line-height: 1.1; color: var(--butter); }
#pBody { margin: 0 8px; font-size: 16px; }
#pBody p { margin: 6px 0; }
#pBtns { display: flex; flex-direction: column; gap: 8px; margin: 12px 8px 4px; }
#pBtns.row { flex-direction: row; flex-wrap: wrap; }
#pBtns.row .btn { flex: 1 1 42%; width: auto; }
#pToast { margin: 6px 8px 2px; font-size: 14px; min-height: 0; }
#pToast:empty { display: none; }
.big-score { font-weight: 800; font-size: clamp(38px, 9vmin, 58px); line-height: 1; color: var(--gold); margin: 4px 0; }
.tally { display: grid; grid-template-columns: repeat(auto-fit, minmax(66px, 1fr)); gap: 6px; margin: 8px 0; }
.tally div { padding: 4px 6px 6px; border-radius: 10px; text-align: center; color: var(--ink); border: 2.5px solid var(--ink); }
.tally b { display: block; font-size: 26px; line-height: 1; }
.tally small { display: block; font-size: 12.5px; line-height: 1.1; }
.tally .champ { outline: 3px solid var(--gold); outline-offset: 1px; }
.score-rows { margin: 6px 0; display: grid; grid-template-columns: 1fr auto; gap: 1px 14px; font-size: 15px; }
.score-rows span:nth-child(2n) { text-align: right; font-weight: 800; }
.share-box { width: 100%; height: 88px; margin-top: 6px; font: inherit; font-size: 14px; color: var(--ink); background: var(--cream); border: 2px solid var(--ink); border-radius: 8px; -webkit-user-select: text; user-select: text; }

/* Lobby */
.seats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 7px; margin: 4px 0 10px; }
.seat { display: flex; align-items: center; gap: 8px; min-height: 60px; padding: 5px 10px 5px 6px; text-align: left; background: var(--night); color: var(--cream); border: 2.5px solid var(--ink); border-radius: 12px; touch-action: manipulation; }
.seat canvas { flex: 0 0 44px; width: 44px; height: 50px; }
.seat b { display: block; font-weight: 800; font-size: 16px; line-height: 1.1; }
.seat small { display: block; font-size: 13px; line-height: 1.15; opacity: .92; }
.seat.human { background: var(--cream); color: var(--ink); }
.seat.off { opacity: .55; border-style: dashed; }
.opt { margin: 8px 0; }
.opt > span { display: block; font-size: 14.5px; margin-bottom: 3px; }
.seg { display: flex; flex-wrap: wrap; gap: 5px; }
.seg button { flex: 1 1 auto; min-height: 40px; padding: 5px 10px 6px; background: var(--night); color: var(--cream); border: 2.5px solid var(--ink); border-radius: 10px; font-size: 14.5px; line-height: 1.1; touch-action: manipulation; }
.seg button[aria-pressed=true] { background: var(--butter); color: var(--ink); font-weight: 800; }
.note { font-size: 13.5px; line-height: 1.25; opacity: .9; }

/* How to and wardrobe */
.how { list-style: none; padding: 0; margin: 4px 0; }
.how li { display: flex; gap: 10px; align-items: center; margin: 7px 0; font-size: 15px; line-height: 1.25; }
.how canvas { flex: 0 0 40px; width: 40px; height: 40px; }
.how b { font-weight: 800; }
.keys { width: 100%; border-collapse: collapse; font-size: 14px; margin: 4px 0; }
.keys td, .keys th { padding: 2px 6px 2px 0; text-align: left; vertical-align: top; font-weight: 400; }
.keys th { font-weight: 800; white-space: nowrap; }
.wardrobe h3 { margin: 10px 0 4px; font-weight: 800; font-size: 17px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.tile { padding: 4px 4px 6px; background: var(--night); color: var(--cream); border: 2.5px solid var(--ink); border-radius: 10px; text-align: center; font-size: 13px; line-height: 1.12; touch-action: manipulation; }
.tile canvas { display: block; margin: 0 auto 2px; width: 56px; height: 56px; }
.tile.on { background: var(--butter); color: var(--ink); font-weight: 800; }
.tile.locked canvas { opacity: .35; filter: grayscale(.8); }
.tile small { display: block; font-size: 12px; margin-top: 1px; }
