/* Fonts */
@font-face {
    font-family: 'KoddiUDOnGothic';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2105_2@1.0/KoddiUDOnGothic-Regular.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'KoddiUDOnGothic';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2105_2@1.0/KoddiUDOnGothic-Bold.woff') format('woff');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
  --font-lg: 1.2em;
  --font-md: 0.9em;
  --font-sm: 0.75em;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: rgba(26, 26, 26, 1);
  color: rgba(204, 204, 204, 1);
  font-family: 'KoddiUDOnGothic', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 16px;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* 게임 페이지(캔버스 있음)는 내용이 고정 크기라 viewport 채우기 불필요.
   min-height:100vh를 풀어 푸터 아래 빈 공간/스크롤을 없앤다. 허브는 유지. */
body:has(#canvas-wrap) {
  min-height: 0;
}

a {
  text-decoration: none;
  color: rgba(123, 166, 222, 1);
}

a:visited {
  color: rgba(90, 133, 185, 1);
}

a:hover {
  text-decoration: underline;
  text-decoration-style: dotted;
}

h1 { font-size: var(--font-lg); color: rgba(170, 170, 170, 1); margin-top: 8px; }

/* 좌(디스크) · 중앙(로고) · 우(버튼) 3분할. 좌측 요소 유무와 무관하게 로고는 항상 정중앙 */
.top-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 640px;
  height: 44px;
}

#btn-disk {
  grid-column: 1;
  justify-self: start;
}

.top-bar .logo {
  grid-column: 2;
  justify-self: center;
  /* 로고 표시 영역(바운딩 박스). 비율 다른 로고도 이 안에 맞춰 들어감 */
  max-width: 160px;
  max-height: 42px;
  width: auto;
  height: auto;
}

#btn-disk.active { background: rgba(38, 38, 38, 1); }

.top-bar-right {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
}

.disk-panel {
  display: flex;
  gap: 0;
  justify-content: flex-start;
  width: 640px;
  overflow: hidden;
  max-height: 48px;
  opacity: 1;
  transition: max-height 0.2s, opacity 0.2s;
}

.disk-panel button {
  font-size: var(--font-sm);
  padding: 4px 12px;
  background: rgba(38, 38, 38, 1);
  border: none;
  color: rgba(119, 119, 119, 1);
}

.disk-panel button:hover {
  background: rgba(51, 51, 51, 1);
  color: rgba(204, 204, 204, 1);
}

.disk-panel.hidden {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.btn-icon {
  background: none;
  border: none;
  color: rgba(119, 119, 119, 1);
  font-size: 1.6em;
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover { color: rgba(204, 204, 204, 1); }

/* 데스크톱(마우스)에서는 게임패드·상단바 접기 버튼 숨김 */
@media (hover: hover) and (pointer: fine) {
  .btn-touch-only,
  #btn-collapse { display: none; }
}

/* 게임패드 활성 시 토글 버튼 숨김 */
body.mobile-active .btn-touch-only { display: none; }

/* 터치 기기에서 전체화면 버튼 숨김 */
@media (hover: none), (pointer: coarse) {
  #btn-fullscreen { display: none; }
}

/* 상단바 접힘: 바를 0 높이로 클립하고, 접기 버튼만 화면 상단 중앙에 고정 */
body.chrome-hidden { padding-top: 0; }
body.chrome-hidden .top-bar { height: 0; overflow: hidden; }
body.chrome-hidden .disk-panel { display: none; }
body.chrome-hidden #canvas-wrap { margin-top: 0; }
body.chrome-hidden #footer { display: none; }
body.chrome-hidden .hint { display: none; }
body.chrome-hidden #btn-collapse {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
}
body.chrome-hidden #btn-collapse svg { transform: rotate(180deg); }

#canvas-wrap {
  position: relative;
  display: inline-block;
  border: 0;
  margin: 12px 0;
}

canvas {
  display: block;
  width: 640px;
  height: 400px;
  image-rendering: pixelated;
}

#overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: rgba(238, 238, 238, 1);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s, visibility 0s 0.3s;
}

#overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#overlay button {
  font-size: var(--font-lg);
  padding: 10px 28px;
  background: rgba(51, 51, 51, 1);
  border: 1px solid rgba(102, 102, 102, 1);
  color: rgba(238, 238, 238, 1);
  cursor: pointer;
  font-family: 'KoddiUDOnGothic', sans-serif;
  transition: background 0.15s;
}

#overlay button:hover { background: rgba(68, 68, 68, 1); }


#toast {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: rgba(204, 204, 204, 1);
  font-size: var(--font-sm);
  padding: 6px 16px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
  z-index: 10;
}

#toast.visible { opacity: 1; }

button {
  background: rgba(51, 51, 51, 1);
  border: 1px solid rgba(85, 85, 85, 1);
  color: rgba(204, 204, 204, 1);
  padding: 6px 14px;
  cursor: pointer;
  font-family: 'KoddiUDOnGothic', sans-serif;
  font-size: var(--font-md);
  transition: background 0.15s;
}

.disk-panel button:hover { background: rgba(68, 68, 68, 1); }

.hint { font-size: var(--font-sm); color: rgba(85, 85, 85, 1); }

#footer .site-version { color: rgba(102, 102, 102, 1); letter-spacing: 0.05em; }

#footer {
  font-size: var(--font-sm);
  color: rgba(85, 85, 85, 1);
  text-align: center;
  margin-top: 20px;
  padding-top: 16px;
  width: 640px;
  border-top: 1px solid;
  border-image: linear-gradient(to right, transparent, rgba(85, 85, 85, 0.5), transparent) 1;
}

