:root {
  /* Pixel Ground 본보기 팔레트: 따뜻한 짙은 갈색 테두리 · 크림 종이 · 꿀 · 로고 빨강 */
  --ink: #4a3428;
  --paper: #fff3ce;
  --honey: #f6c446;
  --honey-dark: #c48c28;
  --bark: #4a3428;
  --line: #4a3428;
  --red: #e6643e;
  --mute: #bc8c62;
  --bg: #f7cdb0;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overscroll-behavior: none; }
body { font: 15px/1.4 "Consolas", "Courier New", ui-monospace, monospace; -webkit-user-select: none; user-select: none; touch-action: none; }
#app { position: relative; height: 100vh; height: 100dvh; display: grid; place-items: center; overflow: hidden; }
#screen {
  height: 100%; max-width: 100vw; aspect-ratio: 9 / 16; object-fit: contain;
  image-rendering: pixelated; image-rendering: crisp-edges; background: #000; display: block;
}
.hidden { display: none !important; }

/* 패널: 나무판 느낌의 두꺼운 테두리, 그림자 대신 계단식 테두리 */
.panel {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(88vw, 360px); max-height: 92dvh; overflow: auto;
  background: var(--paper); color: var(--ink);
  border: 4px solid var(--line); box-shadow: 0 6px 0 var(--line), inset 0 -4px 0 #f6dec8, inset 0 4px 0 #fffaf0;
  padding: 22px 18px 18px; text-align: left;
}
h1 { margin: 0 0 6px; line-height: 0; }
#logo { image-rendering: pixelated; max-width: 100%; height: auto; }
h2 { font-size: 24px; letter-spacing: 4px; margin: 0 0 12px; color: var(--red); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge { font-size: 12px; letter-spacing: 1px; background: var(--honey); color: var(--ink); border: 3px solid var(--line); padding: 2px 8px; animation: pop .6s steps(3) 2; }
@keyframes pop { 50% { transform: translateY(-4px); } }
.sub { margin: 0 0 14px; color: #78523a; font-size: 13px; }
.keys, .tiny { font-size: 12px; color: #7d6646; margin: 12px 0 0; }
a.tiny { display: inline-block; color: #7d6646; }

button {
  font: inherit; font-weight: 700; letter-spacing: 1px; cursor: pointer;
  background: var(--honey); color: var(--ink); border: 3px solid var(--line);
  padding: 9px 12px; box-shadow: 0 3px 0 var(--line);
}
button:active { transform: translateY(3px); box-shadow: none; }
button.ghost { background: transparent; }
button:disabled { opacity: .45; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

#stageList { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; max-height: 52vh; overflow-y: auto; }
#stageList button { width: 100%; text-align: left; display: flex; justify-content: space-between; gap: 8px; padding: 6px 10px; }
#stageList .best { font-weight: 400; font-size: 13px; }
#stageList button.locked { background: #ecdec8; color: #a08068; }

.stats { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin: 0; font-size: 20px; }
.stats dt { color: #6d5536; }
.stats dd { margin: 0; font-weight: 700; }
.check { font-size: 13px; margin: 8px 0; }
.check.ok { color: #2f6b2a; }
.check.bad { color: #a3321f; }
label { display: block; font-size: 13px; margin-top: 10px; color: #6d5536; }
input { font: inherit; padding: 8px; border: 3px solid var(--line); background: #fffaf0; color: var(--ink); flex: 1; min-width: 0; -webkit-user-select: text; user-select: text; }
.msg { font-size: 12px; margin: 4px 0 0; min-height: 1em; }

.tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.tabs button { padding: 5px 9px; font-size: 13px; background: transparent; box-shadow: none; }
.tabs button[aria-selected="true"] { background: var(--honey); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: #6d5536; font-weight: 400; border-bottom: 2px solid var(--line); padding: 3px 2px; }
td { padding: 4px 2px; border-bottom: 1px dashed #c9b48d; }
td.v { color: #2f6b2a; }
td.x { color: #a3321f; }

/* 터치 버튼: 화면 아래쪽, 반투명 */
#pad { position: absolute; inset: auto 0 0 0; height: 26%; pointer-events: none; }
.pad-btn {
  position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); pointer-events: auto;
  width: 78px; height: 78px; border-radius: 0; font-size: 26px; touch-action: none;
  background: rgba(241, 227, 196, .22); color: var(--paper); border: 3px solid rgba(241, 227, 196, .5); box-shadow: none;
}
.pad-btn[data-k="L"] { left: 14px; }
.pad-btn[data-k="R"] { left: 104px; }
.pad-btn.jump { right: 14px; width: 112px; font-size: 15px; line-height: 1.2; }
.pad-btn.on { background: rgba(226, 164, 50, .6); }
@media (hover: hover) and (pointer: fine) { #pad { display: none; } }

#pauseBtn {
  position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  padding: 2px 10px; font-size: 12px; background: rgba(0,0,0,.35); color: var(--paper); border: 2px solid rgba(241,227,196,.4); box-shadow: none;
}

/* 조작 설명 */
kbd { font: inherit; font-size: 11px; background: #fffaf0; border: 2px solid var(--line); border-bottom-width: 3px; padding: 0 4px; margin: 0 1px; }
.pad-tip { position: absolute; right: 14px; bottom: max(30px, env(safe-area-inset-bottom)); margin: 0; width: 120px; text-align: right;
  font-size: 12px; color: var(--paper); text-shadow: 1px 1px 0 var(--line), -1px 0 0 var(--line), 0 -1px 0 var(--line); pointer-events: none; }

/* 그림 조작 안내(web/controls.js 공용 조각) */
.how { margin-top: 12px; border-top: 2px dashed #e2c8a8; padding-top: 10px; }
.pg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pg-card { width: 100%; aspect-ratio: 64 / 36; image-rendering: pixelated; image-rendering: crisp-edges; border: 2px solid var(--line); display: block; }
.pg-strip { display: block; height: 26px; margin: 8px auto 0; image-rendering: pixelated; image-rendering: crisp-edges; }
.pg-grid > .pg-card:last-child:nth-child(odd) { grid-column: 1 / -1; width: calc(50% - 3px); justify-self: center; }

.foot { margin: 10px 0 0; text-align: center; font-size: 11px; color: #8a6648; }
.foot a { color: inherit; }
.periods { margin-top: -2px; }
