:root {
  --bg: #e8f4fa;
  --surface: #ffffff;
  --line: #d6e6ef;
  --ink: #3d4f5a;
  --muted: #8a9ca7;
  --accent: #f0607a;
  --font: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'Segoe UI', Roboto, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  font-family: var(--font);
  font-weight: 400;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overflow: hidden;
}

#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(14px, env(safe-area-inset-top)) 12px max(32px, calc(env(safe-area-inset-bottom) + 20px));
  gap: 12px;
}

/* ---------- Titel ---------- */
.title {
  font-size: min(3.6vh, 6vw, 30px);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: .01em;
  color: var(--ink);
  white-space: nowrap;
}
.title .heart { color: var(--accent); }

/* ---------- Anzeige oben ---------- */
.hud {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

/* ---------- Knöpfe unter dem Spielfeld ---------- */
#board-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.controls {
  display: flex;
  gap: 8px;
}

.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 76px;
  padding: 5px 12px 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.chip .label {
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--muted);
}
.chip .value {
  font-size: 20px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.chip[hidden] { display: none; }
.chip-player .value {
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s ease;
}
.icon-btn:hover { background: #f4f9fc; }
.icon-btn:active { background: var(--line); }
.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.6;
  stroke-linejoin: round;
}
.icon-btn .ico-off { display: none; }
.icon-btn .slash { display: none; }
.icon-btn[aria-pressed="false"] svg { opacity: .55; }
.icon-btn[aria-pressed="false"] .slash { display: block; }
.icon-btn.muted .ico-on { display: none; }
.icon-btn.muted .ico-off { display: block; }

/* ---------- Spielfeld ---------- */
#board-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

#board {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
}

#game {
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(255, 255, 255, .82);
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility .3s;
}
.overlay.show {
  opacity: 1;
  visibility: visible;
}

.card {
  width: min(100%, 320px);
  padding: 26px 22px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  text-align: center;
}

.card h2 {
  margin: 0 0 10px;
  font-size: 26px;
  font-weight: 500;
  color: var(--ink);
}
.card p {
  margin: 0 0 12px;
  font-size: 18px;
  line-height: 1.4;
}
.card p.small {
  font-size: 15px;
  color: var(--muted);
}
.card p.big {
  font-size: 26px;
  margin: 4px 0 16px;
  font-variant-numeric: tabular-nums;
}
.card .record {
  display: none;
  color: var(--accent);
  font-size: 18px;
}
.card .record.show { display: block; }

.toplist {
  margin: 4px 0 16px;
  text-align: left;
}
.toplist h3 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--muted);
  text-align: center;
}
.toplist ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: platz;
  max-height: 34vh;
  overflow-y: auto;
}
.toplist li {
  counter-increment: platz;
  display: flex;
  gap: 8px;
  padding: 5px 4px;
  font-size: 15px;
  border-top: 1px solid var(--line);
}
.toplist li:first-child { border-top: 0; }
.toplist li::before {
  content: counter(platz) '.';
  width: 22px;
  color: var(--muted);
}
.toplist li .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toplist li .p { font-variant-numeric: tabular-nums; }
.toplist li.me { color: var(--accent); }

.btn {
  margin-top: 4px;
  border: 0;
  border-radius: 12px;
  padding: 14px 30px;
  font: inherit;
  font-size: 19px;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  transition: background .15s ease;
}
.btn:hover { background: #e4546e; }
.btn:active { background: #d64a63; }

@media (max-width: 420px) {
  .chip { min-width: 62px; padding: 4px 8px 5px; }
  .chip .value { font-size: 18px; }
  .icon-btn { width: 40px; height: 40px; }
}
