/* 배치: 낮은 해질녘 배너 위, 그 아래 게임 · 소개 · 점수 세 칸. 휴대폰에서는 한 줄로 쌓는다. */
:root {
  color-scheme: dark;
  /* 페이지: 보랏빛 해질녘 */
  --night: #1b1430;
  --panel: #251c3f;
  --line: #43356a;
  --dusk-top: #5d4b8c;
  --dusk-low: #c4a3c9;
  --ink: #f2edf9;
  --muted: #b6abcf;
  --title-ink: #1b1430;
  --glow: #f6cf5e;
  --glow-ink: #2a1d05;
  --error: #ff9b9b;
  /* 게임 화면: 하늘 → 남색 → 우주 */
  --sky: #a7dcf2;
  --navy: #26397a;
  --void: #04050c;
  --suit: #ffffff;
  --visor: #8fb4d9;

  /* 인터넷 글꼴 없이 컴퓨터에 있는 글꼴만 쓴다 */
  --font-body: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --font-display: var(--font-body);

  /* 배너 높이 (게임 자리 높이 계산에 쓴다) */
  --banner-h: 128px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.65;
}

/* 배너 */
.banner {
  position: relative;
  overflow: hidden;
  min-height: var(--banner-h);
  background: linear-gradient(180deg, var(--dusk-top) 0%, var(--dusk-low) 100%);
}
.banner-inner {
  position: relative;
  z-index: 2;
  max-width: 1180px;
  margin: 0 auto;
  padding-block: 18px 40px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.banner h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 4.5vw, 42px);
  line-height: 1.15;
  letter-spacing: 0.02em;
  color: var(--title-ink);
  text-wrap: balance;
}
.banner p {
  margin: 0;
  font-weight: 600;
  font-size: clamp(15px, 2.2vw, 18px);
  color: var(--title-ink);
}
.banner .moon {
  position: absolute;
  z-index: 1;
  right: 14%;
  top: 16px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--glow);
  box-shadow: 0 0 50px 14px color-mix(in srgb, var(--glow) 45%, transparent);
  opacity: 0.9;
}
.banner .dots { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.banner .dots i {
  position: absolute;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--ink);
  opacity: 0.7;
}
.banner svg.ridges {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  width: 100%;
  height: 56px;
  z-index: 1;
}

/* 세 칸 */
.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding-block: 20px 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 320px);
  gap: 24px;
  align-items: start;
}
.layout > * { min-width: 0; }

.label {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--muted);
}

