/* ══════════════════════════════════════════════════════════════
   절친 (운동 동호회) — 도트(픽셀) 게임 UI
   폰트: Galmuri (OFL-1.1, quiple) — fonts/LICENSE.txt 참고
   Galmuri14 는 14/28px, Galmuri11 은 11/22px 에서 도트가 깨지지 않음.
   ══════════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Galmuri14';
  src: url('/fonts/Galmuri14.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Galmuri11';
  src: url('/fonts/Galmuri11.woff2') format('woff2');
  font-display: swap;
}

:root {
  --bg: #0d1018;
  --bg-2: #141a28;
  --panel: #1c2438;
  --panel-hi: #2b3654;
  --line: #46578f;
  --line-dark: #070910;

  --ink: #eaf2ff;
  --ink-dim: #8395c4;

  /* 글자·테두리에 쓰는 강조색 */
  --lime: #7ee787;
  --cyan: #57d8e0;
  --gold: #ffcb45;
  --red: #ff6b6b;
  --purple: #b78bff;
  --orange: #ff9f45;

  /* 배지 '배경'에 쓰는 강조색 — 라이트 모드에서도 밝게 유지하고 위에 어두운 글자를 올린다 */
  --lime-bg: #7ee787;
  --cyan-bg: #57d8e0;
  --gold-bg: #ffcb45;
  --orange-bg: #ff9f45;
  --purple-bg: #b78bff;
  --lime-edge: #3aa84f;
  --orange-edge: #c96f10;
  --purple-edge: #7c52d6;
  --gold-edge: #c99a10;
  --on-accent: #0d1018;          /* 강조색 배경 위 글자색 */

  --well: #0b0e15;               /* 움푹 들어간 영역 (입력칸·게이지 바닥) */
  --sunken: #10141f;             /* 한 단 낮은 면 (펼침 영역·타일) */
  --chip: #232c44;               /* 작은 칩 배경 */
  --dotted: #2b3654;             /* 점선 구분선 */
  --drop: rgba(0,0,0,.55);       /* 패널 아래 하드 섀도 */
  --scrim: rgba(4,6,12,.82);     /* 모달 뒷배경 */
  --err-bg: #2a1418;             /* 오류 메시지 배경 */
  --ok-bg: #12251a;              /* 성공 메시지 배경 */

  --px: 4px;              /* 도트 1칸 */
  --font: 'Galmuri14', 'Galmuri11', 'Apple SD Gothic Neo', 'Malgun Gothic', monospace;
  --font-sm: 'Galmuri11', 'Galmuri14', 'Malgun Gothic', monospace;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% 0%, #1b2540 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.65;
  letter-spacing: .02em;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: unset;
  font-smooth: never;
  -webkit-text-size-adjust: 100%;
  image-rendering: pixelated;
  min-height: 100vh;
  min-height: 100dvh;   /* iOS 주소창 높이를 뺀 실제 보이는 높이 */
}

/* CRT 스캔라인 + 비네트 오버레이 */
.crt {
  position: fixed; inset: 0; z-index: 90; pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,.22) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.45) 100%);
  mix-blend-mode: multiply;
  animation: flicker 4s steps(2) infinite;
}

.wrap {
  max-width: 560px; margin: 0 auto;
  padding: 0 12px calc(110px + env(safe-area-inset-bottom, 0px));
}
.hidden { display: none !important; }

/* ── 픽셀 패널 ─────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 3px solid var(--line);
  box-shadow:
    inset 0 3px 0 var(--panel-hi),
    inset 0 -3px 0 var(--line-dark),
    0 6px 0 var(--drop);
  margin-top: 12px;
}
.panel-pad { padding: 14px; }

.label-sm {
  font-family: var(--font-sm); font-size: 11px; color: var(--ink-dim);
  letter-spacing: .12em; text-transform: uppercase;
}
.section-title {
  font-family: var(--font-sm); font-size: 11px; color: var(--cyan);
  letter-spacing: .16em; margin: 20px 0 0; text-transform: uppercase;
}
.section-title::before { content: '▶ '; }

/* ── HUD 헤더 ──────────────────────────────────────────── */
header.hud {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, var(--bg) 82%, transparent);
  /* iOS 상태바/노치 영역만큼 위쪽을 비운다 (viewport-fit=cover 사용 중) */
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 0 8px;
}
.hud-row { display: flex; align-items: center; gap: 8px; }
.hud-title { font-size: 14px; color: var(--gold); flex: 1; letter-spacing: .06em; }
.hud-title .who { display: block; font-family: var(--font-sm); font-size: 11px; color: var(--ink-dim); letter-spacing: .1em; }

