:root {
  --ink: #111317;
  --muted: #78809a;
  --blue: #5d73ff;
  --blue-soft: #cdd5ff;
  --paper: #ffffff;
  --bg: #eef2fb;
  --heart: #ff4960;
  --pin: rgba(95, 115, 255, 0.23);
  --shadow: 0 22px 70px rgba(45, 58, 105, 0.15);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 16% 12%, rgba(255, 255, 255, 0.95), transparent 20rem),
    linear-gradient(180deg, #f8faff 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.shell {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  width: min(100vw, 520px);
  height: 100dvh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.topbar {
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  align-items: center;
  min-height: 128px;
}

.status {
  text-align: center;
}

h1 {
  margin: 0 0 12px;
  color: var(--blue);
  font-size: clamp(26px, 7vw, 36px);
  line-height: 1;
  font-weight: 850;
  letter-spacing: 0;
}

.hearts {
  display: flex;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
}

.heart {
  position: relative;
  width: 31px;
  height: 28px;
  transform: rotate(-45deg);
  background: var(--heart);
  border-radius: 5px 0 5px 5px;
  box-shadow: 0 6px 12px rgba(255, 73, 96, 0.18);
}

.heart::before,
.heart::after {
  content: "";
  position: absolute;
  width: 31px;
  height: 31px;
  background: inherit;
  border-radius: 50%;
}

.heart::before {
  top: -15px;
  left: 0;
}

.heart::after {
  top: 0;
  left: 15px;
}

.heart.empty {
  background: #cfd7f5;
  box-shadow: none;
}

.round-btn {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: #3f4d7c;
  box-shadow: 0 10px 26px rgba(87, 105, 178, 0.12);
  transition: transform 160ms ease, filter 160ms ease;
}

.round-btn.small {
  justify-self: end;
  width: 48px;
  height: 48px;
  color: var(--blue);
  font-weight: 850;
  font-size: 14px;
}

.round-btn:active,
.pill-btn:active {
  transform: scale(0.95);
}

.chevron {
  width: 0;
  height: 0;
  border-top: 13px solid transparent;
  border-bottom: 13px solid transparent;
  border-right: 20px solid #49547d;
  margin-right: 4px;
}

.board-card {
  position: relative;
  display: grid;
  min-height: 0;
  border-radius: 0 0 34px 34px;
  background: var(--paper);
  box-shadow: inset 0 3px 0 rgba(91, 102, 145, 0.08), var(--shadow);
  overflow: hidden;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(12px);
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(17, 19, 23, 0.82);
  color: white;
  font-size: 14px;
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.bottombar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 72px;
}

.pill-btn {
  min-width: 88px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  background: #ffffff;
  color: var(--blue);
  font-weight: 850;
  box-shadow: 0 10px 24px rgba(73, 86, 138, 0.12);
}

.progress-wrap {
  display: grid;
  gap: 7px;
}

.progress-copy {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.progress-track {
  height: 9px;
  border-radius: 999px;
  background: #dfe5f6;
  overflow: hidden;
}

#progressFill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #54d6ba, #5d73ff);
  transition: width 260ms ease;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(37, 43, 68, 0.38);
  backdrop-filter: blur(7px);
  z-index: 10;
}

.modal.hidden {
  display: none;
}

.modal-panel {
  width: min(380px, 100%);
  padding: 28px 24px 24px;
  border-radius: 28px;
  background: white;
  text-align: center;
  box-shadow: 0 24px 80px rgba(28, 35, 66, 0.25);
}

.modal-badge {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: #eef2ff;
  color: var(--heart);
  font-size: 40px;
  font-weight: 900;
}

.modal h2 {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 28px;
  line-height: 1.08;
}

.modal p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.modal-actions {
  display: grid;
  gap: 10px;
}

.modal-actions button {
  min-height: 50px;
  border-radius: 999px;
  background: var(--blue);
  color: white;
  font-weight: 850;
}

.modal-actions button.secondary {
  background: #eef2ff;
  color: var(--blue);
}

@media (max-height: 720px) {
  .shell {
    gap: 8px;
  }

  .topbar {
    min-height: 104px;
  }

  .bottombar {
    min-height: 60px;
  }
}
