/* Student app layout (phone-first). Shared look lives in pixel.css. */
html, body { height: 100%; }
body {
  background:
    repeating-linear-gradient(0deg, transparent 0 14px, rgba(255,255,255,.18) 14px 16px),
    repeating-linear-gradient(90deg, transparent 0 14px, rgba(255,255,255,.12) 14px 16px),
    var(--grass-1);
}
#app { min-height: 100dvh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: #283048; color: #fff; border-bottom: 4px solid #182030;
  text-shadow: 1px 1px 0 #101828;
}
.topbar h1 { margin: 0; white-space: nowrap; font-size: var(--fs-m); letter-spacing: 1px; }
.status { display: flex; align-items: center; gap: 6px; font-size: var(--fs-s); padding: 3px 10px; border-radius: 999px; background: #182030; border: 2px solid #586890; }
.status i { width: 8px; height: 8px; border-radius: 2px; background: #58d080; }
.status.off i { background: #f86868; }

main { flex: 1; padding: 12px 12px calc(96px + env(safe-area-inset-bottom)); display: grid; gap: 12px; align-content: start; }
.section-title { margin: 4px 2px 0; font-size: var(--fs-m); color: #183018; text-shadow: 1px 1px 0 rgba(255,255,255,.5); }

/* bottom navigation */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  max-width: 560px; margin: 0 auto;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: #283048; border-top: 4px solid #182030;
}
nav.tabs button {
  appearance: none; border: 0; background: none; color: #a8b8d8; padding: 6px 0 2px;
  display: grid; justify-items: center; gap: 2px; font-size: var(--fs-s); min-height: 52px; cursor: pointer;
  text-shadow: 1px 1px 0 #101828;
}
nav.tabs button svg { width: 28px; height: 28px; shape-rendering: crispEdges; }
nav.tabs button[aria-current='page'] { color: #fff; }
nav.tabs button[aria-current='page'] svg { filter: drop-shadow(0 0 0 #fff); }
nav.tabs button[aria-current='page']::after { content: ''; width: 18px; height: 4px; background: var(--gold); border-radius: 2px; }
nav.tabs .badge { position: absolute; transform: translate(14px, -4px); background: var(--red); color: #fff; font-size: var(--fs-s); padding: 0 5px; border-radius: 8px; border: 2px solid #182030; }

/* centre scan tab (red & white ball) */
nav.tabs .scan-tab { color: #fff; position: relative; }
nav.tabs .scan-tab .capsule {
  width: 64px; height: 64px; margin-top: -30px; border-radius: 50%;
  background: #283048; border: 4px solid #182030; box-shadow: 0 4px 0 #101828;
  display: grid; place-items: center;
}
nav.tabs .scan-tab .capsule svg { width: 48px; height: 48px; }
nav.tabs .scan-tab:active .capsule { transform: translateY(3px); box-shadow: 0 1px 0 #101828; }

.gear { appearance: none; width: 44px; height: 44px; border-radius: 8px; border: 3px solid #586890; background: #182030; color: #fff; font-size: var(--fs-l); cursor: pointer; display: grid; place-items: center; }
.gear:active { transform: translateY(2px); }
.setting-name { display: grid; gap: 8px; border-color: var(--red); }
.setting-name .seg button { font-size: var(--fs-m); padding: 6px; }

.next-action { justify-content: flex-start; text-align: left; gap: 12px; font-size: var(--fs-m); }
.next-action span { font-size: var(--fs-xl); }
.warn-box { background: #fff4c0; }
.evo-dot { font-size: var(--fs-s); color: #a06000; }
.evo-panel { display: grid; gap: 8px; }
.chain.n2 { grid-template-columns: 1fr auto 1fr; }
details.code-login { width: min(100%, 320px); text-align: left; }
details.code-login summary { cursor: pointer; color: #283048; font-size: var(--fs-m); text-shadow: 1px 1px 0 #fff; padding: 6px 0; }
details.code-login form { margin-top: 8px; }
/* dev-only test login (CONFIG.DEV_LOGIN): small and folded so it doesn't compete with the real logins */
details.dev-login { width: min(100%, 260px); text-align: left; opacity: .8; }
details.dev-login summary { cursor: pointer; color: #283048; font-size: var(--fs-s); padding: 4px 0; list-style-position: inside; }
details.dev-login form { display: grid; gap: 6px; margin-top: 6px; }
details.dev-login input { min-height: 36px; font-size: var(--fs-s); padding: 4px 8px; }

/* trainer card */
.trainer {
  border-radius: 12px; border: 4px solid #384868; padding: 14px;
  background: linear-gradient(135deg, #f8e8a8 0 30%, #f8d878 30% 60%, #f0c860 60%);
  box-shadow: inset 0 0 0 3px #fff8d8, 0 4px 0 rgba(0,0,0,.2);
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; text-shadow: 1px 1px 0 #fff8d8;
}
.trainer .idno { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 8px; white-space: nowrap; font-size: var(--fs-s); border-bottom: 2px solid #c8a048; padding-bottom: 4px; }
.trainer .name { font-size: var(--fs-xl); font-weight: bold; }
.trainer .partner { grid-row: 2 / 4; grid-column: 2; align-self: center; background: rgba(255,255,255,.5); border: 3px solid #c8a048; border-radius: 10px; padding: 4px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 12px; white-space: nowrap; font-size: var(--fs-m); }
.stats b { float: right; margin-left: 8px; }
.badges { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; margin-top: 4px; }
.badges i { aspect-ratio: 1; border-radius: 4px; border: 2px solid #8a7038; background: rgba(0,0,0,.08); }
.badges i.on { border-color: #384868; box-shadow: inset 0 0 0 2px rgba(255,255,255,.6); }

.bag-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.bag-row .chip.local { border-style: dashed; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hint { font-size: var(--fs-m); }

/* dex */
.dex-head { display: grid; gap: 6px; }
.filters { display: flex; flex-wrap: wrap; gap: 4px; padding-bottom: 2px; }
.filters .chip { cursor: pointer; padding: 2px 9px; min-height: 34px; font-size: var(--fs-s); border-width: 2px; }
.filters .chip[aria-pressed='true'] { background: var(--ink); color: #fff; }
.dex-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dex-cell { appearance: none; border: 3px solid #384868; border-radius: 10px; background: var(--paper); padding: 6px 4px 8px; display: grid; justify-items: center; gap: 2px; cursor: pointer; text-shadow: 1px 1px 0 var(--ink-shadow); }
.dex-cell .no { font-size: var(--fs-s); color: #4a5268; justify-self: start; padding-left: 4px; }
.dex-cell .nm { font-size: var(--fs-s); }
.dex-cell.unknown { background: #d8dce0; }
.dex-cell.caught .no::after { content: ' ●'; color: var(--red); }

/* sheets & overlays */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(16, 24, 40, .72); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.overlay.center { align-items: center; }
.overlay.full { background: #101828; align-items: stretch; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; background: var(--bg); border-top: 4px solid var(--ink); border-radius: 16px 16px 0 0; padding: 16px 14px calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 12px; animation: up .2s steps(4); }
@keyframes up { from { transform: translateY(40%); } }
.sheet .grab { width: 48px; height: 5px; border-radius: 3px; background: var(--gray); justify-self: center; }
.close-x { position: absolute; top: calc(env(safe-area-inset-top) + 10px); right: 12px; z-index: 5; }

/* detail */
.habitat { border-radius: 12px; border: 4px solid var(--ink); display: grid; place-items: center; padding: 14px; min-height: 180px; position: relative; overflow: hidden; }
.habitat::before { content: ''; position: absolute; left: 15%; right: 15%; bottom: 14px; height: 18px; border-radius: 50%; background: rgba(0,0,0,.15); }
.habitat canvas { position: relative; }
.chain { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; justify-items: center; }
.chain .arrow { font-size: var(--fs-m); color: #687088; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: var(--fs-m); }

/* scanner */
.scanner { position: relative; flex: 1; display: grid; place-items: center; overflow: hidden; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.reticle { position: relative; width: min(70vw, 300px); aspect-ratio: 1; border-radius: 16px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
.reticle::before, .reticle::after { content: ''; position: absolute; inset: -4px; border: 6px solid #fff; border-radius: 18px; clip-path: polygon(0 0, 30% 0, 30% 6px, 6px 6px, 6px 30%, 0 30%, 0 70%, 6px 70%, 6px calc(100% - 6px), 30% calc(100% - 6px), 30% 100%, 70% 100%, 70% calc(100% - 6px), calc(100% - 6px) calc(100% - 6px), calc(100% - 6px) 70%, 100% 70%, 100% 30%, calc(100% - 6px) 30%, calc(100% - 6px) 6px, 70% 6px, 70% 0, 100% 0, 100% 100%, 0 100%); }
.reticle::after { border-color: transparent; }
.scan-bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); display: grid; gap: 10px; background: linear-gradient(transparent, rgba(0,0,0,.8)); }
.scan-tip { position: absolute; top: calc(env(safe-area-inset-top) + 64px); left: 16px; right: 16px; text-align: center; color: #fff; text-shadow: 1px 1px 0 #000; }

/* bag QR */
.bagqr { background: #fff; display: grid; justify-items: center; gap: 10px; padding: 16px; border-radius: 12px; border: 4px solid var(--ink); }
.bagqr canvas { width: min(84vw, 360px); height: auto; image-rendering: pixelated; }
.bright { font-size: var(--fs-m); display: flex; gap: 6px; align-items: center; }

/* celebration / evolution stage */
.stage { width: 100%; max-width: 560px; display: grid; grid-template-rows: 1fr auto; padding: calc(env(safe-area-inset-top) + 16px) 14px calc(16px + env(safe-area-inset-bottom)); gap: 12px; }
.stage .scene { display: grid; place-items: center; position: relative; }
.stage .scene > canvas, .stage .scene .spr { position: relative; z-index: 1; }
.stage .textbox { position: relative; z-index: 2; }
.stage .scene { overflow: hidden; }
.spr { position: relative; display: inline-block; }
.stage .scene.flash::after { content: ''; position: absolute; inset: -50vmax; background: #fff; animation: flash .6s ease-out forwards; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }
.stage .rays { position: absolute; width: 320px; height: 320px; border-radius: 50%; background: repeating-conic-gradient(rgba(248, 208, 72, .35) 0 10deg, transparent 10deg 20deg); animation: spin 8s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }
.new-badge { position: absolute; top: -8px; right: -24px; z-index: 2; background: var(--red); color: #fff; padding: 2px 10px; border-radius: 6px; border: 3px solid #fff; animation: blink 1s steps(1) infinite; }
.textbox { min-height: 96px; font-size: var(--fs-m); }
.textbox .more { float: right; animation: blink .8s steps(1) infinite; }

/* quiz */
.quiz-q { font-size: var(--fs-m); }
.choices { display: grid; gap: 8px; }
.choice { text-align: left; justify-content: flex-start; padding-left: 34px; position: relative; }
.choice[aria-pressed='true']::before { content: '▶'; position: absolute; left: 10px; }
.choice.right { background: #b8f0b8; }
.choice.right::after { content: '정답'; margin-left: auto; font-size: var(--fs-s); }
.choice.wrong { background: #f8c0c0; text-decoration: line-through; }

/* ranking */
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 3px solid var(--ink); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--paper); min-height: 44px; cursor: pointer; }
.seg button[aria-pressed='true'] { background: var(--ink); color: #fff; }
.rank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rank-list li { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 8px; background: var(--paper); border: 3px solid #384868; border-radius: 10px; padding: 8px 10px; }
.rank-list li.me { background: #fff4c0; border-color: #c89820; }
.rank-no { font-weight: bold; text-align: center; }
.rank-no.r1 { color: #c89820; } .rank-no.r2 { color: #8890a0; } .rank-no.r3 { color: #b06830; }
.rank-sub { font-size: var(--fs-s); color: #4a5268; }

/* evolve list */
.evo-row { display: grid; grid-template-columns: auto auto auto 1fr; align-items: center; gap: 6px; }
.evo-row .info { justify-self: end; text-align: right; display: grid; gap: 4px; justify-items: end; }
.prob { font-size: var(--fs-s); }
.ticket-big { display: flex; align-items: center; justify-content: space-between; font-size: var(--fs-l); }
.ticket-icon { display: inline-block; width: 28px; height: 18px; background: var(--gold); border: 3px solid var(--ink); border-radius: 4px; position: relative; vertical-align: middle; }
.ticket-icon::after { content: ''; position: absolute; left: 7px; top: 3px; width: 8px; height: 6px; border: 2px dashed var(--ink); border-width: 0 2px; }

/* map */
.map-wrap { position: relative; border: 4px solid var(--ink); border-radius: 10px; overflow: hidden; background: var(--grass-1); margin: 0 auto; }
.map-wrap img { display: block; width: 100%; height: auto; }
.map-label { position: absolute; transform: translate(-50%, -50%); pointer-events: none; white-space: nowrap; font-size: var(--fs-s); line-height: 1; padding: 3px 4px; background: rgba(255,255,255,.88); color: var(--ink); border: 2px solid var(--ink); border-radius: 4px; }
/* map pins: a small dot exactly on the spot (labels stay readable); invisible 40px touch area */
.pin { position: absolute; transform: translate(-50%, -50%); width: 40px; height: 40px; border: 0; padding: 0; background: none; cursor: pointer; }
.pin::before { content: ''; position: absolute; left: 13px; top: 13px; width: 14px; height: 14px; border-radius: 50%; background: var(--red); border: 3px solid #fff; box-shadow: 0 0 0 2px var(--ink); box-sizing: border-box; }
.pin.bag::before { background: var(--gold); } .pin.done::before { background: var(--gray); } .pin.today::before { background: var(--green); }
.pin.sel::before { width: 20px; height: 20px; left: 10px; top: 10px; }
.pin span { display: none; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: var(--fs-s); }
.legend i { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--ink); border-radius: 3px; vertical-align: -2px; margin-right: 4px; }

/* login */
.login { min-height: 100dvh; display: grid; align-content: center; justify-items: center; gap: 18px; padding: 24px 18px calc(24px + env(safe-area-inset-bottom)); text-align: center; background: linear-gradient(#78c8f0 0 55%, var(--grass-1) 55%); }
.logo { font-size: var(--fs-xxl); font-weight: bold; color: #f8d048; text-shadow: 3px 3px 0 #384868, -2px -2px 0 #384868, 2px -2px 0 #384868, -2px 2px 0 #384868; letter-spacing: 2px; }
.logo-sub { color: #283048; text-shadow: 1px 1px 0 #fff; }
.login .mons { display: flex; gap: 6px; }
.login form { display: grid; gap: 8px; width: min(100%, 320px); }
.login input { min-height: 44px; padding: 8px 12px; border: 3px solid var(--ink); border-radius: 8px; font-size: var(--fs-m); }
.press { font-size: var(--fs-l); color: #fff; text-shadow: 2px 2px 0 #283048; }
.err { color: #a01818; background: rgba(255,255,255,.85); border-radius: 6px; padding: 0 6px; font-size: var(--fs-m); }
.foot-note { font-size: var(--fs-s); color: #283048; max-width: 340px; }

/* audit fixes: notices / ended screen / legend schedule */
.notice-box { background: #283048; color: #fff; --frame: #f8d048; text-shadow: 1px 1px 0 #101828; }
.ended-box { background: #fff4c0; text-align: center; display: grid; gap: 6px; }
.ended-box .big { font-size: var(--fs-xl); font-weight: bold; }
.legend-box { display: flex; gap: 10px; align-items: center; }
.icon { width: 1.2em; height: 1.2em; vertical-align: -0.2em; }
.dex-cell.withdrawn { opacity: .5; }
input[type='checkbox'] { width: 24px; height: 24px; flex: none; accent-color: var(--red); }

/* map zoom: integer multiples of the native map, scroll/drag to pan */
.zoom { display: flex; align-items: center; gap: 6px; }
.zoom .btn.small { min-width: 44px; padding: 0; font-size: var(--fs-l); }
.map-scroll.zoomed { max-height: 64dvh; overflow: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; overscroll-behavior: contain; touch-action: pan-x pan-y; }
.map-scroll.zoomed .map-wrap { margin: 0; }

/* 진화권 룰렛 */
.roulette { display: grid; gap: 8px; }
.reel-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6px; }
.reel-cell { text-align: center; padding: 6px 0; border: 3px solid var(--ink); border-radius: 6px; background: #fff; font-size: var(--fs-m); }
.reel-cell.on { background: var(--gold); transform: scale(1.08); }
.reel-row.big { width: min(100%, 340px); padding: 0 6px; }
.reel-row.big .reel-cell { padding: 18px 0; font-size: var(--fs-l); }
.roulette-btn:disabled { opacity: .75; }
/* pixel icons (ui.js pix) — whole CSS px per art pixel so edges stay crisp */
.pix { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; flex: none; }
.pix svg { display: block; width: 100%; height: 100%; }
.pix.l { width: 24px; height: 24px; vertical-align: -6px; }
.pix.xl { width: 64px; height: 64px; margin: 0 auto; display: block; }
