/* 달까지 냥냥 · 오락실 테마
   페이지 전체가 오락실 바닥(카펫) 위에 선 게임기 한 대이다.
   간판 → 화면 테두리 → 조종대 → 아랫단 순서로 게임기의 앞모습을 따른다. */

:root {
  /* 게임기 재료의 색 */
  --carpet: #0d0a1c;
  --body: #2236b0;        /* 게임기 몸통 칠 */
  --body-deep: #18278a;
  --trim: #ff4fa3;        /* 몸통 가장자리 띠 */
  --bezel: #08070f;       /* 화면 둘레 검은 판 */
  --ink: #f1ecff;
  --ink-soft: #d9d0f5;
  --ink-dim: #a39bc6;     /* 열 머리처럼 덜 중요한 글자 */
  --yellow: #ffe14d;
  --cyan: #7ff0ff;
  --pink: #ff7ac0;
  --dark: #1b0b3a;

  /* 크기 */
  --page-top: 14px;
  --marquee-h: 112px;
  --bezel-pad: 20px;
  --screen-rim: 10px;

  /* 스크롤 없이 게임 자리가 다 보이도록 창 높이에서 게임 자리 높이를 구한다 */
  --slot-avail: calc(100svh - var(--page-top) - var(--marquee-h) - var(--bezel-pad) * 2);

  --font-logo: 'Bagel Fat One', 'Do Hyeon', sans-serif;
  --font-sign: 'Do Hyeon', sans-serif;
  --font-body: 'Orbit', 'Do Hyeon', sans-serif;
  --font-pixel: 'Jersey 10', 'Do Hyeon', monospace;

  color-scheme: dark;
  scrollbar-color: var(--trim) var(--carpet);
}

* {
  box-sizing: border-box;
}

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

::selection {
  background: var(--trim);
  color: var(--dark);
}

body {
  margin: 0;
  padding: var(--page-top) 20px 48px;
  background: var(--carpet) url("carpet.svg") 0 0 / 220px 220px repeat;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  word-spacing: -0.12em;     /* Orbit 은 띄어쓰기 폭이 넓어서 줄인다 */
  word-break: keep-all;     /* 한글이 낱자 중간에서 끊기지 않게 한다 */
  overflow-wrap: anywhere;   /* 아주 긴 글자는 칸 안에서 줄을 바꾼다 */
  caret-color: var(--yellow);
}

:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

button {
  font-family: var(--font-sign);
  cursor: pointer;
}

/* ---------- 게임기 몸통 ---------- */

.cabinet {
  max-width: 1240px;
  margin: 0 auto;
  border: 8px solid var(--trim);
  border-radius: 10px 10px 4px 4px;
  background: var(--body);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.55);
}

/* ---------- 간판 ---------- */

.marquee {
  position: relative;
  overflow: hidden;
  height: var(--marquee-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 0 24px;
  border-bottom: 6px solid #11101a;
  border-radius: 2px 2px 0 0;
  background:
    url("moon.svg") right 5% center / auto 70% no-repeat,
    url("stars.svg") 0 0 / 240px 120px repeat,
    linear-gradient(to bottom, #2a1576 0%, #170c4a 70%, #0f0836 100%);
  image-rendering: pixelated;
}

/* 간판 뒤의 형광등 빛: 위쪽이 밝다 */
.marquee::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 45%);
  pointer-events: none;
}

.marquee-cat {
  position: relative;
  width: 56px;
  height: 56px;
  flex: none;
  transform: translateY(-6px) rotate(-8deg);
}

.banner-text {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#game-banner h1 {
  font-family: var(--font-logo);
  font-weight: 400;
  font-size: 62px;
  line-height: 1.05;
  letter-spacing: 1px;
  color: var(--yellow);
  -webkit-text-stroke: 7px var(--dark);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--dark), 0 8px 0 #d8297e;
}

#game-banner h1 .pink {
  color: var(--pink);
}

#game-banner p {
  margin-top: 4px;
  font-family: var(--font-sign);
  font-size: 20px;
  line-height: 1.2;
  color: #fff4c2;
  letter-spacing: 1px;
}

/* 처음 열 때 간판 불이 깜빡이며 켜진다. 처음부터 보이고, 밝기만 바뀐다. */
@media (prefers-reduced-motion: no-preference) {
  .marquee {
    animation: marquee-on 1.1s steps(1, end) both;
  }
}

@keyframes marquee-on {
  0% { filter: brightness(0.45); }
  18% { filter: brightness(1.05); }
  26% { filter: brightness(0.5); }
  40% { filter: brightness(1); }
  48% { filter: brightness(0.7); }
  60%, 100% { filter: none; }
}