/* 왼쪽: 게임 자리 */
.screen {
  position: relative;
  /* 컴퓨터 화면: 배너와 여백을 뺀 높이 안에 9:16 전체가 들어가게 한다 */
  height: min(568px, calc(100vh - var(--banner-h) - 92px));
  min-height: 320px;
  aspect-ratio: 9 / 16;
  max-width: 100%;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(0deg, var(--sky) 0%, var(--navy) 55%, var(--void) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.screen .twinkle { position: absolute; inset: 0; pointer-events: none; }
.screen .twinkle i {
  position: absolute;
  width: 2px; height: 2px;
  border-radius: 50%;
  background: var(--ink);
}
.star {
  position: absolute;
  width: 13%;
  aspect-ratio: 46 / 44;
  background: var(--glow);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.astro {
  position: absolute;
  left: 50%;
  bottom: 30%;
  transform: translateX(-50%);
  width: 34px;
  height: 46px;
}
.astro .helmet {
  position: absolute; top: 0; left: 3px;
  width: 28px; height: 26px;
  border-radius: 50%;
  background: var(--suit);
}
.astro .helmet::after {
  content: "";
  position: absolute; top: 7px; left: 6px;
  width: 16px; height: 10px;
  border-radius: 6px;
  background: var(--visor);
}
.astro .suit {
  position: absolute; bottom: 0; left: 5px;
  width: 24px; height: 22px;
  border-radius: 8px 8px 6px 6px;
  background: var(--suit);
}
.placeholder {
  position: relative;
  z-index: 2;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px dashed color-mix(in srgb, var(--ink) 60%, transparent);
  background: color-mix(in srgb, var(--void) 55%, transparent);
  color: var(--ink);
  font-size: 14px;
}

/* 버튼 */
.btn {
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  padding: 12px 26px;
  border: 0;
  border-radius: 999px;
  background: var(--glow);
  color: var(--glow-ink);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px color-mix(in srgb, var(--glow) 40%, transparent); }
.btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

/* 가운데: 소개 */
.about h2, .board h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  line-height: 1.25;
  text-wrap: balance;
}
.about .lead { margin: 0 0 22px; max-width: 60ch; color: var(--ink); }
.section { padding-block: 18px; border-top: 1px solid var(--line); }
.keys { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0; }
kbd {
  display: inline-grid;
  place-items: center;
  min-width: 36px; height: 34px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  background: var(--panel);
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
}
.note { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 18px;
  margin: 0;
}
.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

/* 오른쪽: 점수 */
.board {
  padding: 20px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.score-form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 13px; color: var(--muted); }
.field input {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--night);
  color: var(--ink);
}
.field input:focus-visible { outline: 2px solid var(--glow); outline-offset: 1px; }
.score-form .btn { align-self: stretch; }
.ranks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ranks li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding-block: 10px;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.ranks .no { color: var(--glow); font-family: var(--font-display); font-weight: 700; font-size: 20px; }
.ranks .who { overflow-wrap: anywhere; }
.ranks .pts { font-weight: 600; }
.ranks .empty { display: block; color: var(--muted); font-size: 14px; }
/* 1~3등 강조 */
.ranks li.top {
  padding-inline: 8px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--glow) 10%, transparent);
}
.ranks li.top + li.top { margin-top: 4px; }
.ranks li.top .who, .ranks li.top .pts { font-weight: 700; }
.ranks li.top-1 .no { font-size: 26px; }
.ranks li.top-2 .no { font-size: 23px; }
.notice { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

/* 점수 올리기 안내 메시지 */
.message { margin: 0; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.message:empty { display: none; }
.message[data-kind="ok"] { color: var(--glow); font-weight: 600; }
.message[data-kind="error"] { color: var(--error); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* 맨 아래: 댓글 (세 칸과 같은 폭과 여백) */
.layout { padding-bottom: 24px; }
.comments-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding-block: 0 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.comments {
  padding: 20px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.comments h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  line-height: 1.25;
}
.comment-form {
  display: grid;
  grid-template-columns: minmax(0, 200px) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  margin-bottom: 18px;
}
.comment-form .btn { margin-top: 23px; }
.comment-form .message { grid-column: 1 / -1; }
.field textarea {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--night);
  color: var(--ink);
  resize: vertical;
}
.field textarea:focus-visible { outline: 2px solid var(--glow); outline-offset: 1px; }
.count { align-self: flex-end; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.comment-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.comment-list li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-block: 12px;
  border-top: 1px solid var(--line);
  min-width: 0;
}
.comment-list .meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; color: var(--muted); }
.comment-list .author { font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.comment-list .text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-list .pending .text { color: var(--muted); font-style: italic; }
.comment-list .empty { color: var(--muted); font-size: 14px; }

/* 관리자 페이지 */
.admin-header { background: linear-gradient(180deg, var(--dusk-top) 0%, var(--dusk-low) 100%); }
.admin-header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding-block: 18px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  align-items: baseline;
  justify-content: space-between;
}
.admin-header h1 { margin: 0; font-size: 28px; line-height: 1.2; color: var(--title-ink); }
.admin-header a { color: var(--title-ink); font-weight: 600; }
.admin-wrap { display: flex; flex-direction: column; gap: 20px; padding-top: 24px; }
.admin-login { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 12px; }
.admin-login .field { flex: 1 1 240px; min-width: 0; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.btn-small { font-size: 14px; padding: 6px 16px; }
.btn-danger { background: var(--error); color: var(--title-ink); }
.badge {
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--line);
}
.badge-pending { color: var(--muted); }
.badge-visible { color: var(--glow); border-color: var(--glow); }

@media (max-width: 960px) {
  .comment-form { grid-template-columns: minmax(0, 1fr); }
  .comment-form .btn { margin-top: 0; }
}

/* 휴대폰·좁은 화면: 배너, 게임, 소개, 점수 순서로 쌓기 */
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .game { width: 100%; max-width: 360px; margin: 0 auto; }
  .screen { width: 100%; height: auto; min-height: 0; }
  .banner .moon { width: 56px; height: 56px; right: 8%; }
}

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
  .btn:hover { transform: none; }
}
