:root {
  --bg: #EEEBE6;
  --card: #FFFFFF;
  --text: #2A2724;
  --sub: #5C5650;
  --line: #DDD8D1;
  --soft: #F5F2EE;
  --accent: #3A3632;
  --on-accent: #FFFFFF;
  --hit: #E8702A;
  --dock: #2A2724;
  --dock-icon: #CFC9C2;
  --dock-active: #F59E5B;
  --serif: 'DM Serif Display', Georgia, serif;
  --sans: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  transition: background .25s ease;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 18px calc(env(safe-area-inset-bottom) + 120px);
}
#view:focus { outline: none; }

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; min-height: 44px; }
.topbar h1 { font-family: var(--serif); font-weight: 400; font-size: 30px; line-height: 1.05; margin: 0; }
.hello { font-size: 14px; font-weight: 600; color: var(--sub); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 22px; border: none; background: var(--card);
  display: inline-flex; align-items: center; justify-content: center; color: var(--text); flex-shrink: 0;
}
.offline-pill {
  display: inline-flex; align-items: center; gap: 6px; background: var(--card); color: var(--sub);
  border-radius: 14px; padding: 6px 12px; font-size: 12px; font-weight: 700; margin-bottom: 12px;
}

/* Wordmark */
.wordmark { font-family: var(--serif); font-size: 34px; line-height: 1; white-space: nowrap; display: inline-flex; align-items: baseline; }
.wordmark svg { width: 19px; height: 19px; margin: 0 1px; align-self: baseline; transform: translateY(1px); }

/* Cards and layout */
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 16px; }
.card.dark { background: var(--text); color: var(--bg); border: none; }
.card.dark .muted { color: var(--bg); opacity: .85; }
.card.outline { border: 2px solid var(--accent); }
.label { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--sub); }
.card.dark .label { color: var(--bg); opacity: .8; }
.title { font-size: 17px; font-weight: 800; margin: 0; }
.big { font-family: var(--serif); font-size: 56px; line-height: 1; }
.muted { color: var(--sub); font-size: 14px; }
.small { font-size: 13px; }
.section-title { font-size: 16px; font-weight: 800; margin: 6px 0 0; }
.spacer { flex: 1; }
.center { text-align: center; }

