* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #060708;
  color: #c8ccd4;
  font-family: "Courier New", "D2Coding", "Segoe UI Symbol", monospace;
  -webkit-font-smoothing: none;
}

.wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px;
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #d7dbe3;
}

h1 .stage {
  margin-left: 10px;
  font-size: 12px;
  padding: 3px 10px;
  border: 1px solid #3a3d45;
  background: #16171b;
  color: #9a9fab;
  vertical-align: middle;
}
h1 .stage:empty { display: none; }

/* ---------------- 화면 전환 ---------------- */
.screen { display: none; }
.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 468px;
  max-width: 92vw;
}

/* 타이틀 메뉴 */
#screen-title { padding-top: 30px; }

#title-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}
/* QE 로 통째로 회전하는 그룹 */
#title-rotor {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  transform-origin: center center;
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform;
}
#title-logo {
  width: 100%;
  max-width: 360px;
  height: auto;
  image-rendering: pixelated;
}
#title-logo-fallback {
  display: none;
  font-size: 46px;
  font-weight: 700;
  letter-spacing: 10px;
  text-transform: uppercase;
  color: #e6e9f0;
}
#title-char-cv { display: block; }
.title-hint {
  font-size: 12px;
  letter-spacing: 2px;
  color: #6b7180;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 260px;
}
.menu-btn {
  font-family: inherit;
  font-size: 18px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #e6e9f0;
  background: #14161b;
  border: 2px solid #3a3d45;
  padding: 16px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, transform 0.05s;
}
.menu-btn:hover { background: #1e2129; border-color: #6b7180; }
.menu-btn:active { transform: translateY(1px); }

/* 탭 */
.tabs { display: flex; gap: 10px; }
.tab {
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 3px;
  color: #8b909c;
  background: #101115;
  border: 1px solid #2b2e36;
  padding: 8px 22px;
  cursor: pointer;
}
.tab.active { color: #e6e9f0; border-color: #6b7180; background: #1e2129; }

/* 스테이지 그리드 (7행 3열) */
.stage-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  width: 100%;
}
.cell-btn {
  font-family: inherit;
  font-size: 18px;
  color: #e6e9f0;
  background: #14161b;
  border: 2px solid #3a3d45;
  aspect-ratio: 1 / 1;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.cell-btn:hover:not(.locked) { background: #1e2129; border-color: #6b7180; }
.cell-btn.locked {
  color: #3f434d;
  background: #0d0e11;
  border-color: #1c1e24;
  cursor: default;
}

.custom-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px 0;
  color: #8b909c;
  font-size: 13px;
}
.custom-empty .menu-btn { width: 200px; }

/* 캐릭터 선택 */
.panel-title {
  font-size: 16px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #d7dbe3;
}
.char-options { display: flex; gap: 16px; }
.char-opt {
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: #101115;
  border: 2px solid #2b2e36;
  padding: 14px 10px 10px;
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
}
.char-opt:hover { border-color: #6b7180; }
.char-opt.selected { border-color: #e6e9f0; background: #1e2129; }
.char-opt canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #0b0c0e;
}
.char-name { font-size: 12px; letter-spacing: 2px; color: #c8ccd4; }

.notice { font-size: 13px; color: #8b909c; padding: 30px 0; }

/* 링크형 버튼 (뒤로/네비) */
.link-btn {
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 2px;
  color: #8b909c;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
}
.link-btn:hover { color: #e6e9f0; }
.game-nav { margin-top: 2px; }

/* 설정(캐릭터) 버튼 */
#btn-settings {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 38px;
  height: 38px;
  font-size: 18px;
  line-height: 1;
  color: #c8ccd4;
  background: #14161b;
  border: 1px solid #3a3d45;
  cursor: pointer;
}
#btn-settings:hover { background: #1e2129; border-color: #6b7180; }

.stage-frame {
  position: relative;
  padding: 10px;
  background: #0d0e11;
  border: 2px solid #2b2e36;
  box-shadow: 0 0 0 2px #060708, 0 0 0 3px #33363f;
}

canvas {
  display: block;
  background: #0b0c0e;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.overlay {
  position: absolute;
  inset: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(6, 7, 8, 0.8);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: #e6e9f0;
}

.overlay.hidden {
  display: none;
}

.overlay .overlayHint {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 2px;
  color: #9a9fab;
}

.hud {
  font-size: 13px;
  letter-spacing: 2px;
  color: #9a9fab;
  min-height: 18px;
  text-transform: uppercase;
}

.help {
  display: flex;
  gap: 18px;
  font-size: 12px;
  color: #9a9fab;
  background: #101115;
  padding: 8px 16px;
  border: 1px solid #2b2e36;
}

.help b {
  color: #e6e9f0;
  margin-right: 4px;
}

.tip {
  font-size: 11px;
  letter-spacing: 1px;
  color: #6b6f79;
  margin: 0;
}
