:root {
  --ink: #1c1633;
  --muted: #6b6480;
  --paper: #f6f3ff;
  --card: #ffffff;
  --purple: #6d5efc;
  --purple-deep: #2c2150;
  --yellow: #f6de6a;
  --teal: #1f4d57;
  --line: #e7e2f3;
  --ok: #3d9a7a;
  --danger: #c45c5c;
  --shadow: 0 10px 30px rgba(44, 33, 80, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button, input, select, textarea {
  font: inherit;
}

a { color: inherit; }

.wrap {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 120px;
}

.eyebrow {
  margin: 0;
  color: var(--purple);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 6px 0 0;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.1;
}

.sub {
  color: var(--muted);
  font-size: 16px;
}

.kid-grid {
  display: grid;
  gap: 16px;
  margin: 28px 0;
}

@media (min-width: 720px) {
  .kid-grid { grid-template-columns: repeat(3, 1fr); }
}

.kid-btn, .primary, .ghost, .nav a, .pad-key {
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
}

.kid-btn {
  min-height: 88px;
  padding: 18px 20px;
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: left;
  font-size: 22px;
  font-weight: 800;
}

.kid-btn:active { transform: scale(0.99); }

.primary {
  background: var(--yellow);
  color: var(--ink);
  font-weight: 800;
  padding: 0 18px;
}

.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ghost {
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
}

.parent-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--muted);
  font-weight: 700;
}

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(28, 22, 51, 0.45);
  display: grid;
  place-items: end center;
  padding: 16px;
  padding-bottom: 96px;
  z-index: 20;
}

.sheet[hidden] { display: none; }

.sheet-card {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 24px;
  padding: 22px;
  margin-bottom: 12px;
}

.pin-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 16px 0 20px;
}

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--purple);
}

.pin-dot.on { background: var(--purple); }

.pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.pad-key {
  min-height: 56px;
  background: var(--paper);
  font-size: 22px;
  font-weight: 800;
}

.err {
  color: var(--danger);
  min-height: 1.2em;
  font-weight: 700;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  margin-top: 18px;
  padding: 22px;
  border-radius: 24px;
  background: linear-gradient(120deg, #16343c, #2a6a75 60%, #1b4e58);
  color: #fff;
  min-height: 180px;
}

.hero h2 {
  margin: 8px 0;
  font-size: clamp(26px, 4vw, 36px);
}

.hero p { margin: 0 0 16px; opacity: 0.92; }

.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
}

.xp {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  font-weight: 800;
  font-size: 13px;
}

.buddy {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  display: grid;
  place-items: center;
  font-size: 12px;
  text-align: center;
  padding: 8px;
}

.grid-2 {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

@media (min-width: 860px) {
  .grid-2 { grid-template-columns: 1.4fr 0.8fr; }
}

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.card h3 { margin: 0 0 12px; }

.portals {
  display: grid;
  gap: 12px;
}

@media (min-width: 720px) {
  .portals { grid-template-columns: repeat(3, 1fr); }
}

.portal, .empty {
  background: #fbfaff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  min-height: 88px;
}

.portal strong { display: block; margin: 4px 0; }

.portal .tag { display: block; margin-bottom: 4px; }

.bar-row { margin: 12px 0; }
.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}
.bar {
  height: 10px;
  background: #eee8ff;
  border-radius: 999px;
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  background: var(--purple);
}

.nav {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 8px;
  background: var(--purple-deep);
  border-radius: 999px;
  z-index: 5;
}

.nav a {
  color: #c9c3de;
  text-decoration: none;
  padding: 10px 14px;
  font-weight: 800;
  font-size: 14px;
}

.nav a.on {
  background: var(--purple);
  color: #fff;
}

.nav a.off {
  opacity: 0.35;
  pointer-events: none;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow: auto;
  margin: 16px 0;
}

.tab {
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: #ece7ff;
  font-weight: 800;
}

.tab.on {
  background: var(--purple);
  color: #fff;
}

.mission-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

label {
  display: block;
  font-weight: 700;
  margin: 12px 0;
}

input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.form-row {
  display: grid;
  gap: 12px;
}

@media (min-width: 640px) {
  .form-row { grid-template-columns: 1fr 1fr; }
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: 0;
  padding: 8px 12px;
  background: #ece7ff;
  border-radius: 999px;
  font-weight: 800;
}

.check input {
  width: 22px;
  min-height: 22px;
  margin: 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 0 18px;
}

.hero .primary {
  margin-top: 14px;
}

.hero-link {
  color: var(--yellow);
  font-weight: 800;
}

.mission-form {
  margin-top: 16px;
}
