:root {
  color-scheme: light;
  font-family: "Inter", system-ui, sans-serif;
  color: #392317;
  background: #e9d6b9;
  --accent: #9a441b;
  --muted: #72523c;
  --border: #c9a47e;
  --chrome: 118px;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  display: grid;
  place-items: center;
  padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
    max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  background:
    radial-gradient(ellipse at 35% 4%, #fff3dc 0, transparent 62%),
    repeating-linear-gradient(1deg, #97663f0b 0 1px, transparent 1px 6px, #fff6dc28 6px 8px),
    #e9d6b9;
}
button { font: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: wait; opacity: .6; }
button:focus-visible, canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.layout {
  width: min(560px, 100%, calc((100svh - var(--chrome) - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 504 / 631 + 16px));
  display: grid;
  gap: 7px;
}
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; height: 47px; }
h1 { margin: 0; font-size: clamp(18px, 5vw, 30px); letter-spacing: -.06em; font-weight: 850; }
h1 span { color: var(--accent); }
.scores { display: flex; gap: clamp(12px, 4vw, 32px); text-align: right; }
.score { min-width: 0; }
.score span { display: block; font-size: 9px; font-weight: 700; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.score strong { display: block; font-size: 24px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.score.current strong { color: var(--accent); }
.game-settings { display: flex; height: 38px; gap: 6px; }
.difficulty {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  flex: 1;
  min-width: 0;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #e2c49f;
}
.difficulty button, .icon-button { border-radius: 6px; color: #4d2e1e; font-size: 12px; font-weight: 700; }
.difficulty button { padding: 0 2px; background: transparent; border: 0; min-width: 0; }
.difficulty button:hover { background: #f0d7b6; }
.difficulty button[aria-pressed="true"] { background: #fff0d7; box-shadow: 0 1px 3px #57321730; }
.icon-button { width: 36px; flex-shrink: 0; font-size: 22px; background: #f8e5c7; border: 1px solid var(--border); }
#sound[aria-pressed="false"] { color: #72523c; text-decoration: line-through; background: #e2c49f; }
.play {
  min-width: 0;
  padding: 7px;
  background: linear-gradient(150deg, #f8e8d0, #e9cba5);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 14px 40px #58301526;
}
.game-surface { position: relative; }
#game { width: 100%; aspect-ratio: 504 / 631; touch-action: none; }
#game canvas { display: block; width: 100% !important; height: auto !important; touch-action: none; border-radius: 10px; }
.tray-label {
  position: absolute;
  top: 81.3%;
  left: 2px;
  right: 2px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: clamp(7px, 1.6vh, 10px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  pointer-events: none;
}
.end {
  position: absolute;
  inset: 0 0 auto;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #2f1c13e8;
}
[hidden] { display: none !important; }
.end-card { width: 90%; max-width: 310px; padding: clamp(10px, 3vw, 22px); text-align: center; background: #f5e6cf; border: 1px solid var(--border); border-radius: 15px; }
.end-card h2 { margin: 0; font-size: clamp(15px, 4vw, 22px); }
.end-card p { color: var(--muted); font-size: 12px; margin: 8px 0; }
.end-card button { display: block; width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 10px 6px; font-size: 13px; font-weight: 750; color: #4d2e1e; background: #ead3b0; }
.end-card #continue { background: var(--accent); color: #fff4df; border-color: var(--accent); }
.end-card .ad-status { min-height: 0; }
.end-card .ad-status:empty { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-height: 480px) {
  :root { --chrome: 92px; }
  .topbar { height: 30px; }
  h1 { font-size: 17px; }
  .score strong { font-size: 17px; }
  .score span { font-size: 8px; }
  .scores { gap: 12px; }
  .game-settings { height: 30px; gap: 3px; }
  .difficulty { padding: 1px; }
  .difficulty button { font-size: 9px; }
  .icon-button { width: 26px; font-size: 17px; }
  .layout { gap: 5px; }
  .end-card { padding: 8px; }
  .end-card h2 { font-size: 13px; }
  .end-card p { font-size: 9px; margin: 5px 0; }
  .end-card button { font-size: 10px; padding: 6px 2px; }
}
.menu-button { border: 1px solid var(--border); background: #f8e5c7; color: #4d2e1e; border-radius: 8px; font-size: 13px; font-weight: 700; padding: 0 13px; }
.current-mode { flex: 1; align-self: center; color: var(--muted); font-size: 12px; text-align: center; }
.menu {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: radial-gradient(ellipse at 25% 20%, #fff1d6, #e3c49d);
}
.menu-card { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: clamp(20px, 5vw, 60px); width: min(880px, 100%); }
.menu-art { width: 100%; height: auto; border-radius: 25%; box-shadow: 0 18px 40px #79502c23; }
.menu-content { min-width: 0; }
.menu-content h2 { margin: 0; font-size: clamp(36px, 6vw, 64px); letter-spacing: -.07em; }
.menu-content h2 span { color: var(--accent); }
.menu-tagline { color: var(--muted); margin: 5px 0 24px; font-size: 14px; }
.menu .difficulty { min-height: 42px; }
.menu-description { color: var(--muted); font-size: 13px; line-height: 1.4; min-height: 3em; margin: 12px 0; }
.menu-record { display: flex; align-items: center; justify-content: space-between; color: var(--muted); margin: 12px 0 20px; font-size: 13px; }
.menu-record strong { color: var(--accent); font-size: 28px; font-variant-numeric: tabular-nums; }
.primary-button { display: block; width: 100%; min-height: 46px; border: 1px solid #8f3e19; border-radius: 10px; color: #fff2db; background: linear-gradient(#af5c2c,#91401d); box-shadow: 0 3px 0 #6f3016; font-weight: 750; margin-top: 12px; }
#menu-resume:not([hidden]) + #menu-start { background: #eed6b0; color: #643b24; border-color: var(--border); box-shadow: none; }
.menu-sound { display: block; margin: 18px auto 0; background: transparent; color: var(--muted); border: 0; font-size: 13px; padding: 6px; }
#menu-status { color: var(--muted); font-size: 12px; text-align: center; min-height: 16px; margin: 10px 0 0; }
.end-card #end-menu { margin-top: 8px; }
@media (max-width: 600px) and (min-height: 501px) {
  .menu-card { grid-template-columns: 1fr; width: min(360px,100%); gap: 16px; }
  .menu-art { width: min(33svh, 180px); justify-self: center; }
  .menu-content h2, .menu-tagline { text-align: center; }
  .menu-tagline { margin-bottom: 16px; }
}
@media (max-height: 500px) {
  .menu-card { grid-template-columns: .8fr 1fr; max-width: 680px; gap: 24px; }
  .menu-art { max-height: 76svh; width: auto; max-width: 100%; justify-self: center; }
  .menu-content h2 { font-size: 30px; }
  .menu-tagline { font-size: 11px; margin: 4px 0 9px; }
  .menu-description { font-size: 11px; margin: 7px 0; }
  .menu-record { margin: 6px 0; }
  .menu-record strong { font-size: 21px; }
  .menu .difficulty { min-height: 32px; }
  .primary-button { min-height: 34px; margin-top: 8px; }
  .menu-sound { margin-top: 9px; }
  #menu-status { margin: 3px 0 0; }
}
@media (max-width: 600px) and (min-height: 501px) and (max-height: 680px) {
  .menu-art { width: min(17svh, 100px); }
  .menu-card { gap: 8px; }
  .menu-tagline { margin-bottom: 12px; }
}
