/* 깨 봐, 내 던전 — 폰 세로 우선 · 맥 14인치에서는 가운데 480px 기둥 · 글자 크게 */
:root {
  --bg: #16131f; --panel: #221d31; --panel2: #2c2540; --line: #3d3456;
  --text: #f4efe6; --dim: #b9b0c9; --gold: #f5c542; --red: #ef4444; --green: #22c55e; --blue: #60a5fa;
  --r: 14px; --fs: 18px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font: var(--fs)/1.45 -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif; overscroll-behavior: none; }
button, input, select { font: inherit; color: inherit; }
#app { max-width: 480px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
#top { display: flex; align-items: center; justify-content: space-between; padding: calc(8px + env(safe-area-inset-top)) 14px 8px; }
.logo-btn { background: none; border: 0; padding: 4px 0; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.logo-btn img { height: 40px; image-rendering: pixelated; }
.logo-text { font-weight: 800; font-size: 20px; color: var(--gold); letter-spacing: -0.5px; }
.icon-btn { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: 44px; height: 44px; font-size: 20px; cursor: pointer; }
main { flex: 1; padding: 0 14px 16px; }
#nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; background: rgba(22,19,31,.96); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
#nav a { flex: 1; max-width: 160px; display: flex; flex-direction: column; align-items: center; padding: 8px 0 10px; color: var(--dim); text-decoration: none; font-size: 15px; }
#nav a b { font-size: 22px; line-height: 1.2; }
#nav a.on { color: var(--gold); }
body.playing #nav { display: none; }
body.playing #app { padding-bottom: 0; }

h1 { font-size: 28px; margin: 12px 0 6px; } h2 { font-size: 22px; margin: 18px 0 8px; } h3 { font-size: 19px; margin: 12px 0 6px; }
p { margin: 6px 0; } .dim { color: var(--dim); } .small { font-size: 15px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin: 10px 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 52px; padding: 0 18px; border-radius: 14px; border: 0; background: var(--panel2); font-weight: 700; font-size: 18px; cursor: pointer; }
.btn.big { width: 100%; min-height: 60px; font-size: 20px; }
.btn.gold { background: var(--gold); color: #241b05; }
.btn.red { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; } .row > * { flex: 1; } .wrap { flex-wrap: wrap; }
input[type=text] { width: 100%; min-height: 52px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: #120f1a; font-size: 19px; }
select { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: #120f1a; padding: 0 8px; }
.hero-box { text-align: center; padding: 24px 0 8px; }
.hero-box img.logo { width: min(360px, 92%); image-rendering: pixelated; display: block; margin: 0 auto; }
.hero-box .big-title { font-size: 38px; font-weight: 900; color: var(--gold); margin: 10px 0 4px; letter-spacing: -1px; }
.code { font: 700 24px/1.2 ui-monospace, Menlo, monospace; letter-spacing: 2px; background: #120f1a; padding: 10px 12px; border-radius: 10px; text-align: center; user-select: all; }

/* 던전 판 */
.tabs { display: flex; gap: 6px; background: var(--panel); border-radius: 14px; padding: 5px; margin: 6px 0 10px; }
.tabs button { flex: 1; min-height: 46px; border: 0; border-radius: 10px; background: transparent; color: var(--dim); font-weight: 700; cursor: pointer; }
.tabs button.on { background: var(--gold); color: #241b05; }
.dcard { display: flex; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; margin: 8px 0; cursor: pointer; }
.dcard:active { transform: scale(.99); }
.dcard .thumb { width: 96px; flex: none; display: flex; align-items: center; justify-content: center; }
.dcard .thumb canvas { border-radius: 6px; }
.dcard .info { flex: 1; min-width: 0; }
.dcard .t { font-weight: 800; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dcard .a { color: var(--dim); font-size: 15px; }
.stats { display: flex; gap: 10px; font-size: 15px; margin-top: 4px; flex-wrap: wrap; }
.rate { font-weight: 800; color: var(--gold); }
.rate.hard { color: var(--red); }
.empty { text-align: center; padding: 30px 0; color: var(--dim); }

/* 플레이 */
.playbar { display: flex; align-items: center; gap: 8px; margin: 2px 0 8px; }
.playbar .title { flex: 1; min-width: 0; }
.playbar .title b { display: block; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud { display: flex; gap: 8px; margin-bottom: 8px; }
.hud div { flex: 1; background: var(--panel); border-radius: 12px; padding: 6px 8px; text-align: center; font-size: 15px; color: var(--dim); }
.hud b { display: block; font-size: 22px; color: var(--text); font-variant-numeric: tabular-nums; }
.stage { position: relative; display: flex; justify-content: center; }
.stage canvas { display: block; touch-action: none; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
.hint { text-align: center; color: var(--dim); font-size: 15px; margin: 6px 0; min-height: 22px; }
.pad { display: grid; grid-template-columns: repeat(3, 104px); grid-template-rows: repeat(3, 84px); gap: 8px; justify-content: center; margin: 10px auto 0; user-select: none; -webkit-user-select: none; }
.pad button { border: 0; border-radius: 18px; background: var(--panel2); font-size: 36px; touch-action: none; cursor: pointer; }
.pad button:active, .pad button.held { background: var(--gold); color: #241b05; }
.pad .u { grid-column: 2; grid-row: 1; } .pad .l { grid-column: 1; grid-row: 2; } .pad .w { grid-column: 2; grid-row: 2; font-size: 16px; font-weight: 700; } .pad .r { grid-column: 3; grid-row: 2; } .pad .d { grid-column: 2; grid-row: 3; }
.overlay { position: fixed; inset: 0; background: rgba(10,8,16,.82); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.overlay .box { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 20px; width: 100%; max-width: 420px; text-align: center; }
.overlay .box h2 { font-size: 30px; margin: 4px 0 8px; color: var(--gold); }
.overlay .box .btn { margin-top: 10px; }
.big-num { font-size: 20px; margin: 4px 0; }

/* 편집기 */
.ed-top { display: flex; gap: 8px; align-items: center; margin: 4px 0 8px; }
.palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 8px 0; }
.palette button { min-height: 54px; border-radius: 10px; border: 2px solid transparent; background: var(--panel2); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 12px; color: var(--dim); padding: 2px; cursor: pointer; }
.palette button canvas { width: 28px; height: 28px; image-rendering: pixelated; }
.palette button.on { border-color: var(--gold); color: var(--text); }
.props { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin: 8px 0; font-size: 16px; }
.props label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0; }
.props .stepper { display: flex; align-items: center; gap: 6px; }
.props .stepper button { width: 44px; height: 40px; border-radius: 10px; border: 0; background: var(--panel2); font-size: 20px; cursor: pointer; }
.props .stepper span { min-width: 34px; text-align: center; font-weight: 800; font-size: 19px; }
.seg { display: flex; gap: 4px; } .seg button { min-width: 44px; height: 40px; border: 0; border-radius: 10px; background: var(--panel2); cursor: pointer; font-size: 18px; } .seg button.on { background: var(--gold); color: #241b05; }
.errs { color: #fca5a5; font-size: 15px; margin: 6px 0; }
.ok { color: #86efac; font-size: 16px; font-weight: 700; }
#toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: #000c; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 16px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 30; max-width: 90%; text-align: center; }
#toast.on { opacity: 1; }

@media (min-width: 700px) { :root { --fs: 19px; } #app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
@media (max-height: 700px) { .pad { grid-template-rows: repeat(3, 64px); } }
@media (max-width: 360px) { .pad { grid-template-columns: repeat(3, 92px); } }
.learn-tip { background: var(--gold); color: #241b05; font-weight: 800; font-size: 21px; line-height: 1.35; border-radius: 14px; padding: 10px 14px; margin: 0 0 8px; text-align: center; }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245,197,66,.6); } 50% { transform: scale(1.04); box-shadow: 0 0 0 10px rgba(245,197,66,0); } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

.badge-gold { color: #241b05; background: linear-gradient(135deg, #f8dc6b, #d9a514); border: 1px solid #fff3b0; border-radius: 8px; padding: 0 6px; font-weight: 800; }
canvas.skinmark { width: 18px; height: 18px; vertical-align: -3px; margin-left: 4px; image-rendering: pixelated; }
[hidden] { display: none !important; }