/* Buttons */
.btn {
  border: none; border-radius: 18px; min-height: 52px; padding: 0 18px; font-weight: 800; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn.soft { background: var(--soft); color: var(--text); }
.btn.block { width: 100%; }
.btn.small { min-height: 44px; font-size: 14px; border-radius: 14px; padding: 0 14px; }
.btn:disabled { opacity: .45; }
.hero-btn {
  width: 100%; border: none; border-radius: 22px; background: var(--accent); color: var(--on-accent);
  padding: 20px; display: flex; align-items: center; justify-content: space-between; text-align: left;
}
.hero-btn .t { font-size: 22px; font-weight: 800; }
.hero-btn .s { font-size: 14px; font-weight: 600; opacity: .95; }
.hero-btn .go { width: 50px; height: 50px; border-radius: 25px; background: var(--on-accent); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 22px;
  min-height: 44px; padding: 0 14px; font-size: 14px; font-weight: 800;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 800; color: var(--sub); }
.input {
  width: 100%; min-height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--card);
  padding: 10px 12px; font-size: 16px;
}
textarea.input { min-height: 96px; resize: vertical; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Bars */
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-row .n { width: 104px; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { flex: 1; height: 10px; border-radius: 5px; background: var(--soft); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.bar-row .v { width: 42px; text-align: right; font-size: 13px; font-weight: 800; }

/* Scoring */
.score-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.score-pill { background: var(--text); color: var(--bg); border-radius: 16px; padding: 8px 14px; font-weight: 800; font-size: 15px; }
.birds { display: flex; flex-wrap: wrap; gap: 8px; }
.bird { width: 24px; height: 24px; border-radius: 12px; background: var(--soft); }
.bird.hit { background: var(--hit); }
.bird.miss { background: transparent; border: 2px solid var(--sub); }
.bird.now { background: transparent; border: 3px solid var(--accent); }
.hm { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hm button {
  height: 150px; border-radius: 26px; font-size: 24px; font-weight: 800;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.hm .hit-btn { border: none; background: var(--accent); color: var(--on-accent); }
.hm .miss-btn { border: 2px solid var(--text); background: var(--card); color: var(--text); }
.hm button:active { transform: scale(.97); }
.station-list .st { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--soft); }
.station-list .st:last-child { border-bottom: none; }
.station-list .st .n { width: 44px; font-size: 12px; font-weight: 800; color: var(--sub); }
.station-list .birds { flex: 1; gap: 6px; }
.station-list .bird { width: 16px; height: 16px; border-radius: 8px; }

/* Lens */
.lens-badge {
  width: 64px; height: 64px; border-radius: 32px; background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 22px; flex-shrink: 0;
}
.card.dark .lens-badge { background: var(--accent); }
.kit { display: flex; flex-wrap: wrap; gap: 10px; }
.kit .lens {
  min-width: 76px; min-height: 56px; border-radius: 16px; background: var(--card); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 12px; font-weight: 800; font-size: 17px;
}
.kit .lens.best { border: 2px solid var(--accent); color: var(--accent); }
.kit .lens button { border: none; background: none; width: 32px; height: 32px; color: var(--sub); padding: 0; }
.hours { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.hours::-webkit-scrollbar { display: none; }
.hour { flex: 0 0 auto; width: 70px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); padding: 10px 6px; text-align: center; }
.hour .t { font-size: 12px; font-weight: 700; color: var(--sub); }
.hour .c { font-size: 12px; margin: 4px 0; }
.hour .l { font-size: 16px; font-weight: 800; color: var(--accent); }

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: 12px; font-weight: 700; color: var(--sub); text-align: center; padding: 4px 0; }
.cal-day {
  height: 42px; border-radius: 12px; border: none; background: transparent; font-size: 14px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 0;
}
.cal-day.today { background: var(--text); color: var(--bg); font-weight: 800; }
.cal-day.sel { outline: 2px solid var(--accent); }
.cal-day i { width: 6px; height: 6px; border-radius: 3px; background: transparent; }
.cal-day.has i { background: var(--accent); }
.cal-day.empty { visibility: hidden; }
.event { display: flex; gap: 12px; align-items: center; }
.event .date {
  width: 52px; height: 56px; border-radius: 14px; background: var(--soft); flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.event .date.next { background: var(--accent); color: var(--on-accent); }
.event .date .d { font-size: 11px; font-weight: 700; }
.event .date .n { font-size: 20px; font-weight: 800; line-height: 1; }
.event .tip { font-size: 12px; font-weight: 800; color: var(--hit); }

/* Lists */
.list-btn {
  width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px;
  display: flex; align-items: center; gap: 12px; text-align: left; color: var(--text); text-decoration: none;
}
.list-btn .ic { width: 42px; height: 42px; border-radius: 12px; background: var(--soft); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* Themes */
.theme-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.theme-btn {
  min-height: 56px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  display: flex; align-items: center; gap: 8px; padding: 0 10px; font-weight: 800; font-size: 14px; text-align: left;
}
.theme-btn.on { border: 2px solid var(--accent); }
.sw { display: flex; }
.sw span { width: 22px; height: 22px; border-radius: 11px; border: 2px solid var(--card); }
.sw span + span { margin-left: -8px; }

/* Dock */
#dock {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  width: min(444px, calc(100% - 36px)); height: 66px; border-radius: 33px; background: var(--dock);
  display: flex; align-items: center; justify-content: space-around; padding: 0 6px;
  box-shadow: 0 12px 30px rgba(0,0,0,.22); z-index: 20;
}
#dock .d {
  width: 54px; height: 54px; border: none; background: none; color: var(--dock-icon); border-radius: 27px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10px; font-weight: 800;
}
#dock .d.on { color: var(--dock-active); }
#dock .gap { width: 78px; flex-shrink: 0; }
#dock .clay {
  position: absolute; left: 50%; top: -26px; transform: translateX(-50%);
  width: 80px; height: 80px; border-radius: 40px; background: var(--accent); border: 5px solid var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 0;
  box-shadow: 0 8px 18px rgba(0,0,0,.18);
}
#dock .clay:active { transform: translateX(-50%) scale(.95); }
#dock .clay.live::after {
  content: ''; position: absolute; top: 2px; right: 2px; width: 14px; height: 14px; border-radius: 7px;
  background: var(--hit); border: 2px solid var(--bg);
}

/* Welcome */
.welcome-mark { font-family: var(--serif); font-size: 58px; line-height: 1; white-space: nowrap; display: flex; align-items: baseline; }
.welcome-mark svg { width: 36px; height: 36px; margin: 0 2px; transform: translateY(2px); }
.welcome-h { font-family: var(--serif); font-weight: 400; font-size: 32px; line-height: 1.1; margin: 0; }

/* Profile & squadies */
.avatar { border-radius: 50%; object-fit: cover; background: var(--accent); color: var(--on-accent); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0; }
.avatar-pick { position: relative; cursor: pointer; display: inline-block; }
.avatar-edit { position: absolute; right: 0; bottom: 0; width: 30px; height: 30px; border-radius: 15px; background: var(--text); color: var(--bg); display: flex; align-items: center; justify-content: center; border: 2px solid var(--card); }
.switch { width: 54px; height: 32px; border-radius: 16px; background: var(--sub); padding: 3px; display: flex; justify-content: flex-start; flex-shrink: 0; }
.switch.on { background: var(--accent); justify-content: flex-end; }
.switch i { width: 26px; height: 26px; border-radius: 13px; background: #fff; display: block; }
.code-big { font-size: 36px; font-weight: 800; letter-spacing: .18em; text-align: center; padding: 6px 0; }

/* Opening screen */
#splash {
  position: fixed; inset: 0; z-index: 50; background: var(--bg); color: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  transition: opacity .45s ease, visibility .45s ease;
}
#splash.gone { opacity: 0; visibility: hidden; }
#splash .mark { font-family: var(--serif); font-size: 64px; line-height: 1; white-space: nowrap; display: flex; align-items: baseline; }
#splash .mark svg { width: 40px; height: 40px; margin: 0 2px; transform: translateY(2px); animation: spin-in .9s cubic-bezier(.2,.8,.2,1) both; }
@keyframes spin-in { from { transform: translateY(2px) rotate(-200deg) scale(.4); opacity: 0; } to { transform: translateY(2px) rotate(0) scale(1); opacity: 1; } }
.theme-icon { width: 72px; height: 72px; border-radius: 18px; flex-shrink: 0; }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 100px); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 16px; font-weight: 700; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 30; max-width: calc(100% - 40px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty-state { text-align: center; padding: 26px 10px; color: var(--sub); }
.empty-state .title { color: var(--text); margin-bottom: 6px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
