/* 달까지 냥냥 게임 페이지
   색, 글자 크기, 배치는 design.html 시안을 따른다. */

:root {
  --banner-height: 88px;   /* 배너 높이 */
  --main-padding: 24px;    /* 본문 위아래 여백 */

  /* 스크롤 없이 게임 자리가 다 보이도록, 창 높이에 맞춰 게임 자리 높이를 정한다 */
  --slot-height: calc(100vh - var(--banner-height) - var(--main-padding) * 2);
}

* {
  box-sizing: border-box;
}

h1, h2, p, ul, ol, dl, dd {
  margin: 0;
}

body {
  margin: 0;
  background: #120b26;
  color: #f1ecff;
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  word-break: keep-all;      /* 한글이 낱자 중간에서 끊기지 않게 한다 */
  overflow-wrap: anywhere;   /* 아주 긴 글자는 칸 안에서 줄을 바꾼다 */
}

/* ---------- 맨 위 배너 ---------- */

#game-banner {
  position: relative;
  overflow: hidden;
  height: var(--banner-height);
  display: flex;
  align-items: center;
  border-bottom: 1px solid #3a2a6b;
  background:
    repeating-linear-gradient(to bottom, rgba(255, 122, 192, 0.55) 0 2px, transparent 2px 5px) bottom / 100% 8px no-repeat,
    radial-gradient(circle at 6% 30%, #ffffff 1.5px, transparent 2px),
    radial-gradient(circle at 23% 22%, #ffd27a 1.2px, transparent 2px),
    radial-gradient(circle at 52% 18%, #ffffff 1.6px, transparent 2px),
    radial-gradient(circle at 61% 66%, #7fe3ff 1px, transparent 2px),
    radial-gradient(circle at 94% 62%, #ffffff 1.4px, transparent 2px),
    #1c1140;
}

/* 초승달: 노란 원 위에 배너 색 원을 겹쳐서 만든다 */
#game-banner::before,
#game-banner::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}

#game-banner::before {
  right: 9%;
  top: 12px;
  width: 48px;
  height: 48px;
  background: #ffd27a;
  box-shadow: 0 0 40px rgba(255, 210, 122, 0.35);
}

#game-banner::after {
  right: calc(9% - 8px);
  top: 7px;
  width: 40px;
  height: 40px;
  background: #1c1140;
}

.banner-text {
  position: relative;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 18px;
}

#game-banner h1 {
  font-family: 'Jua', sans-serif;
  font-weight: 400;
  font-size: 56px;
  line-height: 1.2;
  color: #ffffff;
  letter-spacing: 1px;
}

.pink {
  color: #ff7ac0;
}

#game-banner p {
  font-size: 17px;
  color: #cfc4ef;
}

/* ---------- 세 칸 배치 ---------- */

.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--main-padding) 24px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(280px, 340px);
  gap: 24px;
  align-items: start;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

/* ---------- 왼쪽 칸: 게임 자리 ---------- */

#game-slot {
  position: relative;
  width: min(380px, calc(var(--slot-height) * 9 / 16));
  aspect-ratio: 9 / 16;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(to bottom, #241650 56%, #1c1140 56%);
  border: 1px solid #4a3888;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.slot-label {
  padding: 10px 18px;
  border: 2px dashed rgba(255, 255, 255, 0.55);
  border-radius: 12px;
  background: rgba(18, 11, 38, 0.72);
  color: #ffffff;
  font-size: 15px;
  text-align: center;
}

/* 게임 화면은 게임 자리를 꽉 채운다.
   손가락 동작은 canvas 안에서만 게임이 받고, 페이지의 스크롤과 확대는 그대로 둔다. */
#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* 시작 단추와 안내 문구를 canvas 위에 놓는다 */
#game-start,
#game-status {
  position: relative;
}

#game-start {
  padding: 0 28px;
}

/* ---------- 카드 공통 ---------- */

