/* ===== linkup :root palette — mirrors projects/linkup/DESIGN.md frontmatter 1:1 ===== */
:root {
  /* surfaces & ink */
  --bg: #FBF7F0;
  --bg-2: #F4EEE3;
  --surface: #FFFFFF;
  --surface-2: #F6F1E8;
  --ink: #241B2E;
  --ink-soft: #6B5E78;
  --faint: #A99AAF;
  --line: #E6DCC9;

  /* brand */
  --brand: #6E3AA1;        /* linkup violet signature */
  --brand-deep: #4E2A7A;
  --brand-ink: #FFFFFF;

  /* difficulty palette (yellow easy → purple hard) */
  --diff-1: #F2C744;       /* yellow  */
  --diff-1-ink: #3A2E08;
  --diff-2: #6FB96A;       /* green   */
  --diff-2-ink: #16380F;
  --diff-3: #4F8FE0;       /* blue    */
  --diff-3-ink: #082140;
  --diff-4: #B85FB5;       /* purple  */
  --diff-4-ink: #2E0B2C;

  /* semantic */
  --ok: #2f9e6e;
  --bad: #e8503a;

  /* shape / motion */
  --radius: 14px;
  --radius-lg: 22px;
  --shadow: 0 10px 30px -18px rgba(60,30,90,.45);
  --shadow-lg: 0 30px 70px -30px rgba(40,20,60,.55);

  /* fonts */
  --font-display: "Fraunces", "Noto Sans KR", Georgia, serif;
  --font-body: "Noto Sans KR", system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif;

  /* i18n switcher bridge (light) */
  --i18n-switch-bg: var(--surface);
  --i18n-switch-border: var(--line);
  --i18n-switch-fg: var(--ink);
  --i18n-switch-active-bg: rgba(110,58,161,.12);
  --i18n-switch-active-fg: var(--brand);
  --i18n-switch-menu-bg: var(--surface);
  --i18n-switch-menu-border: var(--line);
}
/* ===== 3-way theme: base :root above is native LIGHT; opposite dark palette below ===== */
:root[data-theme="dark"] {
  --bg: #15121B;
  --bg-2: #100D15;
  --surface: #211C2B;
  --surface-2: #2A2438;
  --ink: #E7E0F0;
  --ink-soft: #A79DB8;
  --faint: #6E6580;
  --line: rgba(255,255,255,.10);

  --brand: #A97BD6;
  --brand-deep: #8A5FBE;
  --brand-ink: #1A0F26;

  --diff-1: #D9B23C;
  --diff-1-ink: #1A1404;
  --diff-2: #5EAA5C;
  --diff-2-ink: #06190B;
  --diff-3: #5FA0E8;
  --diff-3-ink: #06182E;
  --diff-4: #C77BC6;
  --diff-4-ink: #20071F;

  --ok: #36B07E;
  --bad: #E96A57;

  --shadow: 0 10px 30px -18px rgba(0,0,0,.7);
  --shadow-lg: 0 30px 70px -30px rgba(0,0,0,.8);

  --i18n-switch-bg: var(--surface);
  --i18n-switch-border: var(--line);
  --i18n-switch-fg: var(--ink);
  --i18n-switch-active-bg: rgba(169,123,214,.20);
  --i18n-switch-active-fg: var(--brand);
  --i18n-switch-menu-bg: var(--surface);
  --i18n-switch-menu-border: var(--line);
}

/* ===== reset ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background:
    radial-gradient(820px 480px at 88% -10%, rgba(110,58,161,.07), transparent 60%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
.numic { font-variant-numeric: tabular-nums; }

/* ===== app shell ===== */
.app { max-width: 560px; margin: 0 auto; padding: 20px clamp(14px,5vw,24px) 100px; }

/* header */
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 12px; }
.mark {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  font-size: 20px; color: var(--brand-ink);
  background: linear-gradient(145deg, var(--brand), var(--brand-deep));
  box-shadow: 0 10px 22px -12px rgba(110,58,161,.8); transform: rotate(-3deg);
}
.brand h1 { font-family: var(--font-display); font-size: 26px; line-height: 1.1; font-weight: 700; }
.brand p { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.head-right { display: flex; align-items: center; gap: 8px; }
.icon-link {
  width: 34px; height: 34px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-soft); font-size: 16px; font-weight: 700;
  cursor: pointer; transition: all .15s ease; font-family: inherit;
}
.icon-link:hover { border-color: var(--brand); color: var(--brand); }

/* stat bar */
.statbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 12px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.streak-pill {
  display: inline-flex; align-items: baseline; gap: 3px;
  background: linear-gradient(145deg, var(--brand), var(--brand-deep)); color: var(--brand-ink);
  padding: 5px 11px; border-radius: 999px; font-size: 13px; font-weight: 700;
}
.streak-pill small { font-size: 10px; opacity: .85; }
.stat-mini { display: flex; flex-direction: column; line-height: 1.15; }
.stat-mini .sm-k { font-size: 10.5px; color: var(--ink-soft); }
.stat-mini b { font-size: 15px; font-weight: 700; }
.today-tag { margin-left: auto; font-size: 11.5px; color: var(--ink-soft); white-space: nowrap; }

