:root {
  --navy: #0E2B4D; --navy-2: #163a63; --lime: #DFE01A; --orange: #FBB315; --pink: #EF4F99; --cyan: #05A9CE;
  --bg: #f4f2ec; --ink: #14202e; --mute: #64707d; --line: #e2ded4; --green: #1f9d55; --red: #d64545;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.4; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--navy-2); }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; border: 0; border-radius: 14px; padding: 15px 18px; font-weight: 800; font-size: 17px; cursor: pointer; background: var(--navy); color: #fff; text-decoration: none; }
.btn.lime { background: var(--lime); color: var(--navy); }
.btn.ghost { background: transparent; color: var(--navy); box-shadow: inset 0 0 0 2px var(--navy); }
.btn.white { background: #fff; color: var(--navy); }
.btn.small { width: auto; padding: 9px 14px; font-size: 15px; border-radius: 11px; }
.btn:disabled { opacity: .5; }
.stack > * + * { margin-top: 10px; }
input[type=text], input[type=search], textarea { width: 100%; padding: 14px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font-size: 17px; }
input:focus, textarea:focus { outline: none; border-color: var(--cyan); }
label.f { display: block; margin-bottom: 14px; }
label.f span { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.err { color: var(--red); font-weight: 700; margin: 10px 0; }
.muted { color: var(--mute); }
.center { text-align: center; }

/* splash / join */
.splash { min-height: 100vh; background: var(--navy); color: #fff; display: flex; flex-direction: column; }
.splash .cover { height: 34vh; min-height: 180px; background: var(--navy-2) center/cover; position: relative; }
.splash .cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(14,43,77,0) 40%, var(--navy)); }
.splash .inner { padding: 0 22px calc(28px + var(--safe-b)); margin-top: -40px; position: relative; flex: 1; display: flex; flex-direction: column; }
.splash h1 { font-size: 32px; line-height: 1.05; letter-spacing: -.5px; margin: 0 0 10px; }
.splash .desc { color: #cfd9e6; white-space: pre-line; margin-bottom: 22px; }
.splash .grow { flex: 1; }
.tag { display: inline-block; background: var(--lime); color: var(--navy); font-weight: 800; font-size: 15px; letter-spacing: .5px; padding: 5px 9px 4px; transform: skewX(-6deg) rotate(-2deg); margin-bottom: 14px; }
.logo-top { display: block; width: 130px; margin: calc(18px + var(--safe-t)) auto 8px; }
.home { min-height: 100vh; background: var(--navy); color: #fff; padding: 0 24px 30px; display: flex; flex-direction: column; justify-content: center; text-align: center; }
.home img { width: min(240px, 64vw); margin: 0 auto 6px; }
.home .codein { text-align: center; letter-spacing: 6px; font-size: 26px; font-weight: 800; text-transform: uppercase; }
.sheet { background: #fff; color: var(--ink); border-radius: 22px 22px 0 0; padding: 22px 20px calc(24px + var(--safe-b)); margin: 0 -22px calc(-28px - var(--safe-b)); }
.sheet h2 { margin: 0 0 14px; font-size: 22px; }
.teamlist { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; max-height: 40vh; overflow: auto; }
.teamlist button { display: flex; align-items: center; gap: 12px; border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 14px; text-align: left; font-weight: 700; cursor: pointer; }
.teamlist button.on { border-color: var(--navy); background: #eef3f9; }
.teamlist small { margin-left: auto; color: var(--mute); font-weight: 600; }
.passbig { font-size: 44px; font-weight: 800; letter-spacing: 10px; text-align: center; background: var(--lime); color: var(--navy); border-radius: 16px; padding: 14px 0 10px 10px; margin: 10px 0 16px; }

/* game shell */
.bar { position: sticky; top: 0; z-index: 10; background: var(--navy); color: #fff; padding: calc(10px + var(--safe-t)) 16px 12px; }
.bar .row1 { display: flex; align-items: center; gap: 10px; }
.bar .tname { font-weight: 800; font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .pts { background: var(--lime); color: var(--navy); font-weight: 800; padding: 4px 10px; border-radius: 99px; font-size: 15px; white-space: nowrap; }
.bar .row2 { display: flex; gap: 14px; margin-top: 6px; color: #cfd9e6; font-size: 14px; }
.bar .row2 b { color: #fff; }
.content { padding: 14px 14px calc(90px + var(--safe-b)); max-width: 640px; margin: 0 auto; }
.tabsb { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabsb button { flex: 1; border: 0; background: none; padding: 9px 0 8px; font-size: 12px; font-weight: 700; color: var(--mute); display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.tabsb button .ic { font-size: 22px; line-height: 1; filter: grayscale(1); opacity: .6; }
.tabsb button.on { color: var(--navy); }
.tabsb button.on .ic { filter: none; opacity: 1; }
.chips { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; }
.chips button { border: 0; background: #e7e3d9; border-radius: 99px; padding: 7px 14px; font-weight: 700; color: var(--mute); white-space: nowrap; cursor: pointer; }
.chips button.on { background: var(--navy); color: #fff; }

.mcard { display: flex; gap: 12px; background: #fff; border-radius: 14px; padding: 10px; margin-bottom: 9px; box-shadow: 0 1px 0 var(--line); cursor: pointer; align-items: center; }
.mcard .th { width: 64px; height: 64px; border-radius: 10px; background: #e7e3d9 center/cover; flex: none; position: relative; display: grid; place-items: center; font-size: 26px; }
.mcard .bd { flex: 1; min-width: 0; }
.mcard .nm { font-weight: 800; line-height: 1.2; }
.mcard .sub { font-size: 13px; color: var(--mute); margin-top: 3px; }
.mcard .pt { font-weight: 800; white-space: nowrap; }
.mcard.locked { opacity: .55; }
.mcard.done .th::after { content: '✓'; position: absolute; inset: 0; background: rgba(31,157,85,.82); color: #fff; font-size: 30px; font-weight: 800; display: grid; place-items: center; border-radius: 10px; }
.mcard.expired { opacity: .45; }
.badge { display: inline-block; font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 99px; background: #e7e3d9; color: var(--ink); }
.badge.warn { background: #fde8df; color: #b23c10; }
.badge.ok { background: #dff3e8; color: #157347; }

/* mission page */
.mpage .hero { margin: -14px -14px 0; aspect-ratio: 16/10; background: var(--navy) center/cover; }
.mpage h1 { font-size: 26px; line-height: 1.1; margin: 16px 0 6px; }
.mpage .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.desc h4 { margin: 16px 0 4px; font-size: 13px; letter-spacing: .8px; color: var(--navy-2); }
.desc p { margin: 0 0 10px; white-space: pre-line; }
.action { background: #fff; border-radius: 16px; padding: 16px; margin: 18px 0; box-shadow: 0 1px 0 var(--line); }
.preview { width: 100%; border-radius: 12px; display: block; margin-bottom: 12px; max-height: 60vh; object-fit: contain; background: #111; }
.progress { height: 10px; background: #e7e3d9; border-radius: 99px; overflow: hidden; margin: 10px 0; }
.progress div { height: 100%; background: var(--lime); width: 0; transition: width .2s; }
.back { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; font-weight: 700; color: var(--navy); padding: 0; margin-bottom: 10px; cursor: pointer; }
.mapbox { height: 220px; border-radius: 12px; background: #e7e3d9; margin-bottom: 10px; overflow: hidden; }

/* feed */
.post { background: #fff; border-radius: 14px; overflow: hidden; margin-bottom: 12px; box-shadow: 0 1px 0 var(--line); }
.post .ph { width: 100%; display: block; max-height: 70vh; object-fit: cover; background: #111; }
.post .cap { padding: 10px 12px; }
.post .cap b { display: block; }

/* leaderboard */
.lb { background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 1px 0 var(--line); }
.lb div { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.lb div:last-child { border: 0; }
.lb .rk { width: 30px; font-weight: 800; font-size: 18px; color: var(--mute); }
.lb .me { background: #fbfbd9; }
.lb .nm { flex: 1; font-weight: 700; }
.lb .p { font-weight: 800; }

.card { background: #fff; border-radius: 14px; padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 0 var(--line); }
.card h3 { margin: 0 0 8px; }
.msg { background: var(--lime); color: var(--navy); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; font-weight: 600; }
.msg small { display: block; font-weight: 600; opacity: .7; }
.lobby { text-align: center; padding: 30px 10px; }
.lobby .big { font-size: 46px; font-weight: 800; letter-spacing: -1px; }
.toast { position: fixed; left: 14px; right: 14px; top: calc(12px + var(--safe-t)); z-index: 50; background: var(--navy); color: #fff; padding: 14px 16px; border-radius: 14px; font-weight: 700; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.toast.lime { background: var(--lime); color: var(--navy); }
.celebrate { position: fixed; inset: 0; z-index: 60; background: rgba(14,43,77,.92); color: #fff; display: grid; place-items: center; text-align: center; padding: 30px; }
.celebrate .big { font-size: 64px; font-weight: 800; color: var(--lime); }

/* in-app camera */
.recorder { position: fixed; inset: 0; z-index: 70; background: #000; }
.recorder video { width: 100%; height: 100%; object-fit: cover; }
.rectop { position: absolute; top: calc(12px + var(--safe-t)); left: 12px; right: 12px; display: flex; align-items: center; justify-content: space-between; }
.recx { width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(0,0,0,.45); color: #fff; font-size: 22px; cursor: pointer; }
.recx:disabled { opacity: .3; }
.rectime { background: rgba(0,0,0,.45); color: #fff; font-weight: 800; padding: 6px 12px; border-radius: 99px; font-variant-numeric: tabular-nums; }
.rectime:empty { display: none; }
.recorder.on .rectime { background: var(--red); }
.recbar { position: absolute; left: 0; right: 0; top: 0; height: 5px; background: rgba(255,255,255,.2); }
.recbar div { height: 100%; width: 0; background: var(--lime); }
.recbtn { position: absolute; left: 50%; bottom: calc(28px + var(--safe-b)); transform: translateX(-50%); width: 78px; height: 78px; border-radius: 50%; border: 5px solid #fff; background: var(--red); cursor: pointer; transition: border-radius .2s; }
.recorder.photo .recbtn { background: #fff; border-color: rgba(255,255,255,.5); }
.recorder.on .recbtn { border-radius: 24px; width: 70px; height: 70px; }
.recorder.flash::after { content: ""; position: absolute; inset: 0; background: #fff; opacity: .8; }

.tav { width: 34px; height: 34px; border-radius: 50%; background: #e7e3d9 center/cover; flex: none; box-shadow: 0 0 0 2px #fff; }
.bar .tav { width: 30px; height: 30px; box-shadow: 0 0 0 2px var(--lime); }

.btn.plain-light { background: transparent; color: #cfd9e6; font-weight: 700; font-size: 15px; text-decoration: underline; padding: 8px; }
