:root {
  --blue: #0e5e8a;
  --blue-dark: #0a4566;
  --cream: #fff8e7;
  --ink: #1d2a33;
  --muted: #5b6b76;
  --gold: #ffc43d;
  --line: #d9d2bf;
  --error: #b42318;
  --card: #ffffff;
  --radius: 14px;
  --tap: 48px; /* above the 44px minimum */
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

.app {
  min-height: 100vh;  /* fallback for older browsers */
  min-height: 100dvh; /* follows Safari's address bar so bottom buttons stay visible */
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  padding:
    calc(12px + env(safe-area-inset-top))
    calc(16px + env(safe-area-inset-right))
    calc(20px + env(safe-area-inset-bottom))
    calc(16px + env(safe-area-inset-left));
}

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0 16px;
}
.top-icon { border-radius: 10px; flex: none; }
.shop-name { font-size: 1.25rem; margin: 0; color: var(--blue-dark); }

main { flex: 1; display: flex; flex-direction: column; }
.screen { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.screen h2 { margin: 8px 0 0; font-size: 1.5rem; line-height: 1.2; }
.lead { font-size: 1.1rem; margin: 0 0 12px; }
.notice p { margin: 0; }
.fix-list { margin: 0; padding-left: 1.2em; }
.fix-list li { margin-bottom: 6px; }

form { display: flex; flex-direction: column; gap: 6px; }
label { font-weight: 600; margin-top: 10px; }
.optional { font-weight: 400; color: var(--muted); }

input {
  font-size: 16px; /* 16px or more stops iPhone zooming in on focus */
  min-height: var(--tap);
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
}
input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(14, 94, 138, .2); }
input.pin {
  font-size: 22px;
  letter-spacing: .5em;
  -webkit-text-security: disc; /* masks the PIN while keeping the number pad */
}

.error { color: var(--error); min-height: 1.45em; margin: 6px 0 0; font-weight: 600; }

.btn {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 16px;
  border: 0;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 700;
  font-size: 17px;
  cursor: pointer;
  touch-action: manipulation; /* no double-tap zoom delay */
  transition: transform .08s ease, filter .08s ease;
}
/* Pressed feedback works on touch; nothing depends on hover */
.btn:active { transform: scale(.98); filter: brightness(.92); }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.secondary { background: #fff; color: var(--blue-dark); border: 2px solid var(--blue); }
.btn.gold { background: var(--gold); color: var(--ink); }
.btn.link { background: transparent; color: var(--blue-dark); text-decoration: underline; font-weight: 600; }

.hello { margin: 0; color: var(--muted); }

.card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 18px;
}
.stamps {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.stamp {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px dashed var(--line);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--line);
  font-size: 14px;
}
.stamp.filled {
  border: 0;
  background: var(--blue);
  color: #fff;
  font-size: 20px;
}
.stamp.pop { animation: pop .35s ease; }
@keyframes pop { 50% { transform: scale(1.2); } }
.progress { text-align: center; margin: 14px 0 0; font-weight: 600; }

.reward {
  background: #fff3cf;
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  padding: 12px;
}
.reward p { margin: 0 0 10px; text-align: center; }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10;
}
.sheet {
  background: #fff;
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 20px calc(16px + env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sheet h2 { margin: 0; }
.sheet p { margin: 0; }
.steps { margin: 0; padding-left: 1.4em; }
.steps li { margin-bottom: 10px; }
.glyph { display: inline-flex; vertical-align: -4px; color: #007aff; }
.hint { color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 600;
  max-width: calc(100% - 32px);
  text-align: center;
  z-index: 20;
}

@media (prefers-reduced-motion: reduce) {
  .btn, .stamp.pop { transition: none; animation: none; }
}
