:root {
  --bg: #F7F5FC;
  --surface: #FFFFFF;
  --ink: #2A1B3D;
  --muted: #6D6480;
  --line: #E3DDF0;
  --primary: #6B3FD4;
  --primary-ink: #FFFFFF;
  --gold: #FFB400;
  --t-violet: #EDE6FB;
  --t-rose: #FCE3E8;
  --t-teal: #D9F4F0;
  --t-gold: #FFF1CC;
  --t-blue: #DDEBFF;
  --bar: #6B3FD4;
  --display: "Black Han Sans", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --body: "Noto Sans KR", -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17111F;
    --surface: #221A2E;
    --ink: #F2ECFA;
    --muted: #A99FBD;
    --line: #382D49;
    --primary: #A98BFF;
    --primary-ink: #1A1026;
    --gold: #FFC83D;
    --t-violet: #2D2342;
    --t-rose: #3D2230;
    --t-teal: #1E3A38;
    --t-gold: #3F3417;
    --t-blue: #21324D;
    --bar: #A98BFF;
  }
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  word-break: keep-all; overflow-wrap: break-word;
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--body); font-size: 16px; line-height: 1.65;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
a { color: inherit; }
.wrap { max-width: 560px; margin: 0 auto; padding: 0 18px; }
.top { padding: 16px 0 4px; }
.logo { font-family: var(--display); font-size: 22px; text-decoration: none; color: var(--primary); letter-spacing: 0.01em; }
main { padding: 8px 0 32px; }
h1 { font-family: var(--display); font-weight: 400; font-size: 34px; line-height: 1.25; margin: 14px 0 8px; letter-spacing: -0.01em; }
h2 { font-family: var(--display); font-weight: 400; font-size: 22px; margin: 28px 0 8px; }
h3 { font-size: 17px; margin: 0 0 6px; }
p { margin: 0 0 12px; }
.lead { color: var(--muted); }
.today { color: var(--muted); font-size: 15px; margin: 0; }
.back { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 10px 18px 10px 12px; min-height: 44px; border-radius: 999px; background: var(--t-violet); color: var(--primary); font-weight: 700; font-size: 16px; text-decoration: none; }
.back svg { width: 20px; height: 20px; flex: none; }
.homebtn { margin-top: 28px; }