.stagebar {
  display: flex; align-items: center; gap: 6px; margin-top: 8px;
  background: var(--bg-2); border: 3px solid var(--line);
  box-shadow: inset 0 0 0 2px var(--line-dark);
  padding: 6px 6px;
}
.stagebar .stage { flex: 1; text-align: center; font-size: 14px; letter-spacing: .04em; }
.stagebar .stage .timer {
  display: block; font-family: var(--font-sm); font-size: 11px; letter-spacing: .1em; color: var(--cyan);
}
.stagebar .stage .timer.urgent { color: var(--red); animation: blink 1s steps(1) infinite; }

/* ── 메뉴 탭 ───────────────────────────────────────────── */
.menu { display: flex; gap: 6px; margin-top: 8px; }
.menu button {
  flex: 1; background: var(--bg-2); color: var(--ink-dim);
  border: 3px solid var(--line-dark); box-shadow: none;
  padding: 8px 2px 6px; font-family: var(--font); font-size: 14px; cursor: pointer;
  letter-spacing: .04em; position: relative;
}
.menu button.on {
  background: var(--panel-hi); color: var(--gold); border-color: var(--line);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.14);
}
.menu button.on::before {
  content: '▶'; position: absolute; left: 3px; top: 50%; transform: translateY(-50%);
  font-size: 10px; color: var(--gold); animation: nudge .6s steps(2) infinite alternate;
}