.card {
  background: #1c1140;
  border: 1px solid #3a2a6b;
  border-radius: 18px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card h2 {
  font-family: 'Jua', sans-serif;
  font-weight: 400;
  font-size: 24px;
  color: #ffffff;
}

.soft {
  color: #d9d0f5;
}

/* ---------- 가운데 칸: 조작법, 게임 정보 ---------- */

.controls {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.controls li {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.keys {
  display: inline-flex;
  gap: 6px;
}

kbd {
  min-width: 36px;
  padding: 4px 10px;
  border-radius: 8px;
  background: #2e1f5e;
  border: 1px solid #5a47a0;
  color: #ffffff;
  font-family: inherit;
  text-align: center;
}

.info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.info div {
  background: #241650;
  border-radius: 12px;
  padding: 12px 16px;
}

.info dt {
  font-size: 13px;
  color: #b9addb;
}

.info dd {
  font-weight: 700;
  color: #ffffff;
}

/* ---------- 오른쪽 칸: 입력칸, 버튼, 점수판 ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 14px;
  color: #d9d0f5;
}

.field input,
.field textarea {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid #5a47a0;
  background: #120b26;
  color: #ffffff;
  font-family: inherit;
  font-size: 16px;
}

.field textarea {
  padding: 10px 14px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  outline: 2px solid #7fe3ff;
  outline-offset: 2px;
}

#game-start,
#initials-confirm,
#comment-submit,
#admin-load,
#admin-load-scores,
#admin-load-logs,
#admin-backup {
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: #ff7ac0;
  color: #2a0b1d;
  font-family: 'Jua', sans-serif;
  font-size: 19px;
  cursor: pointer;
}

#game-start:hover,
#initials-confirm:hover,
#comment-submit:hover,
#admin-load:hover,
#admin-load-scores:hover,
#admin-load-logs:hover,
#admin-backup:hover {
  filter: brightness(1.08);
}

#game-start:focus-visible,
#initials-confirm:focus-visible,
#comment-submit:focus-visible,
#admin-load:focus-visible,
#admin-load-scores:focus-visible,
#admin-load-logs:focus-visible,
#admin-backup:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
}

.board-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.board-title span {
  font-size: 13px;
  color: #b9addb;
}

.scores {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scores li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #241650;
}

.rank {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #2a1406;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.name {
  flex: 1;
  min-width: 0;
  color: #ffffff;
  font-weight: 500;
}

.points {
  color: #ffffff;
  font-weight: 700;
}

/* 1등 줄: 금색 배경으로 눈에 띄게 한다. 글자는 금색 위에서 읽히도록 어두운 색으로 바꾼다. */
.scores .first {
  background: #ffd27a;
  box-shadow: 0 0 18px rgba(255, 210, 122, 0.35);
}

.first .rank {
  background: #2a1406;
  color: #ffd27a;
}

.first .name,
.first .points {
  color: #2a1406;
}

.second .rank {
  background: #d9d0f5;
  color: #1c1140;
}

.third .rank {
  background: #e3a57a;
}

/* 4등부터: 순위 숫자가 어두운 배경에 묻히지 않게 한다 */
.other .rank {
  background: #5a47a0;
  color: #ffffff;
}

/* 방금 올린 줄: 하늘색 테두리를 두르고 세 번 깜빡인다 */
.scores li.just-added {
  outline: 3px solid #7fe3ff;
  outline-offset: 2px;
  animation: just-added-pulse 0.8s ease-out 3;
}

@keyframes just-added-pulse {
  from {
    box-shadow: 0 0 0 0 rgba(127, 227, 255, 0.7);
  }
  to {
    box-shadow: 0 0 0 12px rgba(127, 227, 255, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .scores li.just-added {
    animation: none;
  }
}

/* ---------- 이니셜 창 ---------- */

#initials-dialog {
  width: min(360px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid #4a3888;
  border-radius: 18px;
  background: #1c1140;
  color: #f1ecff;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
  text-align: center;
}

#initials-dialog[open] {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#initials-dialog::backdrop {
  background: rgba(18, 11, 38, 0.75);
}

#initials-dialog h2 {
  font-family: 'Jua', sans-serif;
  font-weight: 400;
  font-size: 28px;
  color: #ffffff;
}

.initials-slots {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.initial-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: #241650;
}

/* 키보드로 친 글자가 들어갈 칸 */
.initial-slot.active {
  border-color: #7fe3ff;
}

.initial-letter {
  font-family: 'Jua', sans-serif;
  font-size: 44px;
  line-height: 1.1;
  color: #ffffff;
}

/* 휴대폰에서 누르기 쉽게 가로세로 44px 이상으로 만든다 */
.initial-step {
  min-width: 56px;
  min-height: 44px;
  border: 1px solid #5a47a0;
  border-radius: 10px;
  background: #2e1f5e;
  color: #ffffff;
  font-size: 18px;
  cursor: pointer;
}

.initial-step:hover {
  border-color: #7fe3ff;
}

.initial-step:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.initials-actions {
  display: flex;
  gap: 12px;
}

.initials-actions button {
  flex: 1;
  min-width: 44px;
}

#initials-confirm:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ---------- 맨 아래: 댓글 ---------- */

#game-comments {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px 40px;
}

.comments {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comments li {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #241650;
}

.comment-nickname {
  color: #ffffff;
  font-weight: 500;
}

.comment-text {
  color: #d9d0f5;
  white-space: pre-wrap;   /* 입력한 줄바꿈을 그대로 보여 준다 */
}

/* ---------- 관리자 페이지 ---------- */

.admin-page {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--main-padding) 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.admin-page h1 {
  font-family: 'Jua', sans-serif;
  font-weight: 400;
  font-size: 32px;
  color: #ffffff;
}

.comment-info {
  font-size: 13px;
  color: #b9addb;
}

.comment-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.comment-actions button,
.secondary-button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid #5a47a0;
  border-radius: 10px;
  background: #2e1f5e;
  color: #ffffff;
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
}

/* 닉네임으로 모두 지우는 단추: 분홍 단추와 높이를 맞춘다 */
.secondary-button {
  min-height: 48px;
}

.comment-actions button:hover:not(:disabled),
.secondary-button:hover:not(:disabled) {
  border-color: #7fe3ff;
}

.comment-actions button:focus-visible,
.secondary-button:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
}

.comment-actions button:disabled,
.secondary-button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ---------- 작은 컴퓨터 화면, 태블릿: 점수 칸을 아래로 내린다 ---------- */

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .score-column {
    grid-column: 1 / -1;
  }
}

/* ---------- 휴대폰 화면: 배너, 게임, 소개, 점수 순서로 쌓는다 ---------- */

@media (max-width: 720px) {
  #game-banner {
    height: auto;
    padding: 14px 0 12px;
  }

  #game-banner::before,
  #game-banner::after {
    display: none;
  }

  #game-banner h1 {
    font-size: 42px;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
    padding: 20px 16px 40px;
  }

  /* 휴대폰 세로 화면에서 게임 자리가 화면 높이를 넘지 않게 한다. 위아래에 16px 씩 남긴다. */
  #game-slot {
    width: 100%;
    width: min(100%, calc((100svh - 32px) * 9 / 16));
    max-width: 420px;
    margin: 0 auto;
  }

  .score-column {
    grid-column: auto;
  }

  #game-comments {
    padding: 0 16px 40px;
  }
}
