/* 네온 바이트 — 글꼴·그림을 인터넷에서 받지 않는다 */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: radial-gradient(circle at 50% 0%, #101a3d 0%, #050816 60%);
  color: #e2e8f0;
  font-family: system-ui, -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
  word-break: keep-all; overflow-wrap: break-word;
  touch-action: none;
}
.hidden { display: none !important; }
.dim { color: #94a3b8; font-size: 12px; line-height: 1.5; }

#app {
  position: relative; display: flex; flex-direction: column;
  height: 100vh; height: 100dvh; max-width: 560px; margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button {
  font: inherit; color: #e2e8f0; cursor: pointer; touch-action: manipulation;
  background: #111c3a; border: 1px solid #334a7d; border-radius: 10px; padding: 8px 10px; font-weight: 700;
}
button:focus-visible { outline: 2px solid #fde047; outline-offset: 2px; }
button:disabled { opacity: 0.4; cursor: default; }

/* 머리줄 */
header { flex: none; padding: 6px 10px 4px; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h1 { font-size: 17px; color: #67e8f9; text-shadow: 0 0 10px rgba(34, 211, 238, 0.8); white-space: nowrap; }
h1 small { font-size: 9px; color: #f0abfc; letter-spacing: 2px; margin-left: 4px; text-shadow: none; }
.bar-buttons { display: flex; gap: 6px; }
.icon-btn { width: 38px; height: 34px; padding: 0; font-size: 15px; }
.stats { display: grid; grid-template-columns: 1.15fr 1.3fr 1fr 0.8fr; gap: 4px; margin-top: 4px; }
.stat { background: rgba(15, 23, 42, 0.8); border: 1px solid #1e2b4f; border-radius: 8px; padding: 2px 6px; min-width: 0; }
.stat span { display: block; font-size: 9px; color: #94a3b8; white-space: nowrap; }
.stat b { display: block; font-size: 13px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
#lives { color: #fb7185; }
/* 게임 화면 */
#stageArea { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#game { display: block; border-radius: 6px; box-shadow: 0 0 18px rgba(34, 211, 238, 0.22); }
#chips { position: absolute; top: 4px; left: 4px; right: 4px; display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; pointer-events: none; }
.chip { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 20px; background: rgba(2, 6, 23, 0.85); border: 1px solid #475569; }
.chip.power { border-color: #fde047; color: #fde047; }
.chip.hourglass { border-color: #facc15; }
.chip.freeze { border-color: #38bdf8; color: #bae6fd; }
.chip.magnet { border-color: #f472b6; }
.chip.shield { border-color: #c084fc; }
#toast {
  position: absolute; left: 8px; right: 8px; bottom: 6px; margin: 0 auto; width: fit-content; max-width: calc(100% - 16px);
  background: rgba(2, 6, 23, 0.92); border: 1px solid #22d3ee; border-radius: 20px; padding: 5px 12px;
  font-size: 12px; font-weight: 700; text-align: center; pointer-events: none; opacity: 0; transition: opacity 0.2s;
}
#toast.on { opacity: 1; }

/* 방향 버튼 */
.dpad {
  flex: none; display: grid; gap: 4px; justify-content: center; padding: 4px 0 8px;
  grid-template-columns: repeat(3, 70px); grid-template-rows: repeat(2, 52px);
  grid-template-areas: ". up skill" "left down right";
}
.pad { font-size: 20px; padding: 0; border-radius: 14px; touch-action: none; }
.pad.up { grid-area: up; } .pad.down { grid-area: down; } .pad.left { grid-area: left; } .pad.right { grid-area: right; }
.pad:active, .pad.active { background: #1d4ed8; border-color: #67e8f9; }

/* 창 */
.overlay {
  position: absolute; inset: 0; z-index: 10; display: flex; overflow-y: auto; touch-action: pan-y;
  background: rgba(3, 7, 22, 0.9); padding: 10px;
}
.panel { margin: auto; width: 100%; max-width: 400px; text-align: center; display: flex; flex-direction: column; gap: 9px; }
.panel h2 { font-size: 19px; }
.row { display: flex; gap: 6px; justify-content: center; }
.row button { flex: 1; font-size: 13px; white-space: nowrap; padding-left: 4px; padding-right: 4px; }
#lives { letter-spacing: -1px; text-overflow: clip; }
.big {
  font-size: 17px; padding: 11px; border: none; color: #04101f;
  background: linear-gradient(90deg, #22d3ee, #a3e635); box-shadow: 0 0 16px rgba(34, 211, 238, 0.45);
}

#titleArt { display: flex; justify-content: center; align-items: center; gap: 8px; }
.logo { font-size: 30px !important; color: #67e8f9; text-shadow: 0 0 14px rgba(34, 211, 238, 0.9), 0 0 3px #fff; letter-spacing: 2px; }
#chars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.char { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 2px 4px; }
.char-name { font-size: 11px; white-space: nowrap; }
.char.selected { border-color: #a3e635; box-shadow: 0 0 10px rgba(163, 230, 53, 0.5); }
.char.locked canvas { filter: saturate(0.6) brightness(0.62); }
.char.locked .char-name { color: #64748b; }
.char .lock { position: absolute; top: 3px; right: 5px; font-size: 11px; }
.char.asking { border-color: #fde047; }
#charInfo { min-height: 50px; display: flex; flex-direction: column; justify-content: center; font-size: 12px; line-height: 1.45; padding: 5px 8px; border: 1px dashed #334a7d; border-radius: 10px; }
#charInfo.asking { border: 1px solid #fde047; background: rgba(113, 63, 18, 0.3); }
.how-title { font-weight: 800; color: #fde047; }

#zones { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.zone { display: flex; flex-direction: column; align-items: center; padding: 3px 1px; line-height: 1.2; min-width: 0; }
.zone b { font-size: 13px; color: var(--zone); }
.zone span { font-size: 9px; white-space: nowrap; }
.zone.selected { border-color: var(--zone); box-shadow: 0 0 8px var(--zone); }
.zone.locked { opacity: 0.6; }
.zone.locked b::after { content: ' 👀'; font-size: 9px; }
#resultNote { font-size: 13px; font-weight: 700; color: #fde047; line-height: 1.5; }
.chip.boss { border-color: #f43f5e; color: #fecdd3; }
.chip.key { border-color: #fbbf24; color: #fde68a; }
#metaLine { font-size: 12px; font-weight: 800; color: #fde68a; }
.menu { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.menu button { display: flex; flex-direction: column; align-items: center; padding: 4px 0; font-size: 16px; line-height: 1.2; }
.menu button span { font-size: 11px; }
.skill-btn {
  width: 52px; height: 52px; border-radius: 50%; padding: 0; font-size: 22px; touch-action: none; position: relative;
  border: none; background: conic-gradient(#fde047 var(--charge, 0%), #334155 0);
}
.skill-btn .skill-icon { position: absolute; inset: 4px; border-radius: 50%; background: #0b1430; display: flex; align-items: center; justify-content: center; filter: grayscale(0.8); }
.skill-btn.ready .skill-icon { filter: none; background: #422006; }
.skill-btn.ready { box-shadow: 0 0 14px #fde047; animation: ready 0.9s infinite alternate; }
.skill-btn:disabled { opacity: 0.5; }
@keyframes ready { from { transform: scale(1); } to { transform: scale(1.09); } }
.skill-pad { grid-area: skill; align-self: center; justify-self: center; }
.skill-float { position: absolute; left: 8px; bottom: 8px; z-index: 5; display: none; }
body[data-phase="idle"] .skill-btn { visibility: hidden; }
#pickBox { font-size: 12px; display: flex; flex-direction: column; gap: 6px; }
#pickCards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pick { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-color: #a855f7; background: #1d1236; }
.pick .pick-icon { font-size: 24px; }
.pick b { font-size: 12px; }
.pick small { font-size: 10px; color: #c4b5fd; line-height: 1.3; }
.shop-row { display: flex; align-items: center; gap: 10px; background: #0b1430; border: 1px solid #1e2b4f; border-radius: 10px; padding: 6px 8px; }
.shop-row canvas { flex: none; }
.shop-row .grow { flex: 1; min-width: 0; }
.shop-row.on { border-color: #a3e635; }
.shop-row.unknown canvas { filter: brightness(0); opacity: 0.5; }
.shop-icon { font-size: 24px; width: 36px; text-align: center; flex: none; }
.buy { flex: none; font-size: 12px; min-width: 72px; }
.chip.frenzy { border-color: #fb923c; color: #fed7aa; }
/* 놀이 고르기·지도 만들기 */
.mode-row { display: flex; align-items: center; gap: 10px; text-align: left; padding: 8px 10px; background: #0b1430; width: 100%; }
.mode-row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.mode-row small { font-size: 11px; color: #94a3b8; font-weight: 400; }
.mode-row small.best { color: #fde047; font-weight: 700; }
#editorCanvas { align-self: center; touch-action: manipulation; border: 1px solid #334a7d; border-radius: 4px; }
#editorMsg { text-align: center; font-weight: 700; color: #a3e635; font-size: 12px; }
#editorMsg.bad { color: #fb7185; }
.check { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12px; }
#edCode { flex: 1; min-width: 0; font: inherit; font-size: 16px; background: #020617; color: #fde047; border: 1px solid #334a7d; border-radius: 10px; padding: 6px 8px; user-select: text; -webkit-user-select: text; }
.chip.mode { border-color: #22d3ee; color: #a5f3fc; }

/* 둘이서: 위쪽에 바이러스 조작판(마주 앉도록 거꾸로) */
.dpad2 {
  display: none; flex: none; gap: 4px; justify-content: center; padding: 6px 0 2px; transform: rotate(180deg); order: -1;
  grid-template-columns: repeat(3, 70px); grid-template-rows: repeat(2, 48px); grid-template-areas: ". up ." "left down right";
}
.pad2 { font-size: 20px; padding: 0; border-radius: 14px; touch-action: none; border-color: #f43f5e; }
.pad2.up { grid-area: up; } .pad2.down { grid-area: down; } .pad2.left { grid-area: left; } .pad2.right { grid-area: right; }
.pad2:active, .pad2.active { background: #9f1239; }
body[data-mode="duo"] .dpad2 { display: grid; }
body[data-mode="duo"] header { display: none; }
body[data-mode="duo"] .dpad { display: grid; grid-template-rows: repeat(2, 48px); }
body[data-mode="duo"] .skill-btn, body[data-mode="reverse"] .skill-btn { display: none; }
body[data-mode="duo"] #chips { top: auto; bottom: 4px; }
body[data-mode="duo"] #toast { display: none; }
.duo-pause { display: none; position: absolute; left: 6px; top: 6px; z-index: 5; width: 36px; height: 34px; padding: 0; opacity: 0.85; }
body[data-mode="duo"] .duo-pause { display: block; }

/* 계절: 시작 화면에 천천히 떨어지는 조각 */
#season { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
#season span { position: absolute; top: -24px; opacity: 0.55; animation: fall linear infinite; }
@keyframes fall { from { transform: translateY(0) rotate(0); } to { transform: translateY(105vh) rotate(320deg); } }
@media (prefers-reduced-motion: reduce) { #season { display: none; } }

.card-row { display: flex; align-items: center; gap: 10px; text-align: left; background: #0b1430; border: 1px solid #1e2b4f; border-radius: 12px; padding: 8px 10px; font-size: 13px; line-height: 1.45; }
.card-row canvas, .help-row canvas { flex: none; }
#cardList { display: flex; flex-direction: column; gap: 6px; }
.card-name { font-weight: 800; }

#resultChecks { list-style: none; text-align: left; width: fit-content; margin: 0 auto; font-size: 13px; line-height: 1.7; color: #94a3b8; }
#resultChecks li.done { color: #e2e8f0; font-weight: 700; }
#resultStars { display: flex; justify-content: center; gap: 10px; font-size: 44px; line-height: 1.1; }
.star { color: #334155; }
.star.on { color: #fde047; text-shadow: 0 0 14px rgba(253, 224, 71, 0.9); animation: pop 0.4s both; }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.35); } 100% { transform: scale(1); } }
.result { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; font-size: 14px; }
.result dt { color: #94a3b8; text-align: right; }
.result dd { text-align: left; font-weight: 800; }
h2.over { color: #fb7185; }
#rankBox { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
#initials { font: inherit; font-size: 16px; width: 90px; text-align: center; text-transform: uppercase; background: #020617; color: #fde047; border: 1px solid #334a7d; border-radius: 10px; user-select: text; -webkit-user-select: text; }
#rankBox .row button { flex: none; }

.modal { z-index: 20; background: rgba(3, 7, 22, 0.96); }
.modal .panel { max-height: 100%; min-height: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-close { width: 36px; height: 34px; padding: 0; }
.modal-body { overflow-y: auto; min-height: 0; text-align: left; display: flex; flex-direction: column; gap: 6px; font-size: 13px; line-height: 1.5; -webkit-overflow-scrolling: touch; }
.modal-body > * { flex: none; }
.modal-body h3 { font-size: 14px; color: #67e8f9; margin-top: 8px; }
.help-row { display: flex; align-items: center; gap: 10px; background: #0b1430; border-radius: 10px; padding: 5px 8px; }
.ach { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: #0b1430; border: 1px solid #1e2b4f; border-radius: 10px; padding: 7px 10px; }
.ach.done { border-color: #a855f7; background: #1d1236; }
.ach-title { font-weight: 800; }
.ach-num { font-weight: 800; color: #67e8f9; white-space: nowrap; }
table { width: 100%; border-collapse: collapse; text-align: center; font-size: 14px; }
th, td { padding: 6px 4px; border-bottom: 1px solid #1e2b4f; }

/* 마우스를 쓰는 큰 화면에서는 방향 버튼을 숨긴다 */
@media (hover: hover) and (pointer: fine) and (min-height: 600px) { .dpad { display: none; } .skill-float { display: block; } }

/* 키가 작은 세로 화면 */
@media (max-height: 640px) and (orientation: portrait) {
  .dpad { grid-template-rows: repeat(2, 44px); padding-bottom: 4px; }
  header { padding-top: 4px; }
  #titleArt { display: none; }
  .panel { gap: 7px; }
}
@media (max-width: 360px) {
  h1 small { display: none; }
  .stats { grid-template-columns: 1.1fr 1.15fr 1.15fr 0.75fr; }
  .stat b { font-size: 12px; }
  #lives { font-size: 11px; }
  .stat { padding: 2px 3px; }
  .row button { font-size: 12px; }
  .zone span { font-size: 8px; letter-spacing: -0.3px; }
  #zones { gap: 3px; }
  .chip { font-size: 10px; padding: 1px 6px; }
  .dpad { grid-template-columns: repeat(3, 64px); }
}

/* 가로로 눕힌 휴대폰: 머리줄 왼쪽, 게임 가운데, 방향 버튼 오른쪽 */
@media (orientation: landscape) and (max-height: 560px) {
  #app { max-width: none; display: grid; grid-template-columns: minmax(150px, 200px) minmax(0, 1fr) auto; grid-template-rows: minmax(0, 1fr); }
  header { grid-column: 1; display: flex; flex-direction: column; justify-content: center; gap: 4px; min-width: 0; }
  .bar { flex-direction: column; align-items: stretch; }
  .bar-buttons { justify-content: center; }
  h1 { text-align: center; font-size: 15px; }
  h1 small { display: none; }
  .stats { grid-template-columns: 1fr 1fr; }
  #chips { position: fixed; top: auto; right: auto; left: calc(6px + env(safe-area-inset-left)); bottom: 6px; width: 188px; justify-content: flex-start; }
  #stageArea { grid-column: 2; height: 100%; }
  .dpad { grid-column: 3; align-self: center; grid-template-columns: repeat(3, 54px); grid-template-rows: repeat(2, 60px); padding: 0 6px; }
  .start-panel { max-width: 640px; gap: 6px; }
  .start-panel #titleArt { display: none; }
  .start-panel .logo { font-size: 22px !important; }
  .start-panel .logo + p { display: none; }
  .menu button { flex-direction: row; justify-content: center; gap: 3px; }
  body[data-mode="duo"] .dpad2 { grid-column: 1; grid-row: 1; align-self: center; transform: none; order: 0; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(2, 60px); }
  body[data-mode="duo"] .dpad { grid-template-rows: repeat(2, 60px); }
  .dpad2 { grid-column: 1; }
  #chars { grid-template-columns: repeat(6, 1fr); }
  .char-name { font-size: 10px; }
  #charInfo { min-height: 38px; }
  .big { padding: 8px; font-size: 15px; }
  #resultStars { font-size: 30px; }
  #resultChecks { font-size: 12px; line-height: 1.4; }
  #resultTitle { font-size: 16px; }
  .panel { gap: 6px; }
}