/* home tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 22px 0 8px; }
.tile {
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  padding: 18px 16px; border-radius: 18px; text-decoration: none; min-height: 132px;
}
.tile strong { font-family: var(--display); font-weight: 400; font-size: 21px; line-height: 1.25; }
.tile span { font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.tile.wide { grid-column: 1 / -1; min-height: 150px; padding: 22px 20px; }
.tile.wide strong { font-size: 30px; }
.tile.wide span { font-size: 15px; }
.t-violet { background: var(--t-violet); }
.t-rose { background: var(--t-rose); }
.t-teal { background: var(--t-teal); }
.t-gold { background: var(--t-gold); }
.t-blue { background: var(--t-blue); }
.tile:focus-visible, .btn:focus-visible, .opt:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--primary); outline-offset: 2px;
}

/* forms */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin: 14px 0; }
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin-bottom: 14px; min-width: 0; }
.field label { font-size: 14px; font-weight: 700; color: var(--muted); }
input[type="date"], input[type="text"], input[type="number"] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; }
input[type="date"] { text-align: left; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
select { min-width: 0; max-width: 100%; }
input[type="date"], input[type="text"], input[type="number"], select {
  font: inherit; width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); min-height: 48px;
}
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.btn {
  font: inherit; font-weight: 700; font-size: 17px; padding: 14px 18px; border-radius: 14px; border: 0;
  background: var(--primary); color: var(--primary-ink); cursor: pointer; width: 100%;
}
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-size: 15px; font-weight: 500; }
.btn.small { width: auto; font-size: 14px; padding: 10px 14px; }
.row-btns { display: grid; gap: 10px; margin-top: 12px; }
.field .lbl { font-size: 14px; font-weight: 700; color: var(--muted); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg button { font: inherit; padding: 12px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; min-height: 48px; }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); font-weight: 700; }
.namerow { display: flex; gap: 8px; }
.namerow input { flex: 1; min-width: 0; }
.seg2 { display: grid; grid-template-columns: repeat(2, 56px); gap: 6px; flex: none; }
.seg2 button { font: inherit; padding: 0; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; min-height: 48px; }
.seg2 button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); font-weight: 700; }
.saverow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.hint { font-size: 14px; color: var(--primary); margin: 0; min-height: 22px; font-weight: 500; }
.msg { color: #C23A4F; font-size: 14px; min-height: 0; margin: 8px 0 0; }
@media (prefers-color-scheme: dark) { .msg { color: #FF8CA0; } }

/* results */
.result { margin-top: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { background: var(--t-violet); border-radius: 999px; padding: 4px 12px; font-size: 14px; font-weight: 500; }
.score { font-family: var(--display); font-size: 76px; line-height: 1; letter-spacing: -0.02em; }
.score small { font-size: 28px; margin-left: 4px; }
.scoretitle { font-family: var(--display); font-size: 24px; margin: 6px 0; }
.meter { margin: 16px 0 4px; }
.meter .head { display: flex; justify-content: space-between; font-weight: 700; }
.bar { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; margin: 6px 0 6px; }
.bar i { display: block; height: 100%; background: var(--bar); border-radius: 99px; }
.meter p { color: var(--muted); font-size: 15px; margin: 0 0 6px; }
.sec { font-family: var(--display); font-weight: 400; font-size: 20px; margin: 28px 0 6px; }
.kw { background: var(--t-violet); border-radius: 14px; padding: 14px 16px; margin: 16px 0; }
.kw span { font-size: 13.5px; color: var(--muted); }
.kw b { display: block; font-family: var(--display); font-weight: 400; font-size: 30px; line-height: 1.3; }
.kw p { margin: 0; color: var(--muted); font-size: 15px; }
.dodont { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.dodont > div { border-radius: 14px; padding: 12px 14px; font-size: 14.5px; }
.dodont .do { background: var(--t-teal); }
.dodont .dont { background: var(--t-rose); }
.dodont ul { margin: 6px 0 0; padding-left: 18px; }
.lucky { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.lucky div { background: var(--t-gold); border-radius: 12px; padding: 10px; text-align: center; font-size: 14px; }
.lucky b { display: block; font-size: 17px; }
.note { font-size: 13.5px; color: var(--muted); }
.explain { margin-top: 26px; padding-top: 6px; border-top: 1px solid var(--line); }
.explain p { color: var(--muted); font-size: 15px; }

/* tests */
.testlist .tile { min-height: 0; justify-content: flex-start; }
.testlist { display: grid; gap: 12px; margin-top: 14px; }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 14px 0 6px; }
.progress i { display: block; height: 100%; background: var(--primary); transition: width .2s; }
.qtext { font-family: var(--display); font-size: 24px; line-height: 1.35; margin: 14px 0 16px; }
.opts { display: grid; gap: 10px; }
.opt {
  font: inherit; text-align: left; padding: 15px 16px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; line-height: 1.5;
}
.opt:active { background: var(--t-violet); }
.rtitle { font-family: var(--display); font-size: 32px; line-height: 1.25; margin: 6px 0 10px; }
.kv { margin: 0 0 10px; }
.pl { margin: 6px 0 12px; padding-left: 20px; }
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(20, 10, 35, .78); overflow-y: auto; padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
.modal-box { max-width: 440px; margin: 0 auto; background: var(--surface); border-radius: 18px; padding: 14px; }
.modal-box img { display: block; width: 100%; height: auto; border-radius: 12px; margin-bottom: 12px; -webkit-touch-callout: default; user-select: auto; }
.dl { display: block; text-align: center; text-decoration: none; }
.kv b { display: inline-block; min-width: 56px; color: var(--primary); }

/* dates */
.big { font-family: var(--display); font-size: 56px; line-height: 1.1; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 9px 4px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 13.5px; }
td:last-child, th:last-child { text-align: right; }

/* lotto */
.rec { margin: 14px 0 6px; }
.recmeta { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); margin-bottom: 2px; }
.recmeta b { color: var(--ink); }
.rec .game { margin: 4px 0 0; gap: 6px; }
.ball.sm { width: 36px; height: 36px; font-size: 15px; }
.ball.bonus { box-shadow: 0 0 0 3px var(--line), inset 0 -3px 0 rgba(0,0,0,.12); }
.plus { font-weight: 700; color: var(--muted); padding: 0 2px; }
.game { display: flex; align-items: center; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.game .lab { font-weight: 700; width: 18px; color: var(--muted); }
.ball {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 16px; color: #1B1B1B; box-shadow: inset 0 -3px 0 rgba(0,0,0,.12);
}
.b1 { background: #FBC400; }
.b2 { background: #69C8F2; }
.b3 { background: #FF7272; }
.b4 { background: #AAAAAA; }
.b5 { background: #B0D840; }

/* ads */
.ad-slot { margin: 22px 0; min-height: 0; text-align: center; }
.ad-slot.ph { min-height: 90px; border: 1px dashed var(--line); border-radius: 12px; display: grid; place-items: center; color: var(--muted); font-size: 13px; }

footer { border-top: 1px solid var(--line); padding: 20px 0 36px; color: var(--muted); font-size: 13.5px; }
footer nav { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.doc h2 { font-size: 19px; margin-top: 22px; }
.doc ul { padding-left: 20px; margin: 0 0 12px; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-size: 14.5px;
  max-width: 90vw; z-index: 20;
}
@media (prefers-reduced-motion: reduce) { .progress i { transition: none; } }

.topnav { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 6px; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { flex: none; text-decoration: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); font-size: 15px; font-weight: 700; color: var(--ink); background: var(--surface); }
.topnav a[aria-current="page"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.explain a, .doc a, .note a { color: var(--primary); }
.installcard { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px; margin: 28px 0 0; }
.installcard img { width: 52px; height: 52px; border-radius: 12px; flex: none; }
.installtext { flex: 1; display: grid; line-height: 1.35; min-width: 0; }
.installtext span { font-size: 13.5px; color: var(--muted); }
.installcard .btn { width: auto; flex: none; }
.installhelp { margin: 8px 4px 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; }
.menubtn { width: 46px; height: 46px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); display: grid; place-items: center; cursor: pointer; padding: 0; }
.menubtn svg { width: 24px; height: 24px; }
.menupanel { display: grid; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 8px; margin: 6px 0 4px; }
.menupanel a { display: block; padding: 14px 12px; text-decoration: none; color: var(--ink); font-weight: 700; border-radius: 10px; }
.menupanel a:active { background: var(--t-violet); }
.menupanel a.sub { font-weight: 500; color: var(--muted); font-size: 15px; }
.menupanel hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
