:root {
  --bg: #140B2E;
  --bg-deep: #0D0720;
  --panel: #1F1446;
  --panel-2: #2E1F5C;
  --panel-3: #3A2A78;
  --line: #4A3A80;
  --screen: #142048;
  --pink: #FF4FA3;
  --pink-dark: #B8247A;
  --pink-soft: #FF7CC4;
  --cyan: #3DE8F5;
  --cyan-dark: #1C9AA8;
  --yellow: #FFD23F;
  --green: #4FD18B;
  --ink: #F4EFFF;
  --ink-2: #C9BFE8;
  --ink-3: #A99BD6;
  --ink-4: #8C7FBA;
  --px: 'Press Start 2P', monospace;
  --title: 'Do Hyeon', sans-serif;
  --body: 'Gowun Dodum', sans-serif;
  --el-목: #4FD18B; --el-화: #FF8A3D; --el-토: #D9B26A; --el-금: #B8C4D9; --el-수: #5B8CFF;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); }
body { min-height: 100vh; }
a { color: var(--cyan); }
button { font: inherit; cursor: pointer; }
.app { max-width: 430px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
#view { flex: 1; outline: none; }

.px { font-family: var(--px); font-size: 9px; letter-spacing: 0.5px; }
.green { color: var(--green); }
.yellow { color: var(--yellow); }
.cyan { color: var(--cyan); }
.pink { color: var(--pink-soft); }
.muted { color: var(--ink-3); }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; background: var(--bg-deep); border-bottom: 3px solid var(--panel-2); position: sticky; top: 0; z-index: 5; }
.brand { font-family: var(--title); font-size: 20px; color: var(--pink); text-decoration: none; }
.coin-pill { min-height: 40px; padding: 0 10px; background: var(--panel-2); border: 2px solid var(--yellow); color: var(--yellow); font-family: var(--px); font-size: 10px; }

.footer { padding: 16px; border-top: 2px solid var(--panel-2); font-size: 11px; line-height: 1.6; color: var(--ink-4); }

/* 공통 버튼 */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 56px; border: 0; text-decoration: none; font-family: var(--title); font-size: 20px; }
.btn-pink { background: var(--pink); color: var(--bg); border-bottom: 6px solid var(--pink-dark); }
.btn-cyan { background: var(--cyan); color: var(--bg); border-bottom: 6px solid var(--cyan-dark); }
.btn-yellow { background: var(--yellow); color: var(--bg); border-bottom: 6px solid #B8901A; }
.btn-ghost { background: var(--panel-2); color: var(--ink); border: 2px solid var(--cyan); min-height: 52px; font-size: 17px; }
.btn:active { transform: translateY(3px); border-bottom-width: 3px; }

.section { padding: 24px 16px 8px; display: flex; flex-direction: column; gap: 14px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; }
.section-head h2 { margin: 0; font-family: var(--title); font-weight: 400; font-size: 24px; }

/* ===== 로비: 오락실 게임기 ===== */
.cabinet { padding: 20px 16px 0; }
.marquee { background: var(--pink); padding: 6px; border-radius: 16px 16px 0 0; }
.bulbs { display: flex; justify-content: space-between; padding: 0 6px 4px; }
.bulbs span { width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); animation: blink 1.2s steps(1) infinite; }
.bulbs span:nth-child(even) { background: #fff; animation-delay: 0.6s; }
@keyframes blink { 50% { opacity: 0.35; } }
.marquee-sign { background: var(--panel); border-radius: 10px; padding: 14px 10px; text-align: center; display: flex; flex-direction: column; gap: 6px; }
.marquee-sign h1 { margin: 0; font-family: var(--title); font-weight: 400; font-size: 44px; line-height: 1; color: var(--yellow); letter-spacing: 2px; text-shadow: 3px 3px 0 var(--pink-dark); }
.cab-body { background: var(--panel-2); padding: 14px 22px 18px; border-left: 6px solid var(--panel-3); border-right: 6px solid var(--panel-3); }
.bezel { background: #0A0612; padding: 10px; border-radius: 14px; box-shadow: inset 0 0 0 3px var(--line); }
.crt { position: relative; background: var(--screen); border-radius: 10px; padding: 14px 10px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; overflow: hidden; }
.crt::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(255,255,255,0.05) 0 1px, transparent 1px 3px); }
.vs-row { display: flex; gap: 14px; align-items: flex-end; }
.vs-row figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.vs { padding-bottom: 46px; color: var(--yellow); font-size: 12px; }
.crt-title { font-family: var(--title); font-size: 22px; text-align: center; line-height: 1.25; }
.insert { animation: blink 1s steps(1) infinite; }
.panel { background: var(--panel-3); padding: 18px 20px 20px; border-radius: 0 0 6px 6px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 4px solid #4A3A98; }
.stick { display: flex; flex-direction: column; align-items: center; }
.stick i:nth-child(1) { width: 26px; height: 26px; border-radius: 50%; background: var(--pink); border: 3px solid var(--pink-dark); }
.stick i:nth-child(2) { width: 8px; height: 18px; background: var(--ink-2); margin-top: -4px; }
.stick i:nth-child(3) { width: 44px; height: 12px; border-radius: 6px; background: var(--bg-deep); }
.start-btn { flex: 1; min-height: 64px; border-radius: 32px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--pink); color: var(--bg); text-decoration: none; border: 0; border-bottom: 6px solid var(--pink-dark); }
.start-btn .px { font-size: 11px; }
.start-btn b { font-family: var(--title); font-weight: 400; font-size: 16px; }
.coin-btn { width: 64px; height: 64px; flex: none; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--cyan); color: var(--bg); border: 0; border-bottom: 6px solid var(--cyan-dark); }
.coin-btn .px { font-size: 8px; }
.coin-btn b { font-family: var(--title); font-weight: 400; font-size: 14px; }
.slot { margin: 0 auto; width: 150px; padding: 10px; background: var(--panel-2); border-radius: 0 0 8px 8px; display: flex; align-items: center; gap: 10px; justify-content: center; }
.slot i { width: 6px; height: 26px; background: var(--bg-deep); border: 2px solid var(--yellow); }

