/* style.css — 부엉이의 소용돌이 비행 */
:root {
  --ink: #0b1438;
  --navy: #0d1b52;
  --panel: rgba(11, 22, 66, 0.86);
  --line: rgba(160, 190, 255, 0.28);
  --text: #eef3ff;
  --muted: #b7c4ec;
  --yellow: #ffd23f;
  --yellow-2: #ffe680;
  --sky: #8dbef0;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #050b24; color: var(--text);
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
[hidden] { display: none !important; }
#app { position: fixed; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#cv { position: absolute; inset: 0; display: block; }
#fx { position: absolute; inset: 0; pointer-events: none; z-index: 30; }
.ic { width: 1em; height: 1em; vertical-align: -0.14em; flex: none; }
.ic.star { color: var(--yellow); }
.ic.ok { color: #9be39b; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

/* ── HUD ── */
#hud { position: absolute; left: 0; right: 0; top: 0; z-index: 10; pointer-events: none;
  padding: calc(8px + var(--safe-t)) calc(10px + var(--safe-r)) 0 calc(10px + var(--safe-l)); }
.hud-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hud-l, .hud-r { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 12px; border-radius: 17px;
  background: rgba(8, 16, 52, 0.62); border: 1px solid var(--line); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.chip .ic { color: var(--yellow); font-size: 18px; }
.chip.mult { color: var(--ink); background: var(--yellow); border-color: var(--yellow); padding: 0 10px; }
.chip.mult.pop { animation: pop 0.35s ease-out; }
@keyframes pop { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }
#hud .goal { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px #000a; }
#hud .goal.done { color: #b6f0a8; }
.feathers { display: inline-flex; gap: 2px; height: 34px; align-items: center; padding: 0 8px; border-radius: 17px; background: rgba(8, 16, 52, 0.62); border: 1px solid var(--line); }
.feathers i { width: 16px; height: 24px; display: block;
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 24'%3E%3Cpath d='M8 1.5C13 7 12.5 15 8 22.5 3.5 15 3 7 8 1.5z' fill='%23d08f4f' stroke='%230b1438' stroke-width='1.6'/%3E%3Cpath d='M8 5v18' stroke='%230b1438' stroke-width='1.3'/%3E%3C/svg%3E");
  transform: rotate(18deg); transition: opacity 0.3s, transform 0.3s; }
.feathers i.lost { opacity: 0.22; transform: rotate(60deg) translateY(4px); filter: grayscale(1); }
.ibtn, .paint { pointer-events: auto; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: rgba(8, 16, 52, 0.62);
  display: grid; place-items: center; padding: 0; color: var(--text); }
.ibtn .ic { font-size: 22px; }
.ibtn:active, .paint:active { transform: scale(0.94); }
#hSound .mute { display: none; }
#hSound.muted .mute { display: inline; }
#hSound.muted .wave { display: none; }
.paint svg { width: 38px; height: 38px; transform: rotate(-90deg); }
.paint .pbg { fill: rgba(255, 255, 255, 0.06); stroke: rgba(255, 255, 255, 0.18); stroke-width: 4; }
.paint .pfill { fill: none; stroke: var(--yellow); stroke-width: 4; stroke-dasharray: 100.5; stroke-dashoffset: 100.5; stroke-linecap: round; transition: stroke-dashoffset 0.25s; }
.paint .pmoon { fill: rgba(255, 230, 128, 0.45); transform: rotate(90deg); transform-origin: 20px 20px; }
.paint.full { background: var(--yellow); border-color: var(--yellow); }
.paint.full .pmoon { fill: var(--ink); }
.paint.full .pbg { stroke: transparent; fill: transparent; }
.prog { position: relative; height: 4px; margin: 8px 4px 0; border-radius: 2px; background: rgba(255, 255, 255, 0.14); overflow: visible; }
.prog i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 2px; background: var(--yellow-2); }
.prog .pend { position: absolute; right: -4px; top: -4px; width: 12px; height: 12px; border-radius: 50%; background: #fff8cf; box-shadow: 0 0 0 2px var(--ink); }

#hint { position: absolute; left: 50%; top: calc(64px + var(--safe-t)); transform: translate(-50%, -6px); z-index: 12; pointer-events: none;
  max-width: min(92vw, 560px); padding: 9px 16px; border-radius: 12px; background: rgba(8, 16, 52, 0.85); border: 1px solid var(--line);
  font-size: 16px; line-height: 1.35; text-align: center; opacity: 0; transition: opacity 0.25s, transform 0.25s; }
#hint.on { opacity: 1; transform: translate(-50%, 0); }

#ready { position: absolute; inset: 0; z-index: 11; display: grid; place-items: center; pointer-events: none; }
.ready-card { text-align: center; padding: 18px 26px; border-radius: 16px; background: rgba(8, 16, 52, 0.72); border: 1px solid var(--line); max-width: min(90vw, 460px); }
.ready-card p { margin: 0; }
.ready-card .rt { font-size: 22px; font-weight: 800; }
.ready-card .rg { margin-top: 6px; color: var(--yellow-2); font-size: 16px; }
.ready-card .rh { margin-top: 6px; color: var(--muted); font-size: 15px; }
.ready-card .rh:empty, .ready-card .rg:empty { display: none; }
.ready-card .rgo { margin-top: 12px; font-size: 15px; letter-spacing: 0.02em; color: var(--text); opacity: 0.85; }

#rotate { position: absolute; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); z-index: 12; padding: 8px 14px; border-radius: 10px;
  background: rgba(8, 16, 52, 0.85); border: 1px solid var(--line); font-size: 14px; pointer-events: none; white-space: nowrap; }

