/* 🧠 1분 두뇌 테스트 — 모바일 우선 스타일 (390×844 기준) */
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100dvh;
  overflow-x: hidden;
  color: #e9eef7;
  background-color: #06080f;
  background-image:
    radial-gradient(900px 520px at 50% -160px, rgba(255, 77, 109, .22), transparent 62%),
    radial-gradient(700px 420px at 105% 8%, rgba(167, 139, 250, .14), transparent 60%),
    radial-gradient(760px 500px at 0% 100%, rgba(34, 211, 238, .10), transparent 62%);
  background-attachment: fixed;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
  -webkit-user-select: none;
  user-select: none;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}
h1, h2, h3, p { margin: 0; }

.app {
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 18px calc(22px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

/* ---------- 상단 바 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 -18px;
  padding: calc(10px + env(safe-area-inset-top)) 18px 10px;
  background: #080b13;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .05);
}
.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -.02em;
}
.brand-logo { font-size: 18px; }
.icon-btn {
  margin-left: auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 17px;
  line-height: 1;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .09);
  transition: transform .12s ease, background .2s ease;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.back { margin-left: 0; }
.icon-btn.back[hidden] { display: none; }
body.muted .icon-btn#btnSound { opacity: .55; }

/* ---------- 화면 전환 ---------- */
#views { flex: 1; }
.view { display: none; }
.view.active { display: block; animation: fade .26s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 홈 ---------- */
.hero { padding: 10px 0 2px; }
.eyebrow {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .16em;
  color: #7dd3fc;
  text-transform: uppercase;
}
h1 {
  font-size: 34px;
  line-height: 1.16;
  font-weight: 900;
  letter-spacing: -.035em;
  margin: 8px 0 10px;
}
h1 em {
  font-style: normal;
  background: linear-gradient(100deg, #ffd60a, #ff4d6d 52%, #a78bfa);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.sub { color: #94a3b8; font-size: 13.5px; line-height: 1.5; margin-bottom: 16px; }

.mini-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 20px; }
.mini {
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 15px;
  padding: 10px 8px 9px;
  text-align: center;
}
.mini .mi { font-size: 15px; display: block; margin-bottom: 2px; opacity: .9; }
.mini b { display: block; font-size: 17px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.mini em { display: block; font-style: normal; font-size: 10.5px; color: #8494a9; margin-top: 1px; }

.sec-title {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .09em;
  color: #8494a9;
  margin: 0 0 9px 3px;
}

.game-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 13px 14px;
  margin-bottom: 9px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, .09);
  background: linear-gradient(155deg, rgba(255, 255, 255, .075), rgba(255, 255, 255, .022));
  transition: transform .13s ease, border-color .2s ease;
}
.game-card:active { transform: scale(.985); border-color: rgba(255, 255, 255, .2); }
.gc-icon {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 21px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .3);
}
.game-card[data-game="f1"] .gc-icon { background: linear-gradient(150deg, #ff2d55, #ff8a3d); }
.game-card[data-game="mem"] .gc-icon { background: linear-gradient(150deg, #2563eb, #22d3ee); }
.game-card[data-game="color"] .gc-icon { background: linear-gradient(150deg, #a78bfa, #f472b6); }
.gc-main { flex: 1 1 auto; min-width: 0; }
.gc-main b { display: block; font-size: 15px; font-weight: 700; letter-spacing: -.02em; }
.gc-main em { display: block; font-style: normal; font-size: 11.5px; color: #8fa0b6; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gc-best { font-size: 12.5px; font-weight: 800; color: #ffd60a; font-variant-numeric: tabular-nums; }
.gc-arrow { color: #5b6b81; font-size: 20px; line-height: 1; }

/* ---------- 종합 리포트 ---------- */
.card {
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, .09);
  background: linear-gradient(160deg, rgba(255, 255, 255, .065), rgba(255, 255, 255, .015));
  padding: 15px;
}
.report { margin-top: 18px; }
.report-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.report-score { font-size: 13px; font-weight: 800; color: #ffd60a; font-variant-numeric: tabular-nums; }
.report-body { display: flex; align-items: center; gap: 13px; }
.grade-emoji {
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  font-size: 27px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08);
}
.grade-text h3 { font-size: 17px; font-weight: 800; letter-spacing: -.02em; }
.grade-text p { font-size: 12px; color: #8fa0b6; margin-top: 3px; line-height: 1.45; }

.bars { margin: 15px 0 4px; display: grid; gap: 9px; }
.bar { display: grid; grid-template-columns: 58px 1fr 52px; align-items: center; gap: 9px; }
.bar span { font-size: 11.5px; color: #9aabc0; }
.bar i { display: block; height: 7px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.bar i b { display: block; height: 100%; width: 0%; border-radius: 99px; background: linear-gradient(90deg, #ffd60a, #ff4d6d); transition: width .5s ease; }
.bar em { font-style: normal; font-size: 11.5px; font-weight: 700; text-align: right; color: #cfdcee; font-variant-numeric: tabular-nums; }

.age-line {
  text-align: center;
  margin: 12px 0 4px;
  font-size: 12.5px;
  color: #9aabc0;
}
.age-line b { color: #7dd3fc; font-size: 16px; font-weight: 900; margin: 0 2px; }
.age-line[hidden] { display: none; }

.primary {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 15px;
  font-size: 15px;
  font-weight: 800;
  color: #180b00;
  background: linear-gradient(100deg, #ffd60a, #ff9d3d 60%, #ff5f8f);
  box-shadow: 0 8px 20px rgba(255, 120, 80, .22);
  transition: transform .12s ease, filter .2s ease;
}
.primary:active { transform: scale(.98); filter: brightness(1.05); }
.primary:disabled { opacity: .4; box-shadow: none; }
.ghost {
  display: block;
  width: 100%;
  margin-top: 9px;
  padding: 13px 16px;
  border-radius: 15px;
  font-size: 14.5px;
  font-weight: 700;
  color: #cfdcee;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .04);
}
.ghost:active { background: rgba(255, 255, 255, .09); }

.foot { text-align: center; padding: 22px 0 4px; }
.foot p { font-size: 11px; color: #6b7c92; line-height: 1.7; }
.foot p.dim { color: #4d5c70; }

/* ---------- 게임 공통 ---------- */
.game-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 14px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -.01em;
  padding: 7px 12px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, .1);
}
.chip-f1 { background: rgba(255, 45, 85, .14); color: #ff8fa5; border-color: rgba(255, 45, 85, .28); }
.chip-mem { background: rgba(34, 211, 238, .12); color: #7ee7f5; border-color: rgba(34, 211, 238, .26); }
.chip-color { background: rgba(167, 139, 250, .14); color: #cbb8ff; border-color: rgba(167, 139, 250, .3); }
.round { font-size: 13px; font-weight: 800; color: #9aabc0; font-variant-numeric: tabular-nums; }
.game-tip { font-size: 12.5px; color: #9aabc0; margin-bottom: 12px; line-height: 1.5; }

.result { text-align: center; padding: 16px 2px 4px; animation: fade .3s ease both; }
.result[hidden] { display: none; }
.res-label { font-size: 12px; letter-spacing: .1em; color: #8494a9; font-weight: 700; }
.res-big { display: flex; align-items: baseline; justify-content: center; gap: 4px; margin: 4px 0 2px; }
.res-big b {
  font-size: 62px;
  line-height: 1.02;
  font-weight: 900;
  letter-spacing: -.05em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(160deg, #ffffff, #b6c8ff 62%, #7dd3fc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.res-big span { font-size: 17px; font-weight: 700; color: #8fa0b6; }
.res-badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 99px;
  color: #04060b;
  background: linear-gradient(100deg, #ffd60a, #6ee7b7);
  margin: 6px 0 16px;
}
.res-badge.plain { background: rgba(255, 255, 255, .1); color: #a8b8cc; }
.res-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-bottom: 14px;
}
.res-grid > div {
  padding: 10px 6px;
  border-radius: 13px;
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .07);
}
.res-grid em { display: block; font-style: normal; font-size: 10.5px; color: #8494a9; }
.res-grid b { display: block; font-size: 14px; font-weight: 800; margin-top: 3px; letter-spacing: -.02em; }
.res-note { font-size: 12px; color: #9aabc0; line-height: 1.55; margin-bottom: 4px; }
.res-btns { margin-top: 4px; }

/* ---------- F1 ---------- */
#view-f1.active { display: flex; flex-direction: column; min-height: calc(100dvh - 132px); }
#f1Play { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
#f1Play[hidden] { display: none; }
.f1-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px 16px 30px;
  border-radius: 26px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .1);
  background:
    radial-gradient(120% 80% at 50% 0%, #16233d 0%, #0a0f1c 62%, #070a12 100%);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  transition: background .12s linear;
}
.f1-stage::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 12px;
  opacity: .22;
  background: repeating-conic-gradient(#fff 0% 25%, #111 0% 50%) 0 0 / 16px 16px;
}
.f1-stage.go { background: radial-gradient(120% 80% at 50% 0%, #0d3a24 0%, #07160f 65%, #060a09 100%); }
.f1-stage.miss { background: radial-gradient(120% 80% at 50% 0%, #3a0d18 0%, #16070c 65%, #0a0608 100%); }
.lights { display: flex; gap: 13px; margin-bottom: 6px; }
.lamp {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #161c28;
  border: 2px solid #2a3243;
  box-shadow: inset 0 3px 10px rgba(0, 0, 0, .8);
  transition: background .07s linear, box-shadow .07s linear, border-color .07s linear;
}
.lamp.red {
  background: radial-gradient(circle at 36% 30%, #ff9aa5, #e2112e 58%, #860a1c);
  border-color: #ff5a72;
  box-shadow: 0 0 20px rgba(255, 45, 85, .85), 0 0 44px rgba(255, 45, 85, .45);
}
.lamp.green {
  background: radial-gradient(circle at 36% 30%, #c2ffd8, #00c853 58%, #067a33);
  border-color: #6bffa8;
  box-shadow: 0 0 22px rgba(0, 230, 118, .9), 0 0 52px rgba(0, 230, 118, .5);
}
.f1-time {
  font-size: 46px;
  font-weight: 900;
  letter-spacing: -.045em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  min-height: 52px;
  color: #f1f6ff;
}
.f1-time span { font-size: 16px; font-weight: 700; color: #8fa0b6; margin-left: 3px; letter-spacing: 0; }
.f1-time.idle { font-size: 26px; color: #43536b; letter-spacing: .12em; }
.f1-msg { font-size: 15px; font-weight: 700; color: #cfdcee; min-height: 22px; }
.f1-hint { position: absolute; bottom: 26px; left: 18px; right: 18px; text-align: center; font-size: 11.5px; color: #7f90a6; }
.laps { display: flex; gap: 6px; margin-top: 10px; justify-content: center; flex-wrap: wrap; }
.lap {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .06);
  color: #a8b8cc;
  font-variant-numeric: tabular-nums;
}
.lap.best { background: rgba(255, 214, 10, .16); color: #ffd60a; }

/* ---------- 순간 기억력 ---------- */
#view-mem.active, #view-color.active { display: flex; flex-direction: column; min-height: calc(100dvh - 132px); }
#memPlay { display: flex; flex-direction: column; justify-content: center; flex: 1 1 auto; min-height: 0; }
#colorPlay { display: flex; flex-direction: column; justify-content: space-evenly; flex: 1 1 auto; min-height: 0; }
#memPlay[hidden], #colorPlay[hidden] { display: none; }
.mem-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mem-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  background: linear-gradient(160deg, #151c2c, #101623);
  border: 1px solid rgba(255, 255, 255, .08);
  display: grid;
  place-items: center;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: #e2ecff;
  font-variant-numeric: tabular-nums;
  transition: transform .12s ease, background .18s ease, border-color .18s ease;
  touch-action: manipulation;
}
.mem-cell.empty { background: rgba(255, 255, 255, .022); border-color: rgba(255, 255, 255, .035); }
.mem-cell.hit {
  background: linear-gradient(160deg, rgba(52, 211, 153, .22), rgba(52, 211, 153, .08));
  border-color: rgba(52, 211, 153, .55);
  color: #8ef0c4;
  transform: scale(.97);
}
.mem-cell.hid .num { opacity: 0; }
.mem-cell.hid::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  position: absolute;
}
.mem-cell.bad { background: rgba(255, 45, 85, .2); border-color: #ff5a72; animation: shake .3s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
.mem-count { text-align: center; margin-top: 12px; font-size: 12px; font-weight: 700; color: #7f90a6; font-variant-numeric: tabular-nums; }

/* ---------- 색깔 낚시 ---------- */
.timerbar { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; margin: 2px 0 14px; }
.timerbar i { display: block; height: 100%; width: 100%; border-radius: 99px; background: linear-gradient(90deg, #34d399, #ffd60a 62%, #ff4d6d); transition: width .1s linear; }
.stroop {
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: radial-gradient(110% 80% at 50% 0%, #151d2f, #0b101a 70%);
  padding: 16px 12px 10px;
  text-align: center;
}
.stroop-tip { font-size: 11.5px; color: #8fa0b6; }
.stroop-tip b { color: #e9eef7; }
.stroop-word {
  font-size: 58px;
  font-weight: 900;
  letter-spacing: -.04em;
  line-height: 1.28;
  min-height: 86px;
  display: grid;
  place-items: center;
  transition: color .06s linear;
}
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 12px; }
.choice {
  height: 78px;
  border-radius: 18px;
  background: var(--c);
  color: var(--t);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -.02em;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .22);
  transition: transform .09s ease, filter .12s ease;
}
.choice:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
.choice.miss { filter: brightness(1.35); outline: 3px solid rgba(255, 255, 255, .8); }
.live-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.live-row > div {
  text-align: center;
  padding: 9px 4px;
  border-radius: 13px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .06);
}
.live-row em { display: block; font-style: normal; font-size: 10.5px; color: #8494a9; }
.live-row b { display: block; font-size: 17px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  max-width: 86vw;
  padding: 11px 16px;
  border-radius: 13px;
  background: rgba(18, 24, 36, .96);
  border: 1px solid rgba(255, 255, 255, .14);
  color: #eaf1fb;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-height: 720px) {
  .f1-stage { min-height: 340px; }
  .stroop-word { font-size: 46px; min-height: 66px; }
  .choice { height: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; }
}
