:root {
  color-scheme: light;
  --page: #efede8;
  --board: #fafaf7;
  --line: #dedad2;
  --ink: #141414;
  --muted: #6f6b63;
  --red: #d93a3a;
  --blue: #2563eb;
  --button: #ffffff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--page);
  color: var(--ink);
  font-family: Outfit, system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body { overscroll-behavior: none; }

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 10px 16px 6px;
}

.level { display: flex; align-items: center; gap: 2px; }
.level-text { font-weight: 700; font-size: 20px; min-width: 88px; text-align: center; font-variant-numeric: tabular-nums; }
.level-text .label { font-weight: 500; color: var(--muted); }

.hearts { display: flex; gap: 4px; }
.hearts svg { width: 22px; height: 22px; transition: transform .2s; }
.hearts svg.lost path { fill: none; stroke: #c9c4ba; stroke-width: 2; }
.hearts svg path { fill: var(--red); }
.hearts.shake { animation: shake .35s; }

@keyframes shake {
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.tools { display: flex; gap: 6px; }

button { font: inherit; color: inherit; cursor: pointer; }

.icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--button);
  padding: 0;
}
.icon:hover { border-color: #b9b3a8; }
.icon:active { background: #f1efea; }
.icon:disabled { opacity: .35; cursor: default; }
.icon svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon.step { border-color: transparent; background: transparent; width: 32px; }
.icon.step:hover { border-color: var(--line); }
#sound .off { display: none; }
#sound[aria-pressed="false"] .on { display: none; }
#sound[aria-pressed="false"] .off { display: block; }
#hint.active { border-color: var(--blue); }
#hint.active svg { stroke: var(--blue); }

.modes {
  display: flex;
  width: calc(100% - 32px);
  max-width: 440px;
  margin: 2px auto 0;
  padding: 3px;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--button);
}
.modes button {
  flex: 1;
  border: 0;
  border-radius: 9px;
  background: transparent;
  padding: 7px 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.modes button:hover { color: var(--ink); background: #f1efea; }
.modes button[aria-pressed="true"] { background: var(--ink); color: #fff; }

.zoom {
  position: absolute;
  right: 12px;
  bottom: 2px;
  display: flex;
  gap: 6px;
}
.zoom .icon { width: 34px; height: 34px; }
.zoom[hidden] { display: none; }

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

#board {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}

.tip, .count {
  position: absolute;
  left: 0;
  right: 0;
  width: fit-content;
  max-width: calc(100% - 32px);
  margin: 0 auto;
  padding: 1px 10px;
  border-radius: 8px;
  background: var(--page);
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  pointer-events: none;
}
.tip:empty, .count:empty { display: none; }
.tip { top: 2px; }
.count { bottom: 9px; font-variant-numeric: tabular-nums; }

.card {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(239, 237, 232, .82);
}
.card[hidden] { display: none; }
.card-inner {
  width: 100%;
  max-width: 320px;
  background: var(--board);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px 22px 22px;
  text-align: center;
}
.card h2 { margin: 0 0 6px; font-size: 26px; font-weight: 700; }
.card p { margin: 0 0 18px; color: var(--muted); font-size: 15px; line-height: 1.4; }

.start-inner { max-width: 360px; }
.start-inner h1 { margin: 0 0 6px; font-size: 32px; font-weight: 700; }
.pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pick button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--button);
  padding: 12px 8px;
}
.pick button:hover { border-color: var(--ink); }
.pick b { font-size: 17px; font-weight: 600; }
.pick small { font-size: 13px; color: var(--muted); }
.pick button[data-mode="god"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.pick button[data-mode="god"] small { color: #b9b5ad; }

.primary {
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: 17px;
  padding: 13px 16px;
}
.primary:hover { background: #2c2c2c; }

.foot {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 6px 16px calc(8px + env(safe-area-inset-bottom));
  font-size: 13px;
  color: var(--muted);
}
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--ink); text-decoration: underline; }

@media (max-width: 400px) {
  .bar { padding: 8px 10px 4px; gap: 4px; }
  .level-text { font-size: 18px; min-width: 70px; }
  .level-text .label { display: none; }
  .hearts svg { width: 19px; height: 19px; }
  .icon { width: 36px; height: 36px; }
  .icon.step { width: 28px; }
  .tools { gap: 4px; }
}
