:root {
  color-scheme: light;
  --paper: #f7e9c5;
  --ink: #351c1a;
  --cream: #fff1cc;
  --clay: #693326;
  --lime: #e2ee95;
  --amber: #ffdc8c;
  --heading: Georgia, "Times New Roman", serif;
  --gutter: clamp(8px, 2.15vw, 42px);
}
* { box-sizing: border-box }
[hidden] { display: none !important }
body {
  margin: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 system-ui, sans-serif;
}
a { color: inherit; text-underline-offset: 0.19em }
:focus-visible { outline: 3px solid #fff4d1; box-shadow: 0 0 0 5px #642d29; outline-offset: 2px }
.sitebar {
  width: min(1740px, calc(100% - var(--gutter) * 2));
  height: 62px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.sitebar a { font-size: 0.9rem; font-weight: 720; line-height: 1.15 }
.sitebar-links { display: flex; align-items: center; gap: clamp(8px, 2vw, 22px) }
.sitebar .wordmark {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  font: bold 1.32rem/1 var(--heading);
  letter-spacing: -0.035em;
  text-decoration: none;
}
.wordmark img { display: block }
#game {
  --dock: 80px;
  position: relative;
  width: min(1740px, calc(100% - var(--gutter) * 2));
  height: 83dvh;
  min-height: 290px;
  margin: auto;
  overflow: hidden;
  isolation: isolate;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  border: 1px solid #532a21;
  border-radius: 12px 12px 9px 9px;
  background: #763c2e;
  color: var(--cream);
  box-shadow: 0 4px 0 #5c3025, 0 14px 20px #59331d24;
}
#game:focus { outline: none; box-shadow: 0 4px 0 #5c3025, 0 14px 20px #59331d24 }
canvas { width: 100%; height: 100%; position: absolute; inset: 0; pointer-events: none }
button, select { font: inherit }
button {
  min-height: 46px;
  min-width: 46px;
  padding: 0.45em 0.86em;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.12;
  font-weight: 760;
  color: inherit;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px 11px }
.primary, .secondary { min-height: 49px; padding: 0.62em 1.12em }
.primary {
  color: var(--ink);
  border-color: #3b2e20;
  background: var(--lime);
  box-shadow: 0 3px 0 #32231e;
}
.primary:hover { background: #eff9b1 }
.secondary { color: var(--cream); border-color: #f0c989b5; background: #3e201b8c }
.secondary:hover { background: #713e2e }
.primary:active, .secondary:active { transform: translateY(2px); box-shadow: none }
.less-motion .primary:active, .less-motion .secondary:active { transform: none }
#menu {
  position: absolute;
  inset: auto auto 15% 7.3%;
  max-width: 88%;
}
#menu h1 {
  margin: 0;
  color: #ffedb9;
  font: 900 clamp(5.1rem, 11vw, 11.6rem)/0.78 var(--heading);
  letter-spacing: -0.088em;
  text-shadow: 0 3px #8e4333;
}
.cover-subtitle { display: block; font-size: 0.42em; line-height: 1.05; letter-spacing: -0.035em; margin-top: 0.28em }
.cover-subtitle:empty { display: none }
#menu p { margin: 0.95em 0 1.14em; color: var(--cream); font-size: clamp(1rem, 1.4vw, 1.37rem); font-weight: 680 }
#menu .primary { min-width: 112px }
.hud { position: absolute; inset: 14px 14px auto; display: flex; align-items: flex-start; justify-content: space-between; pointer-events: none }
.hud button { pointer-events: auto }
.tool {
  margin-inline-start: auto;
  display: inline-grid;
  place-items: center;
  background: #3e211ee8;
  border: 1px solid #edc990a9;
  box-shadow: 0 2px 0 #321a1b;
}
.tool:hover { background: #713e2e }
.tool svg { pointer-events: none }
.counters { display: flex; gap: 6px; font-variant-numeric: tabular-nums }
.counter {
  min-width: 76px;
  height: 46px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid #ecbd837c;
  border-radius: 5px;
  background: #3e211eea;
  font-size: 1.08rem;
  font-weight: 850;
  line-height: 1.05;
}
.counter small { display: block; margin-bottom: 3px; font-size: 0.67rem; font-weight: 740; color: #ffe5b2 }
.counter.clock { min-width: 82px }
.warmup .counter { border-color: #efcf83bd }
.warmup .counter.clock { background: #664126 }
.clock.urgent { border-color: #ffbe72 }
.carrot-mark, .bell-mark { display: inline-block; flex: none; width: 20px; height: 20px; position: relative }
.carrot-mark::before {
  content: "";
  position: absolute;
  inset: 6px 6px 0 4px;
  background: #ffab58;
  border-radius: 4px 4px 8px 8px;
  clip-path: polygon(0 0, 100% 0, 73% 80%, 35% 100%);
  transform: rotate(29deg);
}
.carrot-mark::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 3px;
  width: 9px;
  height: 6px;
  transform: rotate(-31deg);
  border-radius: 80% 10%;
  background: var(--lime);
}
.bell-mark::before { content: ""; position: absolute; inset: 3px 4px 6px; border-radius: 7px 7px 2px 2px; background: #ffcf81 }
.bell-mark::after { content: ""; position: absolute; inset: 15px 7px 2px; border-radius: 0 0 6px 6px; background: #ffcf81 }
.lesson, .notice {
  position: absolute;
  inset: 14px auto auto 50%;
  width: max-content;
  max-width: calc(100% - 250px);
  transform: translateX(-50%);
  text-align: center;
  margin: 0;
  padding: 0.48rem 0.85rem;
  border: 1px solid #ffdb8d9c;
  border-radius: 6px;
  background: #422320eb;
  font-size: 0.91rem;
  font-weight: 700;
  pointer-events: none;
}
.notice { z-index: 1; border-color: #ffdc92; color: #fff0c1 }
#pads {
  position: absolute;
  inset: auto 0 0;
  padding: 6px 13px 10px;
  min-height: var(--dock);
  display: flex;
  align-items: end;
  justify-content: center;
  gap: clamp(7px, 4vw, 35px);
  pointer-events: none;
}
#pads.quiet { visibility: hidden }
.pad { display: flex; gap: 6px; pointer-events: auto; --pad-size: 56px }
.pad[data-size="0"] { --pad-size: 46px }
.pad[data-size="2"] { --pad-size: 62px }
.pad button {
  display: grid;
  place-items: center;
  width: var(--pad-size);
  height: var(--pad-size);
  padding: 0;
  color: var(--cream);
  border: 1px solid #f8d59cad;
  background: #3c211fe8;
  box-shadow: 0 3px 0 #321b1c;
}
.pad-two button { border-color: #d3eba4bd }
.pad button[data-move=jump] { color: var(--ink); background: #ffcc78 }
.pad-two button[data-move=jump] { background: #d6e99f }
.pad button.pressed { color: var(--ink); background: var(--lime); box-shadow: inset 0 2px 0 #32231e53 }
.arrow { width: 12px; height: 12px; border: solid currentColor; border-width: 0 3px 3px 0; pointer-events: none }
.arrow.left { transform: rotate(135deg) }
.arrow.right { transform: rotate(-45deg) }
.arrow.up { transform: rotate(225deg) translate(-2px, -2px) }
.overlay { position: absolute; inset: 0; z-index: 2 }
.pause-overlay, .settings-overlay { display: grid; place-items: center; padding: 12px; background: #371c1c90 }
.pause-card, .settings-card {
  color: var(--cream);
  background: #45251f;
  border: 1px solid #e8ba81;
  border-radius: 10px;
  box-shadow: 0 8px 0 #31191a88;
}
.pause-card { max-width: 100%; padding: 20px clamp(14px, 4vw, 35px) }
.overlay h2 { font: bold clamp(2.4rem, 5vw, 4.1rem)/0.94 var(--heading); letter-spacing: -0.065em; margin: 0 0 0.4em }
.pause-card .setting-switches { margin-top: 16px }
.result-overlay {
  inset: auto 0 0;
  min-height: var(--dock);
  display: grid;
  align-items: center;
  padding: 5px clamp(8px, 2vw, 26px) 7px;
  pointer-events: none;
}
.result-card {
  width: min(100%, 820px);
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px 16px;
  pointer-events: auto;
  padding: 6px clamp(9px, 2vw, 18px);
  border: 1px solid #d5a367;
  border-top: 2px solid #edc892;
  background: #40211e;
  box-shadow: 0 3px 0 #321c1baa;
  border-radius: 7px;
}
.result-overlay[data-outcome="record"] .result-card { border-top-color: var(--lime) }
.result-overlay[data-outcome="record"] #result-note { color: var(--lime) }
.result-card h2 { margin: 0; font-size: clamp(1.38rem, 3vw, 2rem); letter-spacing: -0.035em }
.result-stats { display: flex; gap: 5px; margin-top: 2px; color: #ffe2aa; font-size: 0.89rem; font-weight: 710 }
.result-stats p { margin: 0 }
#result-note::before { content: "·"; padding-right: 5px }
.result-card .actions { flex-shrink: 0; gap: 6px }
.result-card button { padding-inline: 0.85em; min-height: 44px }
.settings-card { width: min(100%, 544px); max-height: 100%; overflow: auto; padding: clamp(13px, 2.5vw, 23px) }
.settings-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 13px }
.settings-heading h2 { margin: 0 }
.setting-switches { display: flex; flex-wrap: wrap; gap: 5px }
.setting-switches button, .key-row button, .padbind {
  border: 1px solid #dcb987a9;
  background: #38201d;
  font-size: 0.86rem;
}
.setting-switches button[aria-pressed=true], button.listening { background: var(--lime); color: var(--ink) }
.settings-card button, .settings-card select { min-height: 44px }
.bindings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 14px }
.bindings fieldset { display: grid; gap: 6px; margin: 0; padding: 7px; border: 1px solid #b68b65; border-radius: 5px; min-width: 0 }
.bindings legend { font-weight: 720; font-size: 0.9rem }
.bindings label { display: flex; flex-direction: column; font-size: 0.86rem; font-weight: 720 }
.bindings select { width: 100%; margin-top: 3px; padding-inline: 5px; border: 1px solid #dcb987a9; border-radius: 5px; color: var(--cream); background: #38201d }
.key-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px }
.key-row button { min-width: 0; padding: 0 2px; overflow: hidden; text-overflow: ellipsis }
#bind-hint { margin: 9px 0; font-size: 0.85rem }
.reset { min-height: 44px; font-size: 0.86rem }

.reading { max-width: 980px; margin: clamp(50px, 8vw, 115px) auto; padding: 0 max(18px, 4vw) }
.reading h1, .reading h2, .reading h3 { font-family: var(--heading); line-height: 1.08; letter-spacing: -0.04em }
.reading h1 { margin: 0 0 20px; font-size: clamp(2.7rem, 6vw, 5rem) }
.reading h2 { margin: 1.25em 0 0.38em; font-size: clamp(1.7rem, 3.4vw, 2.8rem) }
.reading h3 { font-size: 1.25rem }
.reading p, .reading li, .reading dd { max-width: 69ch; line-height: 1.65 }
.reading .lead { font-size: 1.12rem }
.reading hr { border: 0; border-top: 1px solid #b48b69; margin: 30px 0 }
.reading dt { font-weight: 770; margin-top: 0.8em }
.reading dd { margin: 0.18em 0 0 }
.reading li + li { margin-top: 0.44em }
.reading kbd { font: 700 0.88em system-ui, sans-serif; border: 1px solid #af8560; border-radius: 3px; padding: 0.04em 0.29em; white-space: nowrap }
.about-frame { display: block; width: 100%; height: auto; margin: 30px 0; border: 1px solid #693326; border-radius: 7px }
.sitefoot {
  width: min(1740px, calc(100% - var(--gutter) * 2));
  margin: 35px auto 0;
  border-top: 1px solid #b48b69;
  padding: 18px 0 26px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 25px;
  font-size: 0.92rem;
}
.sitefoot .language-links { flex-basis: 100% }
.language-links, .footer-pages { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 18px }
.language-links a[aria-current="page"] { font-weight: 770; text-decoration-thickness: 2px }
.footer-pages span:empty { display: none }

@media (max-width: 700px) {
  .sitebar { height: 52px }
  .sitebar .wordmark { gap: 5px }
  #game { height: 84dvh; border-radius: 8px }
  .hud { inset: 10px 10px auto }
  .lesson, .notice { inset: 63px auto auto 50%; max-width: calc(100% - 28px); font-size: 0.83rem }
  #menu { inset: 55px auto auto 6%; max-width: 92% }
  #menu h1 { font-size: clamp(2.55rem, 15.4vw, 6.4rem); line-height: 0.86; white-space: nowrap }
  #menu p { margin: 10px 0 12px; line-height: 1.3 }
  .cover-break { display: none }
  .result-card button { padding-inline: 0.65em; font-size: 0.9rem }
  #pads.duo { padding-inline: 7px; justify-content: space-between; gap: 5px }
  #pads.duo .pad { gap: 3px; flex: 0 1 auto; min-width: 138px; --pad-size: 48px }
  #pads.duo .pad[data-size="0"] { --pad-size: 44px }
  #pads.duo .pad[data-size="2"] { --pad-size: 56px }
  #pads.duo .pad button { min-width: 44px }
}

@media (max-width: 700px) and (orientation: portrait) {
  #game { --dock: 116px }
  #pads:not(.duo) .pad {
    display: grid;
    grid-template-columns: repeat(3, var(--pad-size));
    grid-template-rows: 34px var(--pad-size);
    gap: 0 7px;
    padding-bottom: 0;
  }
  #pads:not(.duo) button[data-move="left"] { grid-area: 2 / 1 }
  #pads:not(.duo) button[data-move="right"] { grid-area: 2 / 3 }
  #pads:not(.duo) button[data-move="jump"] { grid-area: 1 / 2 }
  .result-card { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: start; padding: 4px 9px }
  .result-copy { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 10px }
  .result-card .actions { width: 100% }
  .result-card .primary { flex: 1 }
}

@media (min-width: 701px) and (max-width: 900px) and (orientation: portrait) {
  #menu { inset: 9% auto auto 7% }
  #menu h1 { font-size: clamp(4.5rem, 12vw, 7rem); white-space: nowrap }
  .cover-break { display: none }
}

@media (max-height: 490px) and (orientation: landscape) {
  .sitebar { height: 46px }
  #game { height: 83dvh; min-height: 246px }
  #menu { inset: auto auto 12% 6%; }
  #menu h1 { font-size: clamp(3.7rem, 10.1dvh, 5.2rem) }
  .cover-break { display: none }
  #menu p { margin: 10px 0 }
  #pads.duo { justify-content: space-between }
  .lesson, .notice { font-size: 0.79rem; inset: 15px auto auto 50% }
}

@media (max-width: 390px) {
  .sitebar { gap: 8px }
  .sitebar .wordmark { font-size: 1.18rem; white-space: nowrap }
  .sitebar-links a { font-size: 0.85rem }
  #menu .actions { gap: 8px }
  #menu .primary { min-width: 95px }
  .settings-card { padding-inline: 9px }
  .setting-switches button { padding-inline: 0.52em }
  .settings-heading h2 { font-size: clamp(1.55rem, 7.3vw, 2.4rem); overflow-wrap: anywhere }
}

@media (prefers-reduced-motion: reduce) {
  .primary:active, .secondary:active, .pad button.pressed { transform: none }
}