/* solved groups (revealed) */
.solved-row { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.solved-group {
  border-radius: var(--radius); padding: 10px 14px; color: var(--g-ink, #fff);
  display: flex; flex-direction: column; gap: 2px; align-items: center; justify-content: center;
  text-align: center; box-shadow: var(--shadow);
  animation: reveal .35s cubic-bezier(.2,1.3,.4,1);
}
.solved-group .sg-theme { font-weight: 700; font-size: 14px; letter-spacing: .02em; }
.solved-group .sg-items { font-size: 13px; opacity: .92; }
@keyframes reveal { from { transform: scale(.94); opacity: 0; } }

/* board */
.board {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin-bottom: 16px;
}
.tile {
  aspect-ratio: 1.3 / 1; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); font-family: var(--font-body);
  font-size: clamp(13px, 3.2vw, 16px); font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 6px 4px; word-break: keep-all; transition: transform .12s ease, border-color .12s ease, background .12s ease;
  user-select: none; -webkit-user-select: none;
}
.tile:hover { border-color: var(--ink-soft); }
.tile.selected {
  border-color: var(--brand); border-width: 2.5px; transform: translateY(-2px);
  background: var(--surface-2);
  box-shadow: 0 8px 18px -10px rgba(110,58,161,.6);
}
.tile.shake { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }
.tile.pop { animation: pop .25s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(.85); } }

/* mistakes + hint */
.mistake-row {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 6px;
}
.mk-label { font-size: 13px; color: var(--ink-soft); }
.mk-dots { display: inline-flex; gap: 5px; }
.mk-dots .dot { font-size: 13px; color: var(--brand); line-height: 1; }
.mk-dots .dot.lost { color: var(--faint); opacity: .5; }
.hint-line { text-align: center; font-size: 13.5px; color: var(--ink-soft); margin-bottom: 14px; min-height: 20px; transition: color .15s; }
.hint-line.warn { color: var(--bad); font-weight: 700; }
.hint-line.ok { color: var(--ok); font-weight: 700; }

/* actions */
.actions { display: flex; gap: 9px; justify-content: center; flex-wrap: wrap; }
.btn {
  font-family: inherit; font-size: 14.5px; font-weight: 700; cursor: pointer;
  padding: 11px 22px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); transition: all .15s ease;
}
.btn:hover { border-color: var(--ink-soft); }
.btn.ghost { background: transparent; color: var(--ink-soft); }
.btn.ghost:hover { color: var(--ink); border-color: var(--ink); }
.btn.primary {
  background: linear-gradient(145deg, var(--brand), var(--brand-deep));
  color: var(--brand-ink); border-color: transparent; box-shadow: var(--shadow);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.foot-note { text-align: center; font-size: 11.5px; color: var(--faint); margin-top: 22px; line-height: 1.6; }

/* ===== overlay (result/help) ===== */
.overlay {
  position: fixed; inset: 0; background: rgba(20,12,30,.55);
  display: grid; place-items: center; padding: 20px; z-index: 30; backdrop-filter: blur(3px);
}
.overlay[hidden] { display: none; }
.result-card, .help-card {
  background: var(--surface); border-radius: var(--radius-lg); padding: 26px 24px;
  max-width: 380px; width: 100%; text-align: center; box-shadow: var(--shadow-lg);
  animation: rise .3s ease;
}
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
.result-card h2, .help-card h2 { font-family: var(--font-display); font-size: 26px; margin-bottom: 6px; }
.r-sub { font-size: 13.5px; color: var(--ink-soft); margin-bottom: 16px; }

/* share grid */
.r-grid { display: flex; flex-direction: column; gap: 5px; align-items: center; margin: 0 auto 18px; width: fit-content; }
.r-row { display: flex; gap: 5px; }
.r-cell { width: 34px; height: 34px; border-radius: 7px; }
.r-cell.d1 { background: var(--diff-1); }
.r-cell.d2 { background: var(--diff-2); }
.r-cell.d3 { background: var(--diff-3); }
.r-cell.d4 { background: var(--diff-4); }
.r-cell.miss { background: var(--surface-2); border: 1px solid var(--line); }

.r-meta { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 18px; }
.rm { background: var(--surface-2); border-radius: 11px; padding: 10px 6px; }
.rm .rm-k { display: block; font-size: 11px; color: var(--ink-soft); margin-bottom: 2px; }
.rm .rm-v { font-size: 19px; font-weight: 700; }
.r-actions { display: flex; gap: 9px; justify-content: center; flex-wrap: wrap; }
.r-again { margin-top: 14px; background: none; border: none; color: var(--faint); font-family: inherit; font-size: 12.5px; cursor: pointer; text-decoration: underline; }

/* help */
.help-list { text-align: left; padding-left: 20px; margin: 14px 0; }
.help-list li { font-size: 13.5px; color: var(--ink-soft); line-height: 1.7; margin-bottom: 4px; }
.help-diff { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 16px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 600; z-index: 40; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; box-shadow: var(--shadow-lg); max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* responsive */
@media (max-width: 420px) {
  .statbar { gap: 8px; }
  .stat-mini .sm-k { font-size: 10px; }
  .stat-mini b { font-size: 14px; }
  .r-cell { width: 30px; height: 30px; }
  .tile { font-size: 12.5px; }
}
