:root {
  --bg: #DCEFE0;
  --obj: #3E8E6A;
  --ink: #24313a;
  --good: #2E9E5B;
  --bad: #D2554B;
  --btn: min(15vh, 20vw);
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

[hidden] { display: none !important; }

.screen {
  position: fixed;
  inset: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3vh;
  text-align: center;
}

h1 { font-size: clamp(32px, 8vh, 80px); margin: 0 0.5em; line-height: 1.1; }
h2 { font-size: 34px; margin: 0 0 8px; }

button {
  font: inherit;
  border: 0;
  cursor: pointer;
  color: var(--ink);
  touch-action: manipulation;
}

button.primary {
  background: var(--obj);
  color: var(--bg);
  font-weight: 700;
  border-radius: 28px;
}
button.secondary {
  background: transparent;
  border: 3px solid var(--ink);
  border-radius: 20px;
  font-weight: 600;
}
button.big { font-size: clamp(28px, 7vh, 56px); padding: 0.4em 1.8em; min-height: 76px; }
button.small { font-size: 22px; padding: 0.5em 1.1em; min-height: 56px; }
button:active { transform: scale(0.96); }

/* ---------- Play screen ---------- */

#screen-play {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr;
  gap: 0 2vw;
  padding-left: calc(env(safe-area-inset-left) + 2vw);
  padding-right: calc(env(safe-area-inset-right) + 2vw);
}

.topbar {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 72px;
}
.icon-btn {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: transparent;
  border: 3px solid var(--ink);
  display: grid; place-items: center;
}
#progress { font-size: 24px; font-weight: 600; opacity: 0.75; }

.stage {
  grid-column: 1;
  grid-row: 2;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#stimulus { flex: 1; min-height: 0; width: 100%; }
.obj { fill: var(--obj); }
.frame { fill: none; stroke: var(--obj); stroke-width: 6; opacity: 0.4; }
.hand { opacity: 0.4; }
.hand-line { fill: none; stroke: var(--obj); stroke-width: 14; }
.hand-fill { fill: var(--bg); stroke: none; }
.qmark { fill: var(--obj); opacity: 0.3; font-size: 260px; font-weight: 800; text-anchor: middle; dominant-baseline: central; }

.feedback {
  min-height: 12vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding-bottom: 2vh;
  visibility: hidden;
}
.feedback.on { visibility: visible; }
.fb-icon { width: 64px; height: 64px; flex: none; }
.fb-text { font-size: clamp(28px, 6vh, 52px); font-weight: 800; }
.next { font-size: clamp(26px, 5vh, 44px); padding: 0.35em 1.4em; min-height: 70px; }

.numpad {
  grid-column: 2;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.6vh;
}
.numpad button {
  width: var(--btn);
  height: var(--btn);
  border-radius: 28%;
  background: var(--obj);
  color: var(--bg);
  font-size: calc(var(--btn) * 0.55);
  font-weight: 800;
  line-height: 1;
}
.numpad button:disabled { opacity: 0.3; cursor: default; }

@media (max-aspect-ratio: 1/1) {
  :root { --btn: min(16vw, 12vh); }
  #screen-play { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .numpad { grid-column: 1; grid-row: 3; flex-direction: row; justify-content: center; gap: 2vw; padding: 1vh 0 3vh; }
}

/* ---------- End screen ---------- */

.score { font-size: clamp(28px, 6vh, 52px); font-weight: 700; margin: 0; }
.dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; max-width: 80vw; }
.dots span { width: 28px; height: 28px; border-radius: 50%; border: 4px solid var(--obj); }
.dots span.on { background: var(--obj); }

/* ---------- Options ---------- */

.options { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.options-inner { max-width: 880px; margin: 0 auto; padding: 24px 24px 60px; }
.row { margin: 22px 0; }
.row > label { display: block; font-size: 24px; font-weight: 700; margin-bottom: 10px; }
.row small { display: block; margin-top: 6px; opacity: 0.7; font-size: 18px; }
.row.buttons { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-top: 36px; }

.seg { display: flex; flex-wrap: wrap; gap: 10px; }
.seg button {
  min-width: 72px; min-height: 64px;
  padding: 0 18px;
  font-size: 22px; font-weight: 700;
  background: transparent;
  border: 3px solid var(--ink);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.seg button.on { background: var(--obj); border-color: var(--obj); color: var(--bg); }
.seg svg { width: 30px; height: 30px; fill: currentColor; flex: none; }
.seg img { width: 30px; height: 30px; object-fit: contain; }

input[type=range] { width: 100%; height: 44px; accent-color: var(--obj); }

.stepper { display: inline-flex; align-items: center; gap: 18px; }
.stepper button {
  width: 64px; height: 64px;
  font-size: 36px; font-weight: 700;
  background: transparent;
  border: 3px solid var(--ink);
  border-radius: 18px;
}
.stepper b { font-size: 36px; min-width: 2ch; text-align: center; }

.own-image { margin-top: 12px; display: flex; gap: 12px; flex-wrap: wrap; }

.swatches { display: flex; gap: 14px; flex-wrap: wrap; }
.swatches button {
  width: 76px; height: 76px;
  border-radius: 20px;
  border: 4px solid transparent;
  display: grid; place-items: center;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.18);
}
.swatches button i { width: 30px; height: 30px; border-radius: 50%; display: block; }
.swatches button.on { border-color: var(--ink); }
