:root {
  --bg: #f7f1e8;
  --paper: #fffaf3;
  --ink: #2b2f35;
  --muted: #6d6259;
  --line: #e3d6c7;
  --edge: #d6c6b5;
  --red: #b3262e;
  --brown: #6e3b2c;
  color-scheme: light;
}

* { box-sizing: border-box; }

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.title {
  position: absolute;
  left: 12px;
  top: 10px;
  margin: 0;
  padding: 4px 12px;
  font-size: 14px;
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 243, 0.9);
  pointer-events: none;
}

.bar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 1px solid var(--line);
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button {
  font: inherit;
  font-size: 15px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--edge);
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

button[aria-pressed="true"] {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

#btn-motor[aria-pressed="true"] {
  background: var(--brown);
  border-color: var(--brown);
}

.teeth {
  min-width: 118px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.status {
  margin: 0;
  min-height: 2.8em;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 420px) {
  .row { gap: 6px; }
  button { padding: 0 11px; font-size: 14px; }
  .teeth { min-width: 100px; }
}