/* ── 버튼 (누르면 내려가는 3D 픽셀 버튼) ───────────────── */
button, .btn {
  font-family: var(--font); font-size: 14px; letter-spacing: .04em; cursor: pointer;
  background: var(--panel-hi); color: var(--ink);
  border: 3px solid var(--line);
  border-radius: 0;
  padding: 9px 12px;
  box-shadow: inset 0 3px 0 rgba(255,255,255,.12), 0 4px 0 var(--line-dark);
  transition: transform .04s steps(1), box-shadow .04s steps(1);
}
button:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: inset 0 3px 0 rgba(255,255,255,.08), 0 0 0 var(--line-dark);
}
button:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: #2e6ad1; border-color: #6ea8ff; color: #fff; }
.btn-gold { background: #a97a10; border-color: var(--gold); color: #fff8e0; }
.btn-danger { background: #8f2f2f; border-color: var(--red); color: #ffe8e8; }
.btn-sm { padding: 4px 8px; font-family: var(--font-sm); font-size: 11px; box-shadow: inset 0 2px 0 rgba(255,255,255,.1), 0 3px 0 var(--line-dark); }
.btn-sm:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 0 0; }
.btn-icon { width: 40px; padding: 8px 0; text-align: center; font-size: 14px; }
.btn-block { width: 100%; }

/* ── 파티 멤버 행 ──────────────────────────────────────── */
.party { padding: 4px; }
.member {
  /* 테두리는 border 로 그린다. inset box-shadow 로 그리면 자체 배경을 가진
     자식(.member-body)이 그 위를 덮어 테두리가 중간에 끊겨 보인다. */
  border: 2px solid var(--line-dark); margin: 4px 0; background: var(--bg-2);
  transition: border-color .1s steps(1);
}
.member.is-me { border-color: var(--cyan); }
.member-head { display: flex; align-items: center; gap: 10px; padding: 9px 10px; cursor: pointer; }

.avatar {
  width: 36px; height: 36px; flex: none; image-rendering: pixelated;
  border: 2px solid var(--line-dark); background: var(--well);
  animation: bob 1.4s steps(2) infinite;
}
.member.done .avatar { animation: bob-happy .5s steps(2) infinite; }

.member-info { flex: 1; min-width: 0; }
.member-name { font-size: 14px; letter-spacing: .04em; display: flex; align-items: center; gap: 5px; }
.member-name .crown { color: var(--gold); font-size: 11px; }

/* 세그먼트 게이지 (주 3회) */
.gauge { display: flex; gap: 3px; margin-top: 4px; }
.gauge .cell {
  width: 26px; height: 10px; background: var(--well);
  box-shadow: inset 0 0 0 2px var(--dotted);
}
.gauge .cell.on { background: var(--lime-bg); box-shadow: inset 0 -3px 0 var(--lime-edge), inset 0 0 0 2px var(--well); }
.gauge .cell.pop { animation: cell-pop .34s steps(4) both; }
.gauge .extra { font-family: var(--font-sm); font-size: 11px; color: var(--lime); margin-left: 3px; }

.tag {
  font-family: var(--font-sm); font-size: 11px; letter-spacing: .06em;
  padding: 4px 7px; white-space: nowrap; border: 2px solid;
}
.t-clear { color: var(--on-accent); background: var(--lime-bg); border-color: var(--lime-edge); }
.t-warn { color: var(--on-accent); background: var(--orange-bg); border-color: var(--orange-edge); }
.t-danger { color: #fff; background: #8f2f2f; border-color: var(--red); animation: pulse 1s steps(2) infinite; }
.t-exempt { color: var(--ink-dim); background: var(--chip); border-color: var(--line); }
.t-pending { color: var(--on-accent); background: var(--purple-bg); border-color: var(--purple-edge); }
.t-gold { color: var(--on-accent); background: var(--gold-bg); border-color: var(--gold-edge); }

.today-line {
  font-family: var(--font-sm); font-size: 11px; color: var(--cyan);
  padding: 0 10px 9px 56px; margin-top: -6px; letter-spacing: .04em;
}
.today-line.warn { color: var(--orange); }

/* 펼침 영역 — max-height/overflow 로 자르지 않는다 (기록이 많아도 전부 보이게) */
.member-body {
  border-top: 2px solid var(--line); background: var(--sunken);
  padding: 2px 10px 10px;
  animation: unfold .16s steps(2) both;
}
.day { padding: 9px 0; border-bottom: 2px dotted var(--dotted); }
.day:last-child { border-bottom: 0; }
.day-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.day-date { font-size: 14px; color: var(--gold); }
.day-sum { font-family: var(--font-sm); font-size: 11px; color: var(--ink-dim); }
.sess {
  display: flex; align-items: center; gap: 7px; margin-top: 6px;
  font-family: var(--font-sm); font-size: 11px; color: var(--ink-dim); flex-wrap: wrap;
}
.sess .k { color: var(--ink); background: var(--chip); border: 2px solid var(--line); padding: 2px 5px; }
.sess.rejected { opacity: .5; text-decoration: line-through; }
.shots { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.shots img {
  width: 48px; height: 48px; object-fit: cover; cursor: zoom-in;
  border: 3px solid var(--line); background: var(--well); image-rendering: auto;
  box-shadow: 0 3px 0 var(--line-dark);
}
.shots img:active { transform: translateY(3px); box-shadow: 0 0 0; }
.empty {
  font-family: var(--font-sm); font-size: 11px; color: var(--ink-dim);
  text-align: center; padding: 16px 10px; letter-spacing: .06em;
}

/* ── 대시보드 (통계) ───────────────────────────────────── */
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; }

/* 스탯 타일 2×2 */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tile {
  background: var(--sunken); border: 2px solid var(--line-dark); padding: 9px 10px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.05);
}
.tile .k { font-family: var(--font-sm); font-size: 11px; color: var(--cyan); letter-spacing: .1em; }
.tile .v { font-size: 28px; color: var(--gold); line-height: 1.25; }
.tile .v small { font-size: 14px; color: var(--ink-dim); margin-left: 3px; }
.tile .sub { font-family: var(--font-sm); font-size: 11px; color: var(--ink-dim); }

/* 운동왕 */
.king { display: flex; align-items: center; gap: 12px; }
.king .crown-big { font-size: 28px; color: var(--gold); animation: bob 1.2s steps(2) infinite; }
.king img { width: 48px; height: 48px; image-rendering: pixelated; border: 3px solid var(--gold); background: var(--well); }
.king .who { flex: 1; min-width: 0; }
.king .who b { font-size: 28px; color: var(--gold); display: block; line-height: 1.3; }
.king .who span { font-family: var(--font-sm); font-size: 11px; color: var(--ink-dim); }
.podium { display: flex; gap: 6px; margin-top: 10px; }
.podium .p {
  flex: 1; text-align: center; background: var(--sunken); border: 2px solid var(--line-dark); padding: 7px 4px;
}
.podium .p .rank { font-family: var(--font-sm); font-size: 11px; color: var(--ink-dim); }
.podium .p .nm { font-size: 14px; }
.podium .p .val { font-family: var(--font-sm); font-size: 11px; color: var(--gold); }
.podium .p.first { border-color: var(--gold); }

/* 종목별 막대 */
.bars { display: grid; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 74px 1fr 46px; align-items: center; gap: 7px; }
.bar-row .lb { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 12px; background: var(--well); box-shadow: inset 0 0 0 2px var(--dotted); }
.bar-fill { height: 100%; background: var(--cyan-bg); box-shadow: inset 0 -3px 0 rgba(0,0,0,.28); }
.bar-fill.lime { background: var(--lime-bg); }
.bar-row .ct { font-family: var(--font-sm); font-size: 11px; color: var(--ink-dim); text-align: right; }

/* 기록 하이라이트 */
.best { display: flex; align-items: baseline; gap: 8px; padding: 7px 0; border-bottom: 2px dotted var(--dotted); }
.best:last-child { border-bottom: 0; }
.best .t { font-family: var(--font-sm); font-size: 11px; color: var(--cyan); width: 84px; flex: none; letter-spacing: .06em; }
.best .v { font-size: 14px; color: var(--gold); }
.best .w { font-family: var(--font-sm); font-size: 11px; color: var(--ink-dim); }

/* ── 표 (정산) ─────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 7px 6px; text-align: right; border-bottom: 2px dotted var(--dotted); }
th:first-child, td:first-child { text-align: left; }
th {
  font-family: var(--font-sm); font-size: 11px; color: var(--cyan);
  letter-spacing: .1em; border-bottom: 3px solid var(--line);
}
tr:last-child td { border-bottom: 0; }
td.pos { color: var(--lime); }
td.neg { color: var(--red); }
td .coin { color: var(--gold); animation: coin 1.2s steps(4) infinite; display: inline-block; }
.table-scroll { overflow-x: auto; }
.hint { font-family: var(--font-sm); font-size: 11px; color: var(--ink-dim); letter-spacing: .04em; margin: 8px 0 0; }
.hint.tip::before { content: '※ '; color: var(--cyan); }

/* ── 폼 ───────────────────────────────────────────────── */
label.field { display: block; margin-top: 12px; font-family: var(--font-sm); font-size: 11px; color: var(--cyan); letter-spacing: .1em; }
/* 입력 필드 글씨는 반드시 16px 이상 유지.
   iOS Safari 는 16px 미만 입력칸에 포커스되면 화면을 강제로 확대한다.
   Galmuri11 의 2배수인 22px 로 두어 도트도 깨지지 않고 확대도 발생하지 않는다. */
input, select, textarea {
  width: 100%; margin-top: 5px; padding: 8px 10px;
  font-family: var(--font-sm); font-size: 22px; line-height: 1.25; color: var(--ink);
  background: var(--well); border: 3px solid var(--line); border-radius: 0;
  box-shadow: inset 0 0 0 2px var(--line-dark);
  max-width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); }
