:root {
  --ink: #070a0e;
  --panel: #141b23;
  --panel-2: #1c242e;
  --line: rgba(255, 255, 255, 0.09);
  --text: #e9eff6;
  --dim: #8c99a9;
  --amber: #f0b45c;
  --mint: #7fd9b0;
  --radius: 20px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(240, 180, 92, 0.07), transparent 60%),
    radial-gradient(90% 60% at 50% 110%, rgba(127, 217, 176, 0.05), transparent 60%),
    var(--ink);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ------------------------------------------------------------------- header */

.hud {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 8px;
}

.bname {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}

.bdate {
  margin-top: 2px;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--dim);
}

.stats { display: flex; gap: 16px; text-align: right; }

.stat b {
  display: block;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  line-height: 1.1;
}

.stat span {
  display: block;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}

/* -------------------------------------------------------------------- board */

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  padding: 2px 10px 0;
}

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

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  border-radius: 18px;
}

/* ------------------------------------------------------------------- footer */

.foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 18px 14px;
  min-height: 46px;
}

.hint {
  flex: 1;
  font-size: 12px;
  color: var(--dim);
  letter-spacing: 0.02em;
}

.gems { display: flex; gap: 7px; align-items: center; }

.gem {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  transform: rotate(45deg);
  background: #26303c;
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.gem.got {
  background: var(--amber);
  box-shadow: 0 0 9px rgba(240, 180, 92, 0.7);
  transform: rotate(45deg) scale(1.15);
}

.gear {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--dim);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: opacity 200ms ease;
}

body.playing .gear { opacity: 0.2; pointer-events: none; }

/* ------------------------------------------------------------------ overlay */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 6, 9, 0.66);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.overlay[hidden] { display: none; }

.sheet {
  width: 100%;
  max-width: 360px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 22px 22px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  transform: translateY(10px) scale(0.985);
  opacity: 0;
}

.overlay.in .sheet {
  animation: pop 260ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes pop {
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .overlay.in .sheet { animation: none; transform: none; opacity: 1; }
}

.kicker {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--amber);
}

.sheet h1 {
  margin: 8px 0 10px;
  font-size: 27px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 680;
}

.lead {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.5;
  color: #ccd7e3;
  font-variant-numeric: tabular-nums;
}

.muted {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--dim);
}

.muted strong { color: var(--text); font-variant-numeric: tabular-nums; }

.streak {
  display: inline-block;
  margin-top: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(240, 180, 92, 0.12);
  border: 1px solid rgba(240, 180, 92, 0.25);
  color: var(--amber);
  font-size: 13px;
  font-weight: 600;
}

.tips {
  margin: 14px 0 0;
  padding: 0 0 0 4px;
  list-style: none;
  font-size: 13px;
  line-height: 1.6;
  color: var(--dim);
}

.tips li { position: relative; padding-left: 16px; margin-bottom: 6px; }

.tips li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--mint);
  opacity: 0.7;
}

.actions {
  display: grid;
  gap: 9px;
  margin-top: 20px;
}

.btn {
  appearance: none;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 0;
  border-radius: 13px;
  background: linear-gradient(180deg, #f6c377, var(--amber));
  color: #241704;
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

.btn:active { transform: scale(0.985); filter: brightness(0.95); }

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 550;
}

.fine {
  margin: 14px 0 0;
  font-size: 11px;
  line-height: 1.5;
  color: #6f7c8b;
}

/* ----------------------------------------------------------------- settings */

.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  color: #c8d3df;
}

.field:last-of-type { border-bottom: 0; }

.field input[type="range"] {
  flex: 1;
  accent-color: var(--amber);
  max-width: 150px;
}

.field output {
  width: 26px;
  text-align: right;
  color: var(--dim);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.field input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--amber);
}

@media (max-height: 640px) {
  .sheet h1 { font-size: 23px; }
  .sheet { padding: 18px; }
  .tips { display: none; }
}