/* 오늘의 연애운 */
.today { margin: 20px 16px 0; padding: 16px; background: var(--bg-deep); border: 3px solid var(--panel-2); display: flex; gap: 14px; align-items: center; }
.today .hearts { color: var(--pink); font-size: 18px; letter-spacing: 2px; }
.today p { margin: 4px 0 0; font-size: 14px; line-height: 1.6; color: var(--ink-2); }

/* 미니 게임기 */
.games { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.mini { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); background: none; border: 0; padding: 0; text-align: left; }
.mini-top { border-radius: 10px 10px 0 0; padding: 6px; text-align: center; font-family: var(--title); font-size: 15px; color: var(--bg); }
.mini-body { background: var(--panel-2); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.mini-screen { background: var(--screen); border: 3px solid #0A0612; border-radius: 6px; height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.mini-screen small { font-size: 11px; color: var(--ink-2); }
.mini-foot { display: flex; justify-content: space-between; align-items: center; }
.dots { display: flex; gap: 4px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--pink); }
.dots i + i { background: var(--cyan); }
.soon { opacity: 0.75; }

/* 휴대용 가챠기 */
.handheld { display: flex; gap: 16px; align-items: center; padding: 18px; background: #B9B3D6; border-radius: 14px 14px 40px 14px; color: var(--bg); border: 0; width: 100%; text-align: left; }
.handheld-screen { width: 112px; flex: none; background: #4A4766; border-radius: 8px; padding: 10px; }
.handheld-screen div { background: #9BBC6B; border-radius: 3px; height: 92px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: #23361A; }
.handheld h3 { margin: 0; font-family: var(--title); font-weight: 400; font-size: 18px; line-height: 1.25; }
.handheld p { margin: 0; font-size: 13px; color: #2E2A48; }

/* ===== 플레이어 등록 ===== */
.form { padding: 20px 16px 24px; display: flex; flex-direction: column; gap: 18px; }
.form h1 { margin: 0; font-family: var(--title); font-weight: 400; font-size: 32px; }
.form .lead { margin: -10px 0 0; color: var(--ink-2); font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 8px; border: 0; padding: 0; margin: 0; }
.field > label, .field > legend { font-size: 14px; padding: 0; }
.input, select.input { min-height: 48px; padding: 0 12px; background: var(--panel); border: 2px solid var(--cyan); color: #fff; font-family: var(--body); font-size: 16px; border-radius: 0; width: 100%; }
.row { display: grid; gap: 8px; }
.row-3 { grid-template-columns: 1.4fr 1fr 1fr; }
.row-2 { grid-template-columns: 1fr 1fr; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { min-height: 46px; display: flex; align-items: center; justify-content: center; background: var(--panel); border: 2px solid var(--line); color: var(--ink-2); font-family: var(--title); font-size: 17px; cursor: pointer; }
.seg input:checked + label { background: var(--pink); border-color: var(--pink); color: var(--bg); }
.seg input:focus-visible + label { outline: 3px solid var(--yellow); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; color: var(--ink-2); }
.check input { width: 20px; height: 20px; accent-color: var(--pink); }
.error { color: #FF9AA8; font-size: 14px; min-height: 20px; margin: 0; }
.hint { font-size: 12px; color: var(--ink-4); text-align: center; margin: 0; }

/* 로딩 */
.loading { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; padding: 24px; }
.loading .bounce { animation: bounce 0.5s steps(2) infinite; }
@keyframes bounce { 50% { transform: translateY(-8px); } }
.loading p { font-family: var(--title); font-size: 22px; margin: 0; }
.bar { width: 220px; height: 14px; background: var(--panel-2); border: 2px solid var(--line); }
.bar i { display: block; height: 100%; width: 0; background: var(--pink); animation: fill 1.6s steps(8) forwards; }
@keyframes fill { to { width: 100%; } }

/* ===== 결과 ===== */
.progress { padding: 12px 16px; border-bottom: 2px solid var(--panel-2); display: flex; flex-direction: column; gap: 8px; }
.progress-row { display: flex; justify-content: space-between; }
.progress .track { height: 10px; background: var(--panel-2); }
.progress .track i { display: block; height: 100%; background: var(--pink); }

.card-wrap { padding: 24px 16px 8px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.card { width: 230px; padding: 16px; background: var(--panel); border: 4px solid var(--yellow); box-shadow: 0 0 0 4px var(--bg), 0 0 0 8px var(--yellow); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.card[data-grade="SSR"] { border-color: var(--pink); box-shadow: 0 0 0 4px var(--bg), 0 0 0 8px var(--pink), 0 0 24px var(--pink); }
.card[data-grade="SR"] { border-color: var(--yellow); }
.card[data-grade="R"] { border-color: #B8C4D9; box-shadow: 0 0 0 4px var(--bg), 0 0 0 8px #B8C4D9; }
.card[data-grade="N"] { border-color: var(--line); box-shadow: 0 0 0 4px var(--bg), 0 0 0 8px var(--line); }
.card-top { align-self: stretch; display: flex; justify-content: space-between; }
.card-art { width: 112px; height: 112px; display: flex; align-items: center; justify-content: center; }
.card h2 { margin: 0; font-family: var(--title); font-weight: 400; font-size: 28px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.tag { padding: 4px 8px; font-size: 12px; font-weight: 700; color: var(--bg); background: var(--pink); }
.tag.cyan { background: var(--cyan); }
.tag.yellow { background: var(--yellow); }

.chart { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; text-align: center; }
.chart .head { font-size: 12px; color: var(--ink-4); }
.chart .head.me { color: var(--pink-soft); font-weight: 700; }
.cell { padding: 10px 0; border: 2px solid; }
.cell b { display: block; font-family: var(--title); font-weight: 400; font-size: 26px; }
.cell small { font-size: 11px; color: var(--ink-2); }
.cell.empty { border-style: dashed; border-color: var(--line); color: var(--ink-4); }
.cell.empty b { font-size: 18px; }

.stage { margin: 0 16px 16px; padding: 18px; background: var(--panel); border: 2px solid var(--pink); display: flex; flex-direction: column; gap: 10px; }
.stage-head { display: flex; justify-content: space-between; align-items: center; }
.stage h3 { margin: 0; font-family: var(--title); font-weight: 400; font-size: 22px; }
.stage p { margin: 0; font-size: 15px; line-height: 1.75; color: #E6DEFF; }
.basis { padding: 10px 12px; background: var(--bg); font-size: 12px; line-height: 1.6; color: var(--ink-3); }
.mong-says { display: flex; gap: 10px; align-items: flex-start; }
.mong-says .bubble { flex: 1; padding: 12px 14px; background: var(--panel-2); font-size: 14px; line-height: 1.6; border-radius: 12px; }

.graph { position: relative; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 130px; border-bottom: 2px solid var(--line); }
.bars i { flex: 1; background: #6B5AA8; }
.bars i.top { background: var(--pink); }
.graph.locked .bars { filter: blur(6px); opacity: 0.8; }
.graph .q { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--title); font-size: 20px; text-shadow: 0 2px 6px #000; }
.months { display: flex; gap: 4px; font-size: 10px; color: var(--ink-3); text-align: center; }
.months span { flex: 1; }

.locked-list { display: flex; flex-direction: column; gap: 8px; }
.locked { padding: 12px 14px; background: var(--panel); border-left: 4px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.locked .t { display: flex; justify-content: space-between; font-size: 15px; }
.locked p { margin: 0; font-size: 13px; color: var(--ink-3); }

.cta { margin: 8px 16px 16px; padding: 18px; background: var(--panel-2); border: 3px dashed var(--yellow); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.cta h3 { margin: 0; font-family: var(--title); font-weight: 400; font-size: 22px; }
.cta p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.6; }
.actions { padding: 0 16px 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* 모달 */
.modal { position: fixed; inset: 0; background: rgba(5, 2, 15, 0.75); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.modal[hidden] { display: none; }
.modal-box { width: 100%; max-width: 340px; background: var(--panel); border: 4px solid var(--pink); padding: 22px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.modal-box h2 { margin: 0; font-family: var(--title); font-weight: 400; font-size: 24px; }
.modal-box p { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.6; }

.sprite { image-rendering: pixelated; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