/* ── 화면(메뉴·멈춤·결과·도움말) ── */
.screen { position: absolute; inset: 0; z-index: 20; }
.modal { display: grid; place-items: center; background: rgba(4, 9, 32, 0.55); padding: calc(12px + var(--safe-t)) calc(12px + var(--safe-r)) calc(12px + var(--safe-b)) calc(12px + var(--safe-l)); }
.card { position: relative; width: min(440px, 100%); max-height: 100%; overflow: auto; padding: 22px 22px 18px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45); user-select: text; -webkit-user-select: text; touch-action: pan-y; }
.card h2 { margin: 0 40px 6px 0; font-size: 24px; }
.card .x { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 10px; border: none; background: #c8463c; color: #fff; font-size: 17px; line-height: 1; display: grid; place-items: center; }
.card .x:hover { background: #dd5348; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.card a { color: var(--yellow-2); }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btn { flex: 1 1 auto; min-height: 46px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.07); font-size: 16px; font-weight: 600; }
.btn:hover { background: rgba(255, 255, 255, 0.13); }
.btn.primary { background: var(--yellow); color: var(--ink); border-color: var(--yellow); font-weight: 800; }
.btn.primary:hover { background: var(--yellow-2); }
.res-msg { margin: 4px 0 10px; color: var(--muted); line-height: 1.5; }
.res-msg:empty { display: none; }
.res-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.res-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 17px; }
.res-list b { font-variant-numeric: tabular-nums; }
.res-list em { font-style: normal; font-size: 13px; color: var(--ink); background: var(--yellow); border-radius: 6px; padding: 1px 6px; margin-left: 4px; vertical-align: 2px; }
.res-list small { color: var(--muted); font-weight: 400; margin-left: 4px; }
.res-list .gl { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.res-list .gl.ok { color: #b6f0a8; }
.help-list { margin: 8px 0 12px; padding-left: 0; list-style: none; line-height: 1.5; font-size: 15px; }
.help-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.help-list b { color: var(--yellow-2); margin-right: 6px; }

/* 메뉴 */
#menu { display: flex; justify-content: flex-end; align-items: center; overflow: auto; touch-action: pan-y;
  padding: calc(14px + var(--safe-t)) calc(16px + var(--safe-r)) calc(14px + var(--safe-b)) calc(16px + var(--safe-l)); }
.menu-in { width: min(640px, 66vw); margin: auto 2vw auto auto; padding: 22px 22px 16px; border-radius: 20px; background: rgba(9, 18, 58, 0.72); border: 1px solid var(--line); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.title h1 { margin: 0; font-size: clamp(24px, 3.2vw, 34px); font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; }
.title h1 small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; vertical-align: 4px; margin-left: 4px; }
.title .sub { margin: 6px 0 14px; color: var(--muted); font-size: 16px; }
.nights { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.night { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 104px; padding: 10px 12px; text-align: left;
  border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); }
body:not(.kbd) .night:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 230, 128, 0.6); }
.night .nn { font-size: 13px; color: var(--yellow-2); font-weight: 700; }
.night .nm { font-size: 19px; font-weight: 800; }
.night .ng { font-size: 13px; color: var(--muted); line-height: 1.35; }
.night .ns { margin-top: auto; padding-top: 4px; font-size: 13px; color: var(--text); display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.night.locked { opacity: 0.55; }
.night .met-tag { display: inline-flex; align-items: center; gap: 2px; margin-left: 6px; color: #b6f0a8; }
.night.locked .ns { color: var(--muted); }
.night.endless { background: rgba(255, 210, 63, 0.10); border-color: rgba(255, 210, 63, 0.45); }
.night.endless .nn { font-size: 16px; line-height: 1; }
.night.shake { animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.menu-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.total { font-size: 14px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.opt { min-height: 38px; padding: 0 13px; border-radius: 19px; border: 1px solid var(--line); background: transparent; font-size: 14px; color: var(--muted); }
.opt[aria-pressed="true"] { background: rgba(255, 210, 63, 0.16); border-color: rgba(255, 210, 63, 0.7); color: var(--text); }
.opt[aria-pressed="true"]::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); margin-right: 6px; vertical-align: 2px; }

/* 좁은 화면 */
@media (max-width: 760px) {
  #menu { justify-content: center; align-items: flex-end; }
  .menu-in { width: 100%; margin: 0; padding: 16px 14px 12px; }
  .nights { grid-template-columns: repeat(2, 1fr); }
  .night { min-height: 92px; }
}
/* 낮은 가로 화면(휴대폰 가로) */
@media (max-height: 520px) and (orientation: landscape) {
  #menu { align-items: center; }
  .menu-in { width: min(720px, 72vw); padding: 12px 14px 10px; margin: auto 1vw auto auto; }
  .title h1 { font-size: 22px; }
  .title .sub { margin: 2px 0 8px; font-size: 14px; }
  .nights { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .night { min-height: 0; padding: 6px 10px; }
  .night .nm { font-size: 16px; }
  .night .ng { display: none; }
  .menu-foot { margin-top: 8px; }
  .opt { min-height: 34px; }
  .chip { height: 30px; font-size: 16px; }
  .feathers { height: 30px; }
  .ibtn, .paint { width: 40px; height: 40px; }
  #hint { top: calc(50px + var(--safe-t)); font-size: 15px; }
  .card { padding: 14px 16px 12px; }
  .card h2 { font-size: 20px; }
  .res-list li { padding: 5px 2px; font-size: 15px; }
  .btns { margin-top: 10px; }
  .btn { min-height: 40px; }
}
@media (max-width: 420px) {
  #hud .goal { display: none; }
  .chip { padding: 0 10px; }
  .hud-r { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .chip.mult.pop, .night.shake { animation: none; }
}
