@font-face { font-family: 'Tower Puff'; src: url('./assets/fonts/display.woff2') format('woff2'); font-weight: 400 700; font-display: swap; }
@font-face { font-family: 'Tower Text'; src: url('./assets/fonts/text.woff2') format('woff2'); font-weight: 200 1000; font-display: swap; }
@font-face { font-family: 'Tower Arabic'; src: url('./assets/fonts/arabic.woff2') format('woff2'); font-weight: 400 800; font-display: swap; }
@font-face { font-family: 'Tower Japanese'; src: url('./assets/fonts/japanese.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --ink: #604a40; --muted: #786153; --paper: #fff9ed; --line: #957562;
  --apricot: #f3cca3; --apricot-edge: #b58a68; --mint: #dce8d1;
  --display-font: 'Tower Puff', 'Tower Japanese', 'Tower Arabic', sans-serif;
  --text-font: 'Tower Text', 'Tower Japanese', 'Tower Arabic', sans-serif;
  color-scheme: light; font-family: var(--text-font); font-weight: 650;
  color: var(--ink); background: var(--paper); font-synthesis: none;
}
:root:lang(ja) { --display-font: 'Tower Japanese', sans-serif; --text-font: 'Tower Japanese', sans-serif; }
:root:lang(ar) { --display-font: 'Tower Arabic', sans-serif; --text-font: 'Tower Arabic', sans-serif; }
* { box-sizing: border-box; }
body { margin: 0; background-image: radial-gradient(#bc997d16 .8px, transparent .8px); background-size: 13px 13px; }
/* The play canvas is clickable too: suppress the browser's touch overlay. */
button, select, canvas { -webkit-tap-highlight-color: transparent; }
button, select { font: inherit; min-height: 48px; }
button:focus-visible, select:focus-visible, canvas:focus-visible { outline: 3px solid #4f806b; outline-offset: 4px; }
.game {
  max-width: 800px; min-height: 100vh; height: 100vh; min-height: 100svh; height: 100dvh; margin: auto;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: grid; grid-template-rows: auto auto minmax(220px, 1fr); gap: 9px;
}
.header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; min-height: 48px; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1 1 155px; min-width: 0; }
.brand-mark { width: 34px; height: 40px; flex: 0 0 34px; transform: rotate(-5deg); }
h1 { font: 600 clamp(1.2rem, 3.5vw, 1.6rem)/1.22 var(--display-font); margin: 0; text-wrap: balance; }
.preferences { flex: 0 0 auto; max-width: 100%; }
select {
  color: var(--ink); border: 1.5px solid #c6ac92; background-color: #fffdf6;
  border-radius: 10px 13px 9px 12px; padding: 7px 8px; max-width: 128px;
  font-size: .8125rem; font-weight: 750; cursor: pointer;
}
.hud { display: flex; align-items: center; justify-content: space-between; min-height: 43px; padding: 0 4px 3px; gap: 12px; }
.hud > div { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.hud span { font-size: .8125rem; color: var(--muted); font-weight: 750; }
.hud strong { font: 550 2rem/1.15 var(--display-font); font-variant-numeric: tabular-nums; unicode-bidi: isolate; }
.best-stat { position: relative; }
.best-stat::before { content: ''; width: 15px; height: 17px; align-self: center; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='m3 7 4 3 3-6 3 6 4-3-1 9H4Z' fill='%23f2d7a1' stroke='%23957562' stroke-width='1.4' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat; }
.stage { position: relative; min-height: 220px; border: 1.5px solid #b69b86; border-radius: 25px 29px 24px 28px; overflow: hidden; background: #eee7f1; }
canvas { width: 100%; height: 100%; display: block; touch-action: manipulation; cursor: pointer; }
.message { position: absolute; inset: 10% 18px auto; pointer-events: none; text-align: center; color: var(--ink); max-width: 440px; margin-inline: auto; }
.message h2 { font: 500 clamp(1.15rem, 4vw, 1.6rem)/1.35 var(--display-font); margin: 0 0 12px; text-wrap: balance; }
.message p { font-size: .9375rem; line-height: 1.55; max-width: 360px; margin: 7px auto; text-wrap: pretty; }
.message .detail { font-size: .8125rem; color: var(--muted); max-width: 330px; }
.pause-message { position: absolute; inset: 0; align-content: center; text-align: center; color: var(--ink); background: #fff9ede8; font: 500 1.5rem var(--display-font); pointer-events: none; }
#intro {
  --dialog-bottom: clamp(24px, 14dvh, 140px);
  position: fixed; inset: auto 0 var(--dialog-bottom); margin: 0 auto;
  width: min(420px, calc(100% - 32px)); max-height: calc(100dvh - var(--dialog-bottom) - 24px); overflow: auto;
  padding: 24px; color: var(--ink); background: var(--paper);
  border: 2px solid var(--line); border-radius: 25px 29px 24px 28px;
  box-shadow: 0 7px 0 #bc997d, 0 20px 50px #604a4026; text-align: center;
}
#intro::backdrop { background: #604a4038; }
#prompt-fallback { position: absolute; inset: auto 20px max(24px, 10%) 20px; max-width: 360px; margin: auto; }
.dialog-heading { display: flex; align-items: center; gap: 12px; text-align: start; }
.dialog-heading h2 { flex: 1; min-width: 0; font: 500 1.35rem/1.35 var(--display-font); margin: 0; text-wrap: balance; }
.dialog-heading select { max-width: 112px; flex: 0 0 auto; }
#message-help { font-size: .9375rem; line-height: 1.6; margin: 20px 0 10px; }
#message-detail { font-size: .8125rem; line-height: 1.5; color: var(--muted); margin: 0 0 20px; }
#keyboard-hint { color: var(--muted); font-size: .75rem; line-height: 1.5; margin: 16px 0 0; }
:root[data-state='finished'] #message-help { margin-bottom: 24px; }
#action {
  position: relative; border: 2px solid #977056; border-radius: 20px 17px 22px 18px;
  padding: 14px 20px; min-height: 64px; width: 100%; max-width: 100%; margin-bottom: 5px;
  background: var(--apricot); color: #584236; box-shadow: 0 5px 0 var(--apricot-edge);
  font: 500 1.1875rem/1.3 var(--display-font); cursor: pointer; touch-action: manipulation;
  transition: transform 90ms ease-out, box-shadow 90ms ease-out;
}
#action::before { content: ''; display: inline-block; width: 23px; height: 23px; margin-inline-end: 12px; vertical-align: -.24em; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 26'%3E%3Cg fill='none' stroke='%23735644' stroke-width='1.65' stroke-linejoin='round'%3E%3Cpath d='m3 14 10-4 10 4v5l-10 4-10-4Zm0 0 10 4 10-4M13 18v5'/%3E%3Cpath d='m4 6 9-4 9 4-9 4Z' fill='%23fff0d2'/%3E%3C/g%3E%3C/svg%3E") center/contain no-repeat; }
#action:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--apricot-edge); }
#action:disabled { cursor: default; }
@media (hover: hover) { #action:hover:not(:disabled) { background: #f8d9b5; } }
h1, .message, dialog, button { overflow-wrap: anywhere; line-break: strict; }
:root[data-state='finished'] #action::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 26'%3E%3Cpath d='M6 9a8 8 0 1 1-1 7M6 3v6h6' fill='none' stroke='%23735644' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }
@media (max-height: 520px) and (min-width: 540px) {
  .game { max-width: 1000px; grid-template-columns: minmax(0, 1fr) 150px; grid-template-rows: auto minmax(190px, 1fr); }
  .header { grid-column: 1 / -1; }
  .stage { grid-column: 1; grid-row: 2; min-height: 190px; }
  .hud { grid-column: 2; grid-row: 2; align-self: center; flex-direction: column; gap: 16px; }
  #intro { --dialog-bottom: 20px; width: min(560px, calc(100% - 32px)); padding: 18px 24px; }
  #message-help { margin-top: 12px; }
  #message-detail { margin-bottom: 12px; }
  #keyboard-hint { margin-top: 10px; }
  .message { top: 8%; }
  .message .detail { display: none; }
}
@media (max-width: 539px) and (max-height: 680px) {
  .game { padding-top: 10px; gap: 7px; }
  .brand { gap: 6px; }
  .brand-mark { width: 27px; flex-basis: 27px; height: 34px; }
  h1 { font-size: 1.125rem; }
  .message { inset-block-start: 6%; }
  .message h2 { font-size: 1.125rem; margin-bottom: 8px; }
  .message p { font-size: .875rem; margin: 6px auto; }
  .message .detail { font-size: .75rem; }
  #intro { padding: 20px; --dialog-bottom: 28px; }
  .dialog-heading h2 { font-size: 1.125rem; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } #action { transition: none; } }
