* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: #0d0d0d;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow: hidden;
  position: fixed;
  inset: 0;
  width: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, a { font-family: inherit; }
button {
  background: #1a1a1a;
  border: 1px solid #333;
  color: #ccc;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
button:hover { background: #222; border-color: #555; color: #fff; }
button.primary { background: #1e2d40; border-color: #5b9bd5; color: #5b9bd5; }
button:disabled { opacity: 0.3; }
button:focus-visible, a:focus-visible { outline: 2px solid #5b9bd5; outline-offset: 2px; }
#app {
  position: relative;
  height: 100%;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: #0d0d0d;
  overflow: hidden;
}
canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto 44px 44px;
  grid-template-rows: auto auto;
  gap: 6px 8px;
  align-items: center;
  padding: calc(8px + env(safe-area-inset-top)) 10px 0;
  pointer-events: none;
}
#hud button, #hud a {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  text-decoration: none;
  font-size: 16px;
}
#readout { min-width: 0; }
#score {
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
#combo { color: #f0a040; font-weight: 700; font-size: 13px; min-height: 16px; }
#speed {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: #888;
}
#bars { grid-column: 1 / -1; display: grid; gap: 4px; }
.meter {
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 8px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: #888;
}
.meter b {
  display: block;
  height: 8px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 99px;
  overflow: hidden;
}
.meter i { display: block; height: 100%; width: 0; background: #5b9bd5; }
.meter.heat i { background: #9fd4ff; }
.panel {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 28px));
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 16px;
  padding: 22px 18px 18px;
  max-height: calc(100% - 28px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: auto;
}
#hint, #end {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0,0,0,0.72), rgba(0,0,0,0.15) 55%, rgba(0,0,0,0.05));
}
#hint .panel, #end .panel {
  position: relative;
  left: auto; top: auto; transform: none;
  width: min(420px, 100%);
  margin-bottom: 8px;
}
.hidden { display: none !important; }
.kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #5b9bd5;
  margin-bottom: 4px;
}
h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.04em; margin-bottom: 6px; }
h1 span { color: #5b9bd5; }
.sub { color: #888; font-size: 14px; line-height: 1.5; margin-bottom: 16px; }
a.games {
  color: #555;
  text-decoration: none;
  font-size: 14px;
  display: inline-block;
  margin-bottom: 14px;
}
a.games:hover { color: #aaa; }
.modes { display: grid; gap: 10px; }
.modes button {
  text-align: left;
  padding: 14px 14px 12px;
  border-radius: 12px;
  width: 100%;
}
.modes b { display: block; font-size: 16px; color: #fff; margin-bottom: 2px; }
.modes small { display: block; color: #888; font-size: 13px; line-height: 1.4; }
.modes .best {
  float: right;
  color: #5b9bd5;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
}
.keys { margin-top: 12px; color: #666; font-size: 12px; }
#how, #menu-mute, #tilt {
  margin-top: 12px;
  width: 100%;
  padding: 8px 12px;
}
#tilt-note { min-height: 0; margin-top: 8px; }
#tilt-note:empty { display: none; }
#hud #tilt-cal {
  position: static;
  grid-column: 1 / -1;
  justify-self: end;
  width: auto;
  min-width: 44px;
  height: 28px;
  margin: 0;
  padding: 0 10px;
  font-size: 12px;
  pointer-events: auto;
}
#hint p, #end p { color: #ccc; font-size: 14px; line-height: 1.45; margin: 8px 0; }
#hint h2, #end h2 { font-size: 22px; letter-spacing: -0.03em; }
#hint .go, #end .row button { margin-top: 8px; }
#hint .go, #end-retry {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  font-weight: 700;
  border-radius: 10px;
}
.end-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.end-row button { padding: 12px 10px; font-size: 15px; border-radius: 10px; }
#end-score { font-size: 28px; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }
#end-detail { color: #888; }
.stars { color: #f0a040; letter-spacing: 2px; font-size: 18px; }
