:root {
  font-family: system-ui, -apple-system, 'Hiragino Kaku Gothic ProN', sans-serif;
  color: #2a2328;
  background: #fff;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; -webkit-tap-highlight-color: transparent; }
button {
  font: inherit;
  color: inherit;
  background: #f3f4f6;
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  padding: 8px 14px;
  touch-action: manipulation;
}
button:disabled { opacity: .45; }
[hidden] { display: none !important; }
.shell {
  height: calc(100dvh - 52px);
  min-height: 500px;
  max-width: 450px;
  margin: auto;
  padding: 4px 12px max(8px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
.field {
  flex: 1;
  min-height: 360px;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.hud {
  position: absolute;
  inset: 0 0 auto;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 6px;
  z-index: 2;
  background: #fff;
  gap: 12px;
}
.hud strong { display: block; font-size: 15px; }
.hud small { display: block; font-size: 11px; margin-top: 2px; }
.hud button { width: 44px; padding: 0; font-weight: 700; font-size: 18px; }
.hud #time.urgent { color: #a23e4c; }
.course {
  position: absolute;
  inset: 54px 0 0;
  overflow: hidden;
  border-radius: 6px;
  touch-action: none;
  user-select: none;
  background: #c5d8b2;
}
#world { position: absolute; inset: 0; }
.lane {
  position: absolute;
  left: 0;
  width: 100%;
  height: var(--row-height);
  overflow: hidden;
}
.lane.grass { background: #c5d8b2; }
.lane.road { background: #777d86; border-block: 2px solid #a6adb2; }
.lane.road::before {
  content: '';
  position: absolute;
  inset: 50% 0 auto;
  border-top: 2px dashed #d9d7c6;
}
.lane.river { background: #9ccdd7; border-block: 2px solid #b3dce2; }
.object { position: absolute; top: 15%; height: 70%; border-radius: 6px; }
.car { background: #efb19b; border: 2px solid #a87165; min-height: 28px; }
.car.blue { background: #b1d0dd; border-color: #6a8999; }
.car::before {
  content: '';
  position: absolute;
  inset: 8% 25%;
  background: #e1eded;
  border: 3px solid #ffffffaa;
  border-radius: 3px;
}
.car::after {
  content: '';
  position: absolute;
  inset: -5px 16%;
  background:
    linear-gradient(#343e48, #343e48) left top / 9px 5px,
    linear-gradient(#343e48, #343e48) right top / 9px 5px,
    linear-gradient(#343e48, #343e48) left bottom / 9px 5px,
    linear-gradient(#343e48, #343e48) right bottom / 9px 5px;
  background-repeat: no-repeat;
}
.log { background: #b48c62; border: 2px solid #876744; border-radius: 12px; }
.log::after {
  content: '';
  position: absolute;
  inset: 5px auto 5px 5px;
  width: 10px;
  border-left: 2px solid #e1bd8e;
  border-radius: 50%;
}
.log-art-ready .log {
  background: transparent var(--log-art) center / 100% 100% no-repeat;
  border: 0;
  border-radius: 0;
}
.log-art-ready .log::after { display: none; }
.lane-label {
  position: absolute;
  left: 5px;
  bottom: 3px;
  padding: 1px 4px;
  border-radius: 3px;
  background: #ffffffed;
  color: #414c49;
  font-size: 10px;
  z-index: 1;
}
.lane.current .lane-label { font-weight: 700; }
.goal { display: flex; align-items: center; justify-content: center; gap: 8px; }
.goal img { width: 52px; height: 52px; object-fit: contain; }
.goal b { font-size: 12px; }
.player { position: absolute; width: 38px; height: 43px; left: 0; top: 0; z-index: 2; pointer-events: none; }
.player::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 9px;
  top: 0;
  border-radius: 50%;
  background: #f7d8b8;
  border-top: 7px solid #594b45;
}
.player i {
  position: absolute;
  top: 19px;
  left: 7px;
  width: 24px;
  height: 20px;
  background: #f5f2e7;
  border-radius: 8px 8px 4px 4px;
  border: 2px solid #ba947a;
}
.player i::after { content: ''; position: absolute; right: -4px; top: 3px; width: 9px; height: 12px; background: #d28f79; border-radius: 3px; }
.player span { position: absolute; top: 40px; left: 0; right: 0; text-align: center; background: #fff; border-radius: 3px; font-size: 9px; font-weight: 700; }
.player.grace { opacity: .5; }
.toast { position: absolute; top: 8px; left: 0; right: 0; min-height: 24px; text-align: center; pointer-events: none; color: #283e39; font-size: 12px; font-weight: 700; }
.toast:not(:empty) { background: #fffffff2; margin: 0 32px; border-radius: 6px; padding: 5px; }
.panel {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: #fff;
  padding: 16px;
  text-align: center;
  gap: 12px;
  overflow: auto;
}
.panel > img { object-fit: contain; flex-shrink: 0; }
.panel h2 { font-size: 20px; margin: 0; }
.panel p { font-size: 13px; line-height: 1.7; margin: 0; }
.panel .eyebrow { font-size: 12px; color: #6e626a; }
.panel button { width: 100%; max-width: 310px; font-weight: 700; margin-top: 4px; }
.panel #best { color: #6e626a; font-size: 12px; }
.rules p + p { margin-top: 6px; }
.instruction { font-size: 12px; text-align: center; margin: 8px 0 4px; }
.companion { display: flex; align-items: center; gap: 8px; min-height: 56px; }
.companion img { width: 52px; height: 52px; object-fit: contain; flex-shrink: 0; }
.companion b { font-size: 11px; color: #6e626a; }
.companion p { font-size: 13px; line-height: 1.5; margin: 3px 0; }
#save-note { font-size: 11px; color: #6e626a; margin: 4px 0 0; }
#result-score { font-weight: 700; font-size: 20px; }
@media (max-height: 720px) {
  .shell { min-height: 480px; }
  .field { min-height: 345px; }
  .panel { gap: 10px; padding: 12px; }
  .panel > img { width: 72px; height: 72px; }
  .panel h2 { font-size: 18px; }
  .companion p { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