/* ---------- 화면 테두리 ---------- */

.bezel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-areas: "about screen board";
  align-items: start;
  gap: 32px;
  padding: var(--bezel-pad) 28px;
  background: var(--bezel);
  border-bottom: 4px solid #11101a;
}

#game-slot { grid-area: screen; }
#game-about { grid-area: about; }
.score-column { grid-area: board; }

/* ---------- 게임 자리 (모니터) ---------- */

#game-slot {
  position: relative;
  width: min(430px, calc(var(--slot-avail) * 9 / 16));
  aspect-ratio: 9 / 16;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 0 20px 24%;
  border: var(--screen-rim) solid #1c1a29;
  border-radius: 22px;
  overflow: hidden;
  background: #0b0630 url("screen.svg") center / cover no-repeat;
  image-rendering: pixelated;
  box-shadow: 0 0 0 2px #2e2a45, 0 10px 24px rgba(0, 0, 0, 0.6);
}

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

/* 브라운관의 가로줄과 둥근 유리 그림자. 누르기는 아래 canvas 로 그대로 간다. */
#game-slot::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  border-radius: 12px;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px);
  box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.65);
}

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

/* 시작 단추: 불이 들어오는 둥근 오락기 단추 */
#game-start {
  min-height: 64px;
  padding: 0 34px 2px;
  border: 0;
  border-bottom: 7px solid #8f1050;
  border-radius: 999px;
  background: radial-gradient(ellipse at 50% 30%, #ffb3dd 0%, #ff4fa3 55%, #e0307f 100%);
  color: var(--dark);
  font-size: 27px;
  letter-spacing: 1px;
  box-shadow: 0 0 0 6px #0b0716, 0 0 0 9px var(--yellow), 0 12px 24px rgba(0, 0, 0, 0.55);
}

#game-start:hover {
  filter: brightness(1.1);
}

#game-start:active {
  border-bottom-width: 3px;
  transform: translateY(4px);
}

#game-start:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 12px;
}

@media (prefers-reduced-motion: no-preference) {
  #game-start {
    animation: start-lamp 1.4s steps(2, jump-none) infinite;
  }
}

@keyframes start-lamp {
  from { filter: brightness(1); }
  to { filter: brightness(1.22); }
}

.slot-label {
  padding: 10px 16px;
  border: 3px solid var(--cyan);
  background: #0b0716;
  color: #ffffff;
  font-family: var(--font-sign);
  font-size: 19px;
  line-height: 1.35;
  text-align: center;
}

/* ---------- 왼쪽 테두리: 인쇄된 설명 ---------- */

.bezel-side {
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
  padding-top: 8px;
}

.bezel-side h2 {
  font-family: var(--font-sign);
  font-weight: 400;
  font-size: 28px;
  line-height: 1.2;
  color: var(--cyan);
}

.print {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.print p {
  font-size: 15.5px;
  color: var(--ink-soft);
  max-width: 34em;
}

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

.controls li {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--ink-soft);
  font-size: 15.5px;
}

.keys {
  flex: none;
  display: inline-flex;
  gap: 6px;
  min-width: 102px;
}

/* 노란 오락기 단추 모양 키 */
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 42px;
  padding: 0 10px;
  padding-bottom: 5px;
  border-radius: 8px;
  /* 아래 5px 은 단추의 옆면이다 */
  background: linear-gradient(to bottom, var(--yellow) calc(100% - 5px), #b8941c calc(100% - 5px));
  color: var(--dark);
  font-family: var(--font-sign);
  font-size: 17px;
}

kbd svg {
  width: 16px;
  height: 16px;
  fill: var(--dark);
}

kbd.tap {
  min-width: 102px;
}