#footer a { color: rgba(119, 119, 119, 1); }
#footer a:hover { color: rgba(170, 170, 170, 1); }

.footer-sep { margin: 0 4px; }

.spacer { height: 16px; }

/* Hub page — game list */
.game-list {
  list-style: none;
  width: 640px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.game-list li {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  aspect-ratio: 1 / 1;
  padding: 20px 16px;
  background-color: rgba(38, 38, 38, 1);
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(68, 68, 68, 1);
  overflow: hidden;
  transition: background-color 0.15s;
}

/* 일러스트 카드: 배경 위 가독성 스크림 (아래로 갈수록 진하게) */
.game-list li.has-art::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(15, 15, 15, 0) 0%, rgba(15, 15, 15, 0.05) 50%, rgba(15, 15, 15, 0.85) 100%);
  transition: opacity 0.15s;
}

.game-list li > * { position: relative; z-index: 1; }

.game-list li a {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 20px 16px;
  color: inherit;
  text-decoration: none;
}

.game-list li a:hover { text-decoration: none; }

.game-list li:not(.unavailable):hover { background-color: rgba(51, 51, 51, 1); }
.game-list li.has-art:not(.unavailable):hover::before { opacity: 0.65; }

.game-list li.unavailable { opacity: 0.45; }

.game-logo { width: 160px; height: 48px; object-fit: contain; }

.game-title { font-size: 1.6em; color: rgba(204, 204, 204, 1); }

.game-sub { font-size: var(--font-sm); color: rgba(255, 255, 255, 1); }

.badge {
  font-size: var(--font-sm);
  padding: 2px 8px;
  border-radius: 2px;
  white-space: nowrap;
}

.badge.done { background: rgba(40, 80, 60, 1); color: rgba(120, 200, 150, 1); border: 1px solid rgba(60, 120, 90, 1); }
.badge.wip  { background: rgba(60, 50, 15, 1); color: rgba(210, 165, 55, 1);  border: 1px solid rgba(90, 72, 22, 1); }
.badge.todo { background: rgba(50, 50, 50, 1); color: rgba(120, 120, 120, 1); border: 1px solid rgba(70, 70, 70, 1); }

/* Fullscreen */
#canvas-wrap:fullscreen,
#canvas-wrap:-webkit-full-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 1);
}

#canvas-wrap:fullscreen canvas,
#canvas-wrap:-webkit-full-screen canvas {
  width: min(100vw, 160vh);
  height: min(100vh, 62.5vw);
  image-rendering: pixelated;
}

/* 전체화면은 캔버스가 뷰포트 크기에 비례해 커지므로(위 width/height 공식과 동일 축)
   토스트도 em이 아닌 vmin으로 스케일해야 체감 크기가 맞음 */
#canvas-wrap:fullscreen #toast,
#canvas-wrap:-webkit-full-screen #toast {
  font-size: 2.4vmin;
  padding: 1.2vmin 2.4vmin;
  border-radius: 0.6vmin;
  bottom: 2.4vmin;
}

/* Virtual Gamepad (mobile only) */
#virtual-gamepad {
  display: none;
}

body.mobile-active #virtual-gamepad {
  display: flex;
  justify-content: space-between;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  box-sizing: border-box;
  align-items: center;
  padding: 16px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  z-index: 100;
}

.gamepad-dpad {
  position: relative;
  width: 140px;
  height: 140px;
}

/* 키캡 공통 (프로스티드 글래스) */
#virtual-gamepad button {
  border-radius: 8px;
  background: rgba(30, 30, 30, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(230, 230, 230, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25), 0 3px 8px rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.05s, box-shadow 0.05s;
}

#virtual-gamepad button.active {
  transform: translateY(3px);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.2);
}

.gamepad-dpad button {
  position: absolute;
  width: 48px;
  height: 48px;
}

.dpad-up    { top: 0;    left: 46px; }
.dpad-down  { bottom: 0; left: 46px; }
.dpad-left  { top: 46px; left: 0; }
.dpad-right { top: 46px; right: 0; }

.gamepad-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
}

.gamepad-buttons button {
  min-width: 48px;
  height: 48px;
  padding: 0 10px;
}

/* Enter is the primary action, so it reads as a wider pill than the square ESC. */
.gamepad-buttons button.gamepad-btn-enter {
  width: 72px;
  min-width: 72px;
}

#virtual-gamepad button svg {
  height: 50%;
  width: auto;
  pointer-events: none;
}

/* Face-button icons (ESC/Enter) are square glyphs; the dpad arrows are taller/narrower,
   so each kind gets its own icon height to read as the same visual size on identical
   48px buttons. Both need the "#virtual-gamepad" id prefix to outrank the base
   "#virtual-gamepad button svg" rule above. */
#virtual-gamepad .gamepad-buttons button svg {
  height: 30%;
}
#virtual-gamepad .gamepad-dpad button svg {
  height: 40%;
}

/* Mobile responsive */
@media (max-width: 680px) {
  canvas { width: 100vw; height: calc(100vw * 0.625); }
  #canvas-wrap { width: 100vw; }
  .top-bar { width: 100%; }
  .disk-panel { width: 100%; }
  .hint { display: none; }
  #footer { width: 100%; padding: 16px; }
  .game-list { width: 100%; grid-template-columns: 1fr; }
  .desktop-only { display: none; }
}