textarea { resize: vertical; min-height: 76px; }
/* 파일 선택은 텍스트 입력이 아니라 확대 대상이 아님 → 작게 유지 */
input[type=file] { font-family: var(--font-sm); font-size: 11px; line-height: 1.5; padding: 7px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
/* 날짜 입력칸은 22px 글씨에서 최소 폭이 커서 좁은 화면의 2열에 들어가지 않는다 → 세로로 쌓는다 */
@media (max-width: 430px) {
  .row2.row-stack { grid-template-columns: 1fr; }
}

.chips { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.chip {
  background: var(--bg-2); color: var(--ink-dim); border: 3px solid var(--line-dark);
  padding: 6px 9px; font-family: var(--font); font-size: 14px; box-shadow: none;
}
.chip.on { background: var(--panel-hi); color: var(--gold); border-color: var(--gold); }

.msg {
  font-family: var(--font-sm); font-size: 11px; padding: 8px 10px; margin-top: 10px;
  border: 3px solid; letter-spacing: .04em;
}
.msg.err { color: var(--red); border-color: var(--red); background: var(--err-bg); animation: shake .3s steps(3); }
.msg.ok { color: var(--lime); border-color: var(--lime); background: var(--ok-bg); }

/* ── 대화창(모달) ──────────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0; z-index: 60; background: var(--scrim);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .12s steps(2) both;
}
.modal {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: var(--panel); border: 4px solid var(--line);
  box-shadow: inset 0 0 0 3px var(--line-dark), 0 -6px 0 rgba(0,0,0,.5);
  padding: 14px 14px 24px;
  animation: slide-up .16s steps(3) both;
}
.modal h3 { margin: 0 0 4px; font-size: 14px; color: var(--gold); letter-spacing: .06em; }
.modal h3::before { content: '◆ '; color: var(--cyan); }
.modal-sub { font-family: var(--font-sm); font-size: 11px; color: var(--ink-dim); margin: 0 0 6px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions button { flex: 1; }
@media (min-width: 600px) { .modal-bg { align-items: center; } }

/* 대화 상자 */
.dialogue { white-space: pre-wrap; font-size: 14px; line-height: 1.8; min-height: 3.6em; }
.dialogue .cursor { color: var(--gold); animation: blink .7s steps(1) infinite; }

/* ── DAY CLEAR 연출 ────────────────────────────────────── */
.clear-fx {
  position: fixed; inset: 0; z-index: 70; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  background: rgba(13,16,24,.55); animation: fade .1s steps(2) both;
}
.clear-fx .banner {
  font-size: 28px; color: var(--gold); text-align: center; letter-spacing: .1em;
  text-shadow: 4px 4px 0 var(--line-dark), 0 0 24px rgba(255,203,69,.5);
  animation: banner-pop .5s steps(5) both;
}
.clear-fx .banner small {
  display: block; font-family: var(--font-sm); font-size: 11px; color: var(--lime);
  margin-top: 8px; letter-spacing: .16em;
}
.clear-fx .spark {
  position: absolute; width: 8px; height: 8px; background: var(--gold);
  animation: spark .7s steps(6) both;
}

/* ── FAB ──────────────────────────────────────────────── */
.fab {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex; gap: 8px; justify-content: center;
}
.fab > * { flex: 1; max-width: 258px; padding: 12px 8px; }

/* ── 타이틀 화면 (로그인) ──────────────────────────────── */
.title-screen {
  max-width: 400px; margin: 0 auto; text-align: center;
  padding: calc(env(safe-area-inset-top, 0px) + 4vh) 16px calc(32px + env(safe-area-inset-bottom, 0px));
}
/* 42px = Galmuri14 의 3배수 (도트 유지). 동호회 이름이 짧아 크게 뽑는다 */
.logo {
  font-size: 42px; color: var(--gold); letter-spacing: .1em; line-height: 1.45;
  padding-top: 6px;
  text-shadow: 4px 4px 0 var(--line-dark);
  animation: bob 1.6s steps(2) infinite;
}
.logo small { display: block; font-family: var(--font-sm); font-size: 11px; color: var(--cyan); letter-spacing: .22em; margin-top: 8px; }
.press {
  font-family: var(--font-sm); font-size: 11px; color: var(--ink-dim);
  letter-spacing: .16em; margin: 18px 0 6px; animation: blink 1.1s steps(1) infinite;
}
.player-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.player {
  display: flex; align-items: center; gap: 8px; padding: 9px; text-align: left;
  background: var(--bg-2); border: 3px solid var(--line);
}
.player img { width: 28px; height: 28px; image-rendering: pixelated; border: 2px solid var(--line-dark); }
.player span { flex: 1; min-width: 0; font-size: 14px; }
.player em { display: block; font-family: var(--font-sm); font-style: normal; font-size: 11px; color: var(--gold); }
/* 28px = Galmuri14 의 2배수 (16px 이상이므로 iOS 확대도 없음) */
.pin-input { font-family: var(--font); font-size: 28px !important; letter-spacing: .55em; text-align: center; color: var(--gold) !important; }
.footnote {
  font-family: var(--font-sm); font-size: 11px; color: #5c6b96; line-height: 1.9;
  margin-top: 24px; letter-spacing: .04em;
}

/* 라이트박스 */
.lightbox {
  position: fixed; inset: 0; z-index: 80; background: rgba(4,6,12,.94);
  display: flex; align-items: center; justify-content: center; padding: 14px;
  animation: fade .12s steps(2) both;
}
.lightbox img { max-width: 100%; max-height: 100%; border: 4px solid var(--line); image-rendering: auto; }
.lightbox .close { position: absolute; top: 14px; right: 14px; }

/* ══ 애니메이션 ══════════════════════════════════════════ */
@keyframes flicker { 0%, 96% { opacity: 1; } 97%, 100% { opacity: .82; } }
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes pulse { 0%, 49% { filter: brightness(1); } 50%, 100% { filter: brightness(1.5); } }
@keyframes nudge { from { transform: translate(0, -50%); } to { transform: translate(3px, -50%); } }
@keyframes bob { 0%, 49% { transform: translateY(0); } 50%, 100% { transform: translateY(-3px); } }
@keyframes bob-happy { 0%, 49% { transform: translateY(0) rotate(-3deg); } 50%, 100% { transform: translateY(-5px) rotate(3deg); } }
@keyframes shake {
  0% { transform: translateX(0); } 33% { transform: translateX(-5px); }
  66% { transform: translateX(5px); } 100% { transform: translateX(0); }
}
@keyframes cell-pop {
  0% { transform: scale(0); } 25% { transform: scale(1.5); }
  50% { transform: scale(.85); } 75% { transform: scale(1.15); } 100% { transform: scale(1); }
}
@keyframes unfold { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { transform: translateY(40px); } to { transform: translateY(0); } }
@keyframes coin { 0%, 49% { transform: scaleX(1); } 50%, 100% { transform: scaleX(.35); } }
@keyframes banner-pop {
  0% { transform: scale(0) rotate(-8deg); } 40% { transform: scale(1.35) rotate(4deg); }
  70% { transform: scale(.9) rotate(-2deg); } 100% { transform: scale(1) rotate(0); }
}
@keyframes spark {
  from { transform: translate(0, 0) scale(1.4); opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

/* 움직임 최소화 설정 존중 */
@media (prefers-reduced-motion: reduce) {
  .crt { animation: none; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .avatar, .logo { animation: none; }
}

/* ══ 라이트 모드 ═════════════════════════════════════════
   기본값은 다크. html[data-theme="light"] 일 때만 적용된다.
   배지 배경색(--*-bg)은 밝은 채도를 그대로 두고 위에 어두운 글자를 올리므로
   여기서는 글자·면 색만 갈아끼운다.
   ══════════════════════════════════════════════════════ */
:root[data-theme="light"] {
  --bg: #e9edf6;
  --bg-2: #dde3f0;
  --panel: #ffffff;
  --panel-hi: #eef2fa;
  --line: #7f92bf;
  --line-dark: #aab6d6;

  --ink: #151a26;
  --ink-dim: #4d5a7c;

  /* 밝은 배경에서 읽히도록 강조색을 어둡게 (배지 배경용 --*-bg 는 그대로) */
  --lime: #14672f;
  --cyan: #085a66;
  --gold: #755300;
  --red: #b12a22;
  --purple: #5a32ab;
  --orange: #8a4c00;

  --well: #f5f7fc;
  --sunken: #f1f4fb;
  --chip: #e4e9f5;
  --dotted: #c3cde4;
  --drop: rgba(40, 55, 95, .20);
  --scrim: rgba(20, 28, 50, .55);
  --err-bg: #fdecea;
  --ok-bg: #e6f6ec;
}

:root[data-theme="light"] body {
  background:
    radial-gradient(circle at 50% 0%, #ffffff 0%, transparent 60%),
    var(--bg);
}

/* 밝은 화면에서는 CRT 효과를 약하게 (안 그러면 회색 필터처럼 보인다) */
:root[data-theme="light"] .crt {
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,.07) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 60%, rgba(30,45,80,.14) 100%);
}

/* 밝은 패널 위에서는 흰색 하이라이트가 보이지 않으므로 제거 */
:root[data-theme="light"] button,
:root[data-theme="light"] .btn-sm { box-shadow: 0 4px 0 var(--line-dark); }
:root[data-theme="light"] .btn-sm { box-shadow: 0 3px 0 var(--line-dark); }
:root[data-theme="light"] button:active:not(:disabled) { box-shadow: 0 0 0 var(--line-dark); }
:root[data-theme="light"] .menu button.on { box-shadow: inset 0 2px 0 rgba(0,0,0,.05); }
:root[data-theme="light"] .panel {
  box-shadow: inset 0 -3px 0 var(--line-dark), 0 6px 0 var(--drop);
}
:root[data-theme="light"] .tile { box-shadow: inset 0 2px 0 rgba(0,0,0,.04); }

/* DAY CLEAR 연출은 두 모드 모두 어두운 배경 위에 띄운다 (플래시 연출) */
:root[data-theme="light"] .clear-fx { background: rgba(20, 28, 50, .55); }
:root[data-theme="light"] .clear-fx .banner { color: var(--gold-bg); text-shadow: 4px 4px 0 rgba(0,0,0,.5); }