/* 제조 명판: 쇠판에 새긴 글자와 네 귀퉁이 나사 */
.plate {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
  padding: 18px 22px;
  border-radius: 6px;
  background: linear-gradient(to bottom, #dfe2ea, #b3b7c4);
}

/* 네 귀퉁이 나사 */
.plate::before {
  content: "";
  position: absolute;
  inset: 6px;
  pointer-events: none;
  background:
    radial-gradient(circle at 3px 3px, #6d7184 2.5px, transparent 3.5px),
    radial-gradient(circle at calc(100% - 3px) 3px, #6d7184 2.5px, transparent 3.5px),
    radial-gradient(circle at 3px calc(100% - 3px), #6d7184 2.5px, transparent 3.5px),
    radial-gradient(circle at calc(100% - 3px) calc(100% - 3px), #6d7184 2.5px, transparent 3.5px);
}

.plate dt {
  font-size: 12.5px;
  line-height: 1.3;
  color: #3b3f4f;
}

.plate dd {
  font-family: var(--font-sign);
  font-size: 20px;
  line-height: 1.25;
  color: #11131b;
}

/* ---------- 오른쪽 테두리: 점수판 ---------- */

.board {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.board-title h2 {
  color: var(--yellow);
}

.board-title span {
  font-size: 14px;
  color: var(--ink-soft);
}

.board-head,
.scores li:not(.soft) {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 12px;
  padding: 0 12px;
}

.board-head {
  padding-bottom: 6px;
  border-bottom: 2px dashed #3d3760;
  font-size: 13px;
  color: var(--ink-dim);
}

.board-head span:last-child {
  text-align: right;
}

.scores {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-pixel);
  font-size: 31px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  color: #ece8ff;
}

.scores li {
  padding-top: 2px;
  padding-bottom: 2px;
}

.scores .rank {
  color: var(--ink-dim);
}

.scores .name {
  letter-spacing: 4px;
}

.scores .points {
  text-align: right;
}

/* 1~3등은 옛 오락기 점수표처럼 줄마다 다른 색 */
.scores .first { color: var(--yellow); }
.scores .second { color: var(--cyan); }
.scores .third { color: var(--pink); }

.scores .first .rank,
.scores .second .rank,
.scores .third .rank {
  color: inherit;
}

.scores li.soft {
  padding: 14px 12px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink-soft);
}

/* 방금 올린 줄: 노란 띠가 깜빡인다 */
.scores li.just-added {
  background: var(--yellow);
  color: var(--dark);
}

.scores li.just-added .rank {
  color: var(--dark);
}

@media (prefers-reduced-motion: no-preference) {
  .scores li.just-added {
    animation: just-added-blink 0.5s steps(2, jump-none) 6;
  }
}

@keyframes just-added-blink {
  from { background: var(--yellow); color: var(--dark); }
  to { background: transparent; color: var(--yellow); }
}

.board-note {
  padding: 12px 14px;
  border: 2px solid #3d3760;
  border-radius: 6px;
  font-size: 14.5px;
  color: var(--ink-soft);
}

/* ---------- 조종대 ---------- */

.deck {
  position: relative;
  margin: 0 -22px;
  height: 104px;
  border: 6px solid var(--trim);
  border-radius: 10px;
  background:
    linear-gradient(to bottom,
      #ffd23f 0 7px, #ff8a2b 7px 14px, #ff4fa3 14px 21px,
      #2a1d8f 21px, #1c1366 100%);
  box-shadow: 0 16px 24px rgba(0, 0, 0, 0.5);
}

.deck-art {
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: min(600px, 92%);
  height: 86px;
  transform: translateX(-50%);
}

/* ---------- 아랫단: 동전 문과 댓글 ---------- */

.lower {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 36px;
  padding: 40px 36px 44px;
  background: var(--body);
}

.coin-door {
  width: 140px;
  height: auto;
}

.comment-board {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.comment-board h2 {
  font-family: var(--font-sign);
  font-weight: 400;
  font-size: 30px;
  line-height: 1.2;
  color: #ffffff;
}

.comment-form {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
}

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

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

.field input,
.field textarea {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border-radius: 6px;
  border: 2px solid #4d63e0;
  background: #0b0716;
  color: #ffffff;
  font-family: var(--font-body);
  font-size: 16px;
}

.field textarea {
  padding: 12px 14px;
  min-height: 50px;
  height: 50px;
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #a8a3c4;
}

.field input:hover,
.field textarea:hover {
  border-color: var(--cyan);
}

.field input:focus-visible,
.field textarea:focus-visible {
  border-color: var(--yellow);
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}

/* 노란 오락기 단추: 댓글 올리기 */
#comment-submit {
  min-height: 50px;
  padding: 0 24px;
  border: 0;
  border-bottom: 6px solid #b8941c;
  border-radius: 10px;
  background: var(--yellow);
  color: var(--dark);
  font-size: 20px;
  white-space: nowrap;
}

#comment-submit:hover {
  filter: brightness(1.06);
}

#comment-submit:active {
  border-bottom-width: 2px;
  transform: translateY(4px);
}

#comment-submit:disabled {
  opacity: 0.55;
  cursor: default;
}

#comment-message {
  font-size: 15px;
  color: #ffffff;
}

.comments {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.comments li {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--body-deep);
  border: 2px solid #3348c4;
}

.comments li.soft {
  grid-column: 1 / -1;
  color: #e6e9ff;
}

.comment-nickname {
  font-family: var(--font-sign);
  font-size: 19px;
  line-height: 1.25;
  color: var(--yellow);
}

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

/* ---------- 이니셜 창: 옛 오락기의 이름 넣기 화면 ---------- */

#initials-dialog {
  width: min(420px, calc(100vw - 24px));
  padding: 28px 24px 24px;
  border: 10px solid #1c1a29;
  border-radius: 20px;
  background:
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 3px),
    #07060d;
  color: var(--ink);
  box-shadow: 0 0 0 3px var(--trim), 0 24px 48px rgba(0, 0, 0, 0.6);
  text-align: center;
}

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

#initials-dialog::backdrop {
  background: rgba(5, 3, 12, 0.82);
}

#initials-dialog h2 {
  font-family: var(--font-sign);
  font-weight: 400;
  font-size: 32px;
  line-height: 1.2;
  color: var(--yellow);
}

#initials-dialog .soft {
  font-size: 15px;
  color: var(--ink-soft);
}

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

.initial-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border: 3px solid transparent;
  border-radius: 10px;
}

/* 키보드로 친 글자가 들어갈 칸: 노란 테두리와 밑줄 */
.initial-slot.active {
  border-color: var(--yellow);
}

.initial-letter {
  min-width: 1ch;
  font-family: var(--font-pixel);
  font-size: 104px;
  line-height: 0.9;
  color: #ffffff;
  border-bottom: 5px solid #3d3760;
}

.initial-slot.active .initial-letter {
  color: var(--yellow);
  border-bottom-color: var(--yellow);
}

@media (prefers-reduced-motion: no-preference) {
  .initial-slot.active .initial-letter {
    animation: cursor-blink 0.9s steps(2, jump-none) infinite;
  }
}

@keyframes cursor-blink {
  from { border-bottom-color: var(--yellow); }
  to { border-bottom-color: transparent; }
}

/* 휴대폰에서 누르기 쉽게 가로세로 44px 이상으로 만든다 */
.initial-step {
  width: 64px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #3d3760;
  border-radius: 8px;
  background: #16132a;
}

.initial-step svg {
  width: 20px;
  height: 20px;
  fill: var(--cyan);
}

.initial-step:hover {
  border-color: var(--cyan);
  background: #1f1b3a;
}

.initial-step:active {
  transform: translateY(2px);
}

#initials-message {
  color: #ffb3c8;
}

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

.initials-actions button {
  flex: 1;
  min-height: 54px;
  border-radius: 10px;
  font-size: 22px;
}

.secondary-button {
  border: 2px solid #6b648f;
  background: transparent;
  color: #ffffff;
}

.secondary-button:hover {
  border-color: #ffffff;
}

#initials-confirm {
  border: 0;
  border-bottom: 6px solid #8f1050;
  background: radial-gradient(ellipse at 50% 30%, #ffb3dd 0%, #ff4fa3 60%, #e0307f 100%);
  color: var(--dark);
}

#initials-confirm:hover {
  filter: brightness(1.08);
}

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

/* ---------- 좁은 화면: 게임기를 세로 한 줄로 ---------- */

@media (max-width: 1080px) {
  .bezel {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "screen board"
      "screen about";
  }
}

@media (max-width: 760px) {
  :root {
    --page-top: 0px;
    --marquee-h: 78px;
    --bezel-pad: 10px;
    --screen-rim: 7px;
  }

  body {
    padding: 0 0 24px;
  }

  .cabinet {
    border-width: 5px;
    border-radius: 0;
  }

  .marquee {
    gap: 10px;
    padding: 0 14px;
    background-position: right 8px center, 0 0, 0 0;
    background-size: auto 62%, 240px 120px, auto;
  }

  .marquee-cat {
    width: 36px;
    height: 36px;
  }

  #game-banner h1 {
    font-size: 36px;
    -webkit-text-stroke-width: 5px;
    text-shadow: 0 3px 0 var(--dark), 0 5px 0 #d8297e;
  }

  #game-banner p {
    font-size: 15px;
  }

  .bezel {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "screen"
      "about"
      "board";
    justify-items: center;
    gap: 28px;
    padding: var(--bezel-pad) 10px 28px;
  }

  #game-slot {
    width: min(100%, calc(var(--slot-avail) * 9 / 16));
    border-radius: 18px;
  }

  .bezel-side {
    width: 100%;
    padding: 0 8px;
  }

  .deck {
    margin: 0 -5px;
    height: 84px;
    border-width: 5px;
    border-radius: 0;
  }

  .deck-art {
    height: 68px;
    bottom: 4px;
  }

  .lower {
    grid-template-columns: minmax(0, 1fr);
    padding: 28px 16px 32px;
  }

  .coin-door {
    display: none;
  }

  .comment-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .field textarea {
    height: auto;
    min-height: 96px;
  }

  #comment-submit {
    width: 100%;
  }

  .comments {
    grid-template-columns: minmax(0, 1fr);
  }
}
