/* © 2026 WJoy. All rights reserved. MineMine! (지뢰지뢰!) */
/* =====================================================================
   테마: 8비트 거실 게임기
   검은 바탕 · 흰 이중 테두리(RPG 대화창) · 파란 블록 · 주황 포인트
   ===================================================================== */

/* 한글 도트 글꼴 '갈무리(Galmuri)' — SIL 오픈 폰트 라이선스(fonts/Galmuri-LICENSE.txt)
   칸 숫자용 글꼴 'Nunito Sans' ExtraBold(숫자만) — SIL 오픈 폰트 라이선스(fonts/NunitoSans-LICENSE.txt) */
@font-face {
  font-family: "Galmuri14";
  src: url("fonts/Galmuri14.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Nunito Sans Digits";
  font-weight: 800;
  src: url("fonts/NunitoSans-digits.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Galmuri11";
  font-weight: 700;
  src: url("fonts/Galmuri11-Bold.woff2") format("woff2");
  font-display: swap;
}

:root {
  /* 8비트 게임기 팔레트: 원래 색에서 채도만 약 15% 낮춤(밝기는 그대로) */
  --black: #0c0d10;          /* 게임 화면·창 바탕: 완전한 검정보다 아주 살짝 밝게 */
  --page: #16181d;           /* 페이지 바탕: 게임 화면보다 한 단계 밝게 */
  --white: #f6f6f2;
  --gray: #7c7c7c;
  --dark-gray: #1f2024;      /* 열린 칸 바닥 */
  --blue: #135de5;
  --blue-hover: #387ce8;
  --blue-light: #4ab7ee;
  --blue-dark: #0e0eae;
  --orange: #ed9847;
  --orange-dark: #98430c;
  --yellow: #eed382;
  --red: #e54213;
  --mine-bg: #d24c26;        /* 지뢰 칸 바탕: 빨강에서 채도만 살짝 낮춤 */
  --mine-bg-light: #ec8160;
  --mine-bg-dark: #8c2c12;
  --green: #0d9b0d;
  --green-light: #b1e729;
  --green-dark: #075107;
  --pink: #ee82ee;
  --pink-light: #f3bdf3;
  --pink-dark: #9b0d9b;

  /* 블록 가장자리 2단 명암용: 맨 바깥 1px은 더 밝게·더 어둡게 */
  --blue-edge-light: #9bd7f6;
  --blue-edge-dark: #080860;
  --mine-bg-edge-light: #f5baa8;
  --mine-bg-edge-dark: #4d180a;
  --green-edge-light: #d4f289;
  --green-edge-dark: #042d04;
  --pink-edge-light: #f8dbf8;
  --pink-edge-dark: #550755;
  /* 블록 네 모서리를 2px씩 깎아 둥글둥글한 도트 버튼처럼 */
  --cut-corners: polygon(2px 0, calc(100% - 2px) 0, 100% 2px, 100% calc(100% - 2px), calc(100% - 2px) 100%, 2px 100%, 0 calc(100% - 2px), 0 2px);
  --pixel: 4px;

  /* 본문은 Galmuri14(15px 배수에서 가장 선명), 제목·숫자는 Galmuri11 Bold(12px 배수) */
  --font-body: "Galmuri14", "Courier New", monospace;
  --font-title: "Galmuri11", "Galmuri14", "Courier New", monospace;
  --font-number: "Nunito Sans Digits", "Galmuri11", sans-serif;

  font-family: var(--font-body);
  font-size: 15px;
  color: var(--white);
  background: var(--page);
  -webkit-font-smoothing: none;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 24px;
  /* 아주 옅은 도트 무늬 바탕 */
  background:
    radial-gradient(circle, #23262e 1px, transparent 1.5px) 0 0 / 16px 16px,
    var(--page);
}

button, input { font: inherit; }

/* 공통: RPG 대화창 테두리(흰 테두리 + 검은 틈 + 흰 바깥 테두리) */
.game,
.guide,
.ranking-popup,
.congrats-popup {
  background: var(--black);
  border: var(--pixel) solid var(--white);
  box-shadow: 0 0 0 var(--pixel) var(--black), 0 0 0 calc(var(--pixel) * 2) var(--white);
}

/* 공통: 검은 바탕 + 흰 테두리 버튼, 마우스를 올리면 주황 */
.difficulty-buttons button,
.ranking-tabs button,
#undo-button,
#custom-cancel,
#celebration-close {
  padding: 6px 12px;
  border: 3px solid var(--white);
  color: var(--white);
  background: var(--black);
  cursor: pointer;
}

.difficulty-buttons button:hover,
.ranking-tabs button:hover,
#undo-button:hover:not(:disabled),
#custom-cancel:hover,
#celebration-close:hover {
  color: var(--orange);
  border-color: var(--orange);
}

/* 공통: 키보드 초점은 주황 테두리 */
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 3px;
}

/* 게임판이 항상 브라우저 가운데에 오도록: 레이아웃 크기는 게임 카드만으로 정해집니다.
   해설 창은 절대 위치로 띄워서(왼쪽 또는 아래) 내용·크기가 바뀌어도 게임판이 움직이지 않습니다.
   왼쪽에 자리가 없으면(JS가 guide-below를 붙임) 게임 카드 아래에 붙습니다. */
.layout {
  --game-width: 800px;
  --guide-width: 260px;
  position: relative;
  width: min(100%, var(--game-width));
  margin: 0 auto;
}
.layout > .game { width: auto; }
.layout > .guide { position: absolute; top: 0; right: calc(100% + 24px); width: var(--guide-width); }
.layout.guide-below > .guide { top: calc(100% + 24px); right: calc(var(--pixel) * 2); left: calc(var(--pixel) * 2); width: auto; margin-bottom: 24px; }

.game {
  position: relative;
  width: min(100%, var(--game-width));
  min-width: 0;
  margin: calc(var(--pixel) * 2);
  padding: 24px 28px;
  text-align: center;
}

h1 {
  margin: 0 0 22px;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 46px;
  letter-spacing: 0.08em;
  color: var(--orange);
  text-shadow: 3px 3px 0 var(--orange-dark);
}

/* 난이도·랭킹 버튼은 제목 위 별도 줄(오른쪽 정렬)에 둬서 제목을 가리지 않게 합니다. */
.top-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin: -6px 0 12px 0;
}

.difficulty-buttons { display: flex; flex-wrap: wrap; gap: 6px; }

/* 선택된 난이도: RPG 메뉴 커서(▶)와 주황 글자 */
.difficulty-buttons button.active,
.ranking-tabs button.active {
  color: var(--black);
  border-color: var(--orange);
  background: var(--orange);
}
.difficulty-buttons button.active::before,
.ranking-tabs button.active::before { content: "▶ "; }

#ranking-button {
  padding: 6px 12px;
  border: 3px solid var(--orange);
  color: var(--orange);
  background: var(--black);
  cursor: pointer;
}
#ranking-button:hover { color: var(--black); background: var(--orange); }

.message {
  min-height: 24px;
  margin: 12px 0 16px;
  color: var(--white);
  line-height: 1.6;
}

/* 상태 줄: 가운데 LCD 두 개, 오른쪽 끝에 새 게임 버튼 */
.status-bar {
  display: grid;
  grid-template-columns: 1fr auto auto 1fr;
  align-items: center;
  column-gap: 18px;
  margin: 2px 0 18px;
  color: var(--white);
}
.status-bar > .lcd:first-child { grid-column: 2; }
.status-bar > .game-actions { grid-column: 4; justify-self: end; margin: 0; }
/* LCD 숫자판: 검은 액정 + 지뢰 블록 색 숫자(살짝 빛남) */
.lcd {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #000;
  box-shadow: inset 3px 3px 0 #000, inset -3px -3px 0 #2b2d33, 0 0 0 3px var(--gray);
}
.lcd b {
  font-family: var(--font-number);
  font-weight: 800;
  font-size: 32px;
  line-height: 1;
  letter-spacing: 0.08em;
  color: #bf5739; /* 지뢰 블록 색에서 채도를 조금 낮춤 */
  text-shadow: 0 0 5px rgba(191, 87, 57, 0.5);
}
.lcd-icon { display: inline-block; width: 22px; height: 22px; background: center / contain no-repeat; image-rendering: pixelated; }
/* 게임판과 같은 지뢰 그림, 검은 액정에서도 보이게 밝은 테두리 */
.lcd-mine {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 11' shape-rendering='crispEdges'%3E%3Crect x='5' y='0' width='1' height='1' fill='%237e8292'/%3E%3Crect x='1' y='1' width='1' height='1' fill='%237e8292'/%3E%3Crect x='5' y='1' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='9' y='1' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='2' width='1' height='1' fill='%235d6070'/%3E%3Crect x='5' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='8' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='3' width='1' height='1' fill='%235d6070'/%3E%3Crect x='4' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='7' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='4' width='1' height='1' fill='%235d6070'/%3E%3Crect x='3' y='4' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='4' y='4' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='5' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='7' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='8' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='0' y='5' width='1' height='1' fill='%237e8292'/%3E%3Crect x='1' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='7' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='8' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='9' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='10' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='7' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='8' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='7' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='7' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='7' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='7' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='7' y='7' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='8' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='8' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='8' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='8' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='8' y='8' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='1' y='9' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='9' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='9' y='9' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='10' width='1' height='1' fill='%230c0d10'/%3E%3C/svg%3E");
  filter: drop-shadow(1px 0 0 var(--white)) drop-shadow(-1px 0 0 var(--white)) drop-shadow(0 1px 0 var(--white)) drop-shadow(0 -1px 0 var(--white));
}
.lcd-clock { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 11' shape-rendering='crispEdges'%3E%3Crect x='4' y='1' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='5' y='1' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='6' y='1' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='3' y='2' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='4' y='2' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='5' y='2' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='6' y='2' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='7' y='2' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='2' y='3' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='3' y='3' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='4' y='3' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='5' y='3' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='6' y='3' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='7' y='3' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='8' y='3' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='1' y='4' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='2' y='4' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='3' y='4' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='4' y='4' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='5' y='4' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='6' y='4' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='7' y='4' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='8' y='4' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='9' y='4' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='1' y='5' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='2' y='5' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='3' y='5' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='4' y='5' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='5' y='5' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='6' y='5' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='7' y='5' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='8' y='5' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='9' y='5' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='1' y='6' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='2' y='6' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='3' y='6' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='4' y='6' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='5' y='6' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='6' y='6' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='7' y='6' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='8' y='6' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='9' y='6' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='2' y='7' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='3' y='7' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='4' y='7' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='5' y='7' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='6' y='7' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='7' y='7' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='8' y='7' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='3' y='8' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='4' y='8' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='5' y='8' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='6' y='8' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='7' y='8' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='4' y='9' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='5' y='9' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='6' y='9' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='3' y='0' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='0' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='0' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='0' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='7' y='0' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='1' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='8' y='1' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='1' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='9' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='0' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='10' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='0' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='10' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='0' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='10' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='0' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='10' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='0' y='7' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='10' y='7' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='1' y='8' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='9' y='8' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='9' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='8' y='9' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='10' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='10' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='10' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='10' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='7' y='10' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='2' width='1' height='1' fill='%23d24c26'/%3E%3Crect x='5' y='3' width='1' height='1' fill='%23d24c26'/%3E%3Crect x='5' y='4' width='1' height='1' fill='%23d24c26'/%3E%3Crect x='5' y='5' width='1' height='1' fill='%23d24c26'/%3E%3Crect x='6' y='5' width='1' height='1' fill='%23d24c26'/%3E%3Crect x='7' y='5' width='1' height='1' fill='%23bf5739'/%3E%3C/svg%3E"); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.timer-box { position: relative; }
.time-penalty {
  position: absolute;
  left: calc(100% + 6px);
  top: 0;
  color: var(--red);
  font-family: var(--font-title);
  font-weight: 700;
  white-space: nowrap;
  text-shadow: 2px 2px 0 var(--black);
  pointer-events: none;
  animation: time-penalty-rise 1.1s steps(11) forwards;
}
@keyframes time-penalty-rise {
  0% { transform: translateY(4px); opacity: 1; }
  60% { opacity: 1; }
  100% { transform: translateY(-26px); opacity: 0; }
}

.game-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}

/* 새 게임: 파란 입체 블록 버튼 */
.game-actions button {
  padding: 10px 20px;
  border: 0;
  color: var(--white);
  background: var(--blue);
  box-shadow: inset -1px -1px 0 var(--blue-edge-dark), inset 1px 1px 0 var(--blue-edge-light), inset calc(var(--pixel) * -1) calc(var(--pixel) * -1) 0 var(--blue-dark), inset var(--pixel) var(--pixel) 0 var(--blue-light);
  clip-path: var(--cut-corners);
  cursor: pointer;
}
.game-actions button:hover { background: var(--blue-hover); }
.game-actions button:active { box-shadow: inset 1px 1px 0 var(--blue-edge-dark), inset -1px -1px 0 var(--blue-edge-light), inset var(--pixel) var(--pixel) 0 var(--blue-dark), inset calc(var(--pixel) * -1) calc(var(--pixel) * -1) 0 var(--blue-light); }

/* 되돌리기: 도트 동그라미 화살표 아이콘 버튼 */
#undo-button { display: grid; place-items: center; width: 52px; height: 52px; padding: 0; }
#undo-button svg { fill: currentColor; }
#undo-button:active:not(:disabled) svg { transform: translate(2px, 2px); }
#undo-button:disabled { color: var(--gray); border-color: var(--gray); cursor: not-allowed; }

/* ---------- 게임판 ---------- */
.board {
  display: grid;
  grid-template-columns: repeat(var(--columns), 30px);
  gap: 2px;
  width: max-content;
  padding: 5px;
  background: var(--black);
  box-shadow: 0 0 0 3px var(--white);
  user-select: none;
  -webkit-user-select: none;
}

.board-wrap > .board { margin: 0 auto; }

/* 스크롤바는 만들지 않습니다. 판이 카드보다 넓으면 JS가 판 전체를 비율대로 줄여(zoom) 카드 안에 맞춥니다. */
.board-wrap {
  display: flex;
  width: 100%;
  overflow: visible;
  padding: 4px 0 8px; /* 좌우 여백 없이 판 끝선을 위쪽 버튼 줄과 같은 선에 둠 */
}

/* 닫힌 칸: 파란 입체 블록 */
.cell {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: var(--white);
  background: var(--blue);
  box-shadow: inset -1px -1px 0 var(--blue-edge-dark), inset 1px 1px 0 var(--blue-edge-light), inset -3px -3px 0 var(--blue-dark), inset 3px 3px 0 var(--blue-light);
  cursor: pointer;
  font-family: var(--font-number);
  font-weight: 800;
  font-size: 28px;
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  touch-action: manipulation;
}

.cell:hover { background-color: var(--blue-hover); }

.cell:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: -3px;
}

/* 닫힌 칸·깃발·힌트·지뢰 블록은 모서리를 깎고, 열린 칸(바닥)은 평평한 네모로 둡니다. */
.cell:not(.open) { clip-path: var(--cut-corners); }

/* 열린 칸: 어두운 바닥 */
.cell.open {
  cursor: default;
  background: var(--dark-gray);
  box-shadow: none;
}

/* 깃발·지뢰는 글자 대신 도트 그림으로 그립니다(글자는 투명 처리). */
.cell.flagged {
  color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' shape-rendering='crispEdges'%3E%3Crect x='4' y='1' width='2' height='12' fill='%23f6f6f2'/%3E%3Cg fill='%23e54213'%3E%3Crect x='6' y='1' width='6' height='1'/%3E%3Crect x='6' y='2' width='8' height='1'/%3E%3Crect x='6' y='3' width='9' height='1'/%3E%3Crect x='6' y='4' width='8' height='1'/%3E%3Crect x='6' y='5' width='6' height='1'/%3E%3C/g%3E%3Crect x='6' y='6' width='4' height='1' fill='%239b1a0d'/%3E%3Crect x='2' y='13' width='6' height='1' fill='%23bcbcbc'/%3E%3Crect x='1' y='14' width='8' height='1' fill='%237c7c7c'/%3E%3C/svg%3E");
  background-size: 24px 24px;
  background-position: center;
  background-repeat: no-repeat;
}

/* 지뢰: 8방향 가시 + 명암(11칸 도트, 한 칸 = 2px) */
/* 패배 후 드러난 지뢰: 빨간 입체 블록(밝은 위·왼쪽, 어두운 아래·오른쪽) + 지뢰 그림 */
.cell.mine {
  color: transparent;
  background-color: var(--mine-bg);
  box-shadow: inset -1px -1px 0 var(--mine-bg-edge-dark), inset 1px 1px 0 var(--mine-bg-edge-light), inset -3px -3px 0 var(--mine-bg-dark), inset 3px 3px 0 var(--mine-bg-light);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 11' shape-rendering='crispEdges'%3E%3Crect x='5' y='0' width='1' height='1' fill='%237e8292'/%3E%3Crect x='1' y='1' width='1' height='1' fill='%237e8292'/%3E%3Crect x='5' y='1' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='9' y='1' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='2' width='1' height='1' fill='%235d6070'/%3E%3Crect x='5' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='8' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='3' width='1' height='1' fill='%235d6070'/%3E%3Crect x='4' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='7' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='4' width='1' height='1' fill='%235d6070'/%3E%3Crect x='3' y='4' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='4' y='4' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='5' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='7' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='8' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='0' y='5' width='1' height='1' fill='%237e8292'/%3E%3Crect x='1' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='7' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='8' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='9' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='10' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='7' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='8' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='7' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='7' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='7' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='7' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='7' y='7' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='8' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='8' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='8' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='8' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='8' y='8' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='1' y='9' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='9' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='9' y='9' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='10' width='1' height='1' fill='%230c0d10'/%3E%3C/svg%3E");
  background-size: 22px 22px;
  image-rendering: pixelated;
  background-position: center;
  background-repeat: no-repeat;
}

/* 실제로 밟은 지뢰 칸: 빨간 입체 블록 + 노랑·주황 폭발 별(12칸 도트, 한 칸 = 2px) */
.cell.mine.exploded {
  background-color: var(--mine-bg);
  /* 다른 블록과 같은 입체 테두리(밝은 위·왼쪽, 어두운 아래·오른쪽) */
  box-shadow: inset -1px -1px 0 var(--mine-bg-edge-dark), inset 1px 1px 0 var(--mine-bg-edge-light), inset -3px -3px 0 var(--mine-bg-dark), inset 3px 3px 0 var(--mine-bg-light);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' shape-rendering='crispEdges'%3E%3Crect x='5' y='1' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='6' y='1' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='2' y='2' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='3' y='2' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='5' y='2' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='6' y='2' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='8' y='2' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='9' y='2' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='2' y='3' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='3' y='3' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='4' y='3' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='5' y='3' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='6' y='3' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='7' y='3' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='8' y='3' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='9' y='3' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='3' y='4' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='4' y='4' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='5' y='4' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='6' y='4' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='7' y='4' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='8' y='4' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='1' y='5' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='2' y='5' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='3' y='5' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='4' y='5' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='5' y='5' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='6' y='5' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='7' y='5' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='8' y='5' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='9' y='5' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='10' y='5' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='1' y='6' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='2' y='6' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='3' y='6' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='4' y='6' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='5' y='6' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='6' y='6' width='1' height='1' fill='%23f6f6f2'/%3E%3Crect x='7' y='6' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='8' y='6' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='9' y='6' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='10' y='6' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='3' y='7' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='4' y='7' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='5' y='7' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='6' y='7' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='7' y='7' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='8' y='7' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='2' y='8' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='3' y='8' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='4' y='8' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='5' y='8' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='6' y='8' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='7' y='8' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='8' y='8' width='1' height='1' fill='%23f08a24'/%3E%3Crect x='9' y='8' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='2' y='9' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='3' y='9' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='5' y='9' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='6' y='9' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='8' y='9' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='9' y='9' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='5' y='10' width='1' height='1' fill='%23f2cf4a'/%3E%3Crect x='6' y='10' width='1' height='1' fill='%23f2cf4a'/%3E%3C/svg%3E");
  background-size: 24px 24px;
  image-rendering: pixelated;
}

/* ---------- 비상으로 열린 칸 표시 ---------- */
/* 고른 칸: 칸이 노랗게 한 번 번쩍이면서 네 모서리 방향으로 반짝이가 튀어 나가요(프레임 단위).
   효과가 끝나면 가장 마지막에 연 칸(emergency-last)에만 노란 테두리가 남아요. */
.cell.emergency-pick {
  position: relative;
  z-index: 1;
  overflow: visible;
  animation: emergency-flash 0.55s steps(1) 1;
}
.cell.emergency-last { box-shadow: inset 0 0 0 3px var(--yellow); }
.cell.emergency-pick::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 14px;
  width: 2px;
  height: 2px;
  pointer-events: none;
  animation: emergency-sparkle 0.55s steps(1) 1;
}

@keyframes emergency-flash {
  0% { background-color: var(--yellow); box-shadow: inset 0 0 0 3px #fffbe6; }
  40% { background-color: var(--dark-gray); box-shadow: inset 0 0 0 3px var(--yellow); }
}
@keyframes emergency-sparkle {
  0.00% { box-shadow: -9px -9px 0 3px #fffbe6, 9px -9px 0 3px #fffbe6, -9px 9px 0 3px #fffbe6, 9px 9px 0 3px #fffbe6; }
  16.67% { box-shadow: -15px -15px 0 2px #fffbe6, 15px -15px 0 2px #fffbe6, -15px 15px 0 2px #fffbe6, 15px 15px 0 2px #fffbe6; }
  33.33% { box-shadow: -21px -21px 0 2px var(--yellow), 21px -21px 0 2px var(--yellow), -21px 21px 0 2px var(--yellow), 21px 21px 0 2px var(--yellow); }
  50.00% { box-shadow: -27px -27px 0 2px var(--yellow), 27px -27px 0 2px var(--yellow), -27px 27px 0 2px var(--yellow), 27px 27px 0 2px var(--yellow); }
  66.67% { box-shadow: -33px -33px 0 2px var(--orange), 33px -33px 0 2px var(--orange), -33px 33px 0 2px var(--orange), 33px 33px 0 2px var(--orange); }
  83.33% { box-shadow: -36px -36px 0 1px var(--orange), 36px -36px 0 1px var(--orange), -36px 36px 0 1px var(--orange), 36px 36px 0 1px var(--orange); }
  100% { box-shadow: none; }
}

/* 연쇄로 함께 열린 칸: 한 번 은은하게 번쩍임 */
.cell.emergency-area { animation: emergency-glow 0.6s steps(3) 1; }

@keyframes emergency-flash {
  0% { background-color: var(--yellow); box-shadow: inset 0 0 0 3px #fffbe6; }
  60% { background-color: var(--dark-gray); box-shadow: inset 0 0 0 3px var(--yellow); }
}
@keyframes emergency-glow {
  0% { background-color: #5a5230; }
  100% { background-color: var(--dark-gray); }
}

/* 힌트: 초록(안전)·분홍(지뢰) 입체 블록, 판단 기준 숫자는 주황 테두리 */
.cell.hint-safe { background-color: var(--green); box-shadow: inset -1px -1px 0 var(--green-edge-dark), inset 1px 1px 0 var(--green-edge-light), inset -3px -3px 0 var(--green-dark), inset 3px 3px 0 var(--green-light); }
.cell.hint-mine { background-color: var(--pink); box-shadow: inset -1px -1px 0 var(--pink-edge-dark), inset 1px 1px 0 var(--pink-edge-light), inset -3px -3px 0 var(--pink-dark), inset 3px 3px 0 var(--pink-light); }
.cell.hint-source { outline: 3px solid var(--orange); outline-offset: -3px; }
/* 해설에서 가리키는 숫자 이름표(A·B): 칸 왼쪽 위에 붙는 작은 주황 딱지 */
.cell.hint-source[data-tag] { position: relative; z-index: 2; overflow: visible; }
.cell.hint-source[data-tag]::after {
  content: attr(data-tag);
  position: absolute;
  left: -5px;
  top: -7px;
  width: 13px;
  height: 13px;
  display: grid;
  place-items: center;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 11px;
  line-height: 1;
  color: var(--black);
  background: var(--orange);
  box-shadow: 0 0 0 1px var(--black);
  pointer-events: none;
}

.cell.number-1 { color: var(--blue-light); }
.cell.number-2 { color: #61ce5e; }
.cell.number-3 { color: var(--red); }
.cell.number-4 { color: var(--orange); }
.cell.number-5 { color: var(--pink); }
.cell.number-6 { color: #11d7c9; }
.cell.number-7 { color: var(--white); }
.cell.number-8 { color: #bcbcbc; }

/* ---------- 아래 버튼 줄 ---------- */
.emergency-actions {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  min-height: 44px;
  margin-top: 16px;
  gap: 8px;
}

/* 느낌표 버튼(힌트 + 비상 통합): 주황 테두리의 도트 느낌표 */
.assist-button {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-left: auto;
  padding: 0;
  border: 3px solid var(--orange);
  color: var(--orange);
  background: var(--black);
  cursor: pointer;
}
.assist-button svg { fill: currentColor; }
.assist-button .pixel-shadow { fill: var(--orange-dark); }
.assist-button:hover { color: var(--black); background: var(--orange); }
.assist-button:hover .pixel-shadow { fill: var(--black); opacity: 0.35; }
.assist-button:active svg { transform: translate(2px, 2px); }
/* 비상 열기 중에는 빨강·주황으로 깜빡입니다(다시 누르면 멈춤). */
.assist-button.running { animation: assist-blink 0.4s steps(1) infinite; }
@keyframes assist-blink {
  0% { color: var(--orange); border-color: var(--orange); background: var(--black); }
  50% { color: var(--white); border-color: var(--red); background: var(--red); }
}

/* ---------- 효과음 볼륨(설정 창 안) ---------- */
.volume-row { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
#volume-slider { flex: 1; min-width: 0; margin-right: 8px; accent-color: var(--orange); cursor: pointer; }
#volume-value { min-width: 3ch; text-align: right; }

/* ---------- 팝업 공통 ---------- */
.celebration {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: rgb(0 0 0 / 70%);
}

.celebration[hidden] { display: none; }

.ranking-overlay {
  position: fixed;
  inset: 0;
  z-index: 11;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgb(0 0 0 / 75%);
}

.ranking-overlay[hidden] { display: none; }

.ranking-popup {
  width: min(100%, 660px);
  max-height: min(80vh, 700px);
  overflow-y: auto;
  padding: 22px;
  text-align: left;
}

.ranking-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.ranking-heading h2 { margin: 0; font-family: var(--font-title); font-size: 24px; color: var(--orange); }
#ranking-close, .popup-close { padding: 0 6px; border: 0; background: transparent; color: var(--white); font-size: 30px; line-height: 1; cursor: pointer; }
#ranking-close:hover, .popup-close:hover { color: var(--orange); }
.ranking-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.ranking-summary { margin: 16px 0 10px; color: var(--white); line-height: 1.6; }
.ranking-table-wrap { max-height: min(48vh, 440px); overflow: auto; }
.ranking-table { width: 100%; border-collapse: collapse; }
.ranking-table th, .ranking-table td { padding: 10px 8px; border-bottom: 2px dashed #34363c; }
.ranking-table th { position: sticky; top: 0; background: var(--black); color: var(--orange); font-weight: 400; border-bottom: 3px solid var(--white); }
.ranking-table td:first-child { color: var(--orange); }
.ranking-table tbody tr:first-child td { color: var(--yellow); }
.ranking-empty { padding: 22px 0; text-align: center; color: var(--gray); }

/* ---------- 클리어 축하 ---------- */
.fireworks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.firework {
  position: absolute;
  width: 1px;
  height: 1px;
}

/* 네모난 도트 불꽃 */
.particle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--color);
  animation: burst 1.25s steps(10) forwards;
}

.congrats-popup {
  position: relative;
  z-index: 1;
  width: min(80vw, 360px);
  padding: 28px;
  text-align: center;
  animation: popup-in 0.3s steps(4);
}

.congrats-popup h2 {
  margin: 0;
  font-family: var(--font-title);
  font-size: 36px;
  color: var(--orange);
  text-shadow: 3px 3px 0 var(--orange-dark);
}
/* 영어 제목("Congratulations!")은 한국어보다 길어서 좁은 화면에서 창 밖으로 나가지 않게 줄입니다. */
@media (max-width: 520px) {
  html[lang="en"] .congrats-popup h2 { font-size: clamp(22px, 7vw, 36px); }
}

.congrats-popup p { color: var(--white); }

.congrats-emoji {
  margin: 0 0 10px;
  font-family: var(--font-title);
  font-size: 24px;
  color: var(--yellow);
  letter-spacing: 0.04em;
  white-space: nowrap;
  animation: blink 0.8s steps(1) infinite;
}

#celebration-close { padding: 9px 22px; }

@keyframes burst {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translate(var(--x), var(--y)) scale(0.5); opacity: 0; }
}

@keyframes popup-in {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- 사용자 설정 창 ---------- */
.custom-popup { width: min(100%, 460px); }
.custom-form { display: grid; gap: 6px; margin-top: 16px; }
.custom-form label { margin-top: 8px; color: var(--orange); }
.custom-row { display: flex; align-items: center; gap: 12px; }
.custom-row input[type="range"] { flex: 1; min-width: 0; accent-color: var(--orange); cursor: pointer; }
.custom-row input[type="number"] { width: 76px; padding: 6px 8px; border: 3px solid var(--white); color: var(--white); background: var(--black); text-align: right; }
.custom-summary { margin: 14px 0 0; padding: 10px 12px; clip-path: var(--cut-corners); color: var(--white); background: var(--blue); box-shadow: inset -1px -1px 0 var(--blue-edge-dark), inset 1px 1px 0 var(--blue-edge-light), inset -3px -3px 0 var(--blue-dark), inset 3px 3px 0 var(--blue-light); }
.custom-note { margin: 6px 0 0; color: #b8b8b4; font-size: 15px; line-height: 1.6; }
.custom-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.custom-actions button { padding: 9px 16px; cursor: pointer; }
#custom-start { border: 3px solid var(--orange); color: var(--black); background: var(--orange); }
#custom-start:hover { color: var(--orange); background: var(--black); }

/* ---------- 좁은 화면 ---------- */
@media (max-width: 860px) {
  .top-controls {
    justify-content: center;
    margin: 0 0 14px;
  }
}

@media (max-width: 540px) {
  body { padding: 12px; }
  .game { padding: 20px 12px; }
  h1 { font-size: 34px; margin-bottom: 14px; }
  .ranking-popup { padding: 16px; }
  .ranking-table th, .ranking-table td { padding: 8px 4px; }
  .status-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
  .status-bar > .game-actions { flex-basis: 100%; }
}

/* 제목 아래 안내 문구를 없앤 만큼 제목과 상태 줄 사이 간격을 둡니다. */


/* ---------- 해설 창 ---------- */
.guide {
  margin-top: calc(var(--pixel) * 2);
  padding: 16px 16px 18px;
  text-align: left;
  line-height: 1.65;
}
.guide-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 10px; }
#guide-toggle { width: 30px; height: 30px; padding: 0; border: 3px solid var(--white); color: var(--white); background: var(--black); font-family: var(--font-title); font-size: 18px; line-height: 1; cursor: pointer; }
#guide-toggle:hover, .guide-open:hover { color: var(--orange); border-color: var(--orange); }
.guide[hidden] { display: none; }
/* 해설 창을 접었을 때: 화면 왼쪽 위 끝에 고정된 [+] 버튼 */
.guide-open { position: fixed; top: 16px; left: 16px; z-index: 9; width: 40px; height: 40px; padding: 0; border: 3px solid var(--white); color: var(--white); background: var(--black); font-family: var(--font-title); font-size: 24px; line-height: 1; cursor: pointer; }
.guide-open[hidden] { display: none; }
.guide-title { margin: 0; font-family: var(--font-title); font-size: 24px; color: var(--orange); }
.guide-body p { margin: 0 0 10px; }
.guide-body .quip {
  margin: 0 0 12px;
  padding: 10px 12px;
  color: var(--black);
  background: var(--yellow);
  clip-path: var(--cut-corners);
}
.guide-body .reason { color: #c8c8c4; }
.guide-body .pattern { margin: 0 0 8px; color: var(--yellow); }
.guide-body ol { margin: 8px 0 10px; padding-left: 1.3em; }
.guide-body ol li + li { margin-top: 6px; }
.guide-body .now { margin-top: 10px; padding-top: 10px; border-top: 2px dashed #34363c; color: #c8c8c4; }
.guide-body .counter { margin-top: 8px; color: var(--gray); }
.guide-body b { color: var(--orange); font-weight: 400; }
.guide-body .safe-word { color: #8fe0a2; }
.guide-body .mine-word { color: var(--pink); }

/* 해설 속 작은 예시 판 */
.example { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin: 6px 0 4px; }
.example figure { margin: 0; }
.example figcaption { margin-top: 4px; color: var(--gray); font-size: 13px; text-align: center; }
.ex-board { display: inline-grid; gap: 2px; padding: 3px; background: var(--black); box-shadow: 0 0 0 2px var(--white); }
.ex { position: relative; width: var(--ex, 24px); height: var(--ex, 24px); display: grid; place-items: center; font-family: var(--font-number); font-weight: 800; font-size: calc(var(--ex, 24px) * 0.75); line-height: 1; }
.ex.h { background: var(--blue); box-shadow: inset -2px -2px 0 var(--blue-dark), inset 2px 2px 0 var(--blue-light); color: var(--white); font-family: var(--font-title); font-size: 12px; }
.ex.o { background: var(--dark-gray); }
.ex.w { background: repeating-linear-gradient(135deg, #2b2d33 0 3px, #1a1b1f 3px 6px); }
.ex.fade { background: var(--blue); opacity: 0.25; }
.ex.S { background: var(--green); box-shadow: inset -2px -2px 0 var(--green-dark), inset 2px 2px 0 var(--green-light); color: var(--black); font-family: var(--font-title); font-size: 12px; }
.ex.M { background: var(--pink); box-shadow: inset -2px -2px 0 var(--pink-dark), inset 2px 2px 0 var(--pink-light); color: var(--black); font-family: var(--font-title); font-size: 12px; }
.guide .who { white-space: nowrap; }
.guide .tag { display: inline-block; min-width: 14px; padding: 0 2px; color: var(--black); background: var(--orange); font-family: var(--font-title); font-weight: 700; text-align: center; line-height: 1.3; }
.ex.F { background: var(--blue) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' shape-rendering='crispEdges'%3E%3Crect x='4' y='1' width='2' height='12' fill='%23f6f6f2'/%3E%3Cg fill='%23e54213'%3E%3Crect x='6' y='1' width='6' height='1'/%3E%3Crect x='6' y='2' width='8' height='1'/%3E%3Crect x='6' y='3' width='9' height='1'/%3E%3Crect x='6' y='4' width='8' height='1'/%3E%3Crect x='6' y='5' width='6' height='1'/%3E%3C/g%3E%3Crect x='6' y='6' width='4' height='1' fill='%239b1a0d'/%3E%3Crect x='2' y='13' width='6' height='1' fill='%23bcbcbc'/%3E%3Crect x='1' y='14' width='8' height='1' fill='%237c7c7c'/%3E%3C/svg%3E") center / 80% no-repeat; box-shadow: inset -2px -2px 0 var(--blue-dark), inset 2px 2px 0 var(--blue-light); }
.ex[data-tag]::after { content: attr(data-tag); position: absolute; left: -4px; top: -6px; width: 11px; height: 11px; display: grid; place-items: center; font-family: var(--font-title); font-weight: 700; font-size: 9px; line-height: 1; color: var(--black); background: var(--orange); box-shadow: 0 0 0 1px var(--black); }
.guide-body .reduce { margin: 6px 0 10px; color: var(--yellow); }
.ex.src { outline: 2px solid var(--orange); outline-offset: -2px; }
.ex.n1 { color: #4ab7ee; } .ex.n2 { color: #61ce5e; } .ex.n3 { color: var(--red); }
.ex.n4 { color: var(--orange); } .ex.n5 { color: var(--pink); } .ex.n6 { color: #11d7c9; } .ex.n7 { color: var(--white); } .ex.n8 { color: #bcbcbc; }
.ex.dim { opacity: 0.4; } /* 설명과 상관없는 주변 숫자 */
.mine-left { display: inline-block; margin-bottom: 4px; padding: 2px 8px; color: var(--orange); border: 2px solid var(--orange); font-size: 13px; }

/* ---------- 시작 화면 ---------- */
.start-screen { display: flex; flex-direction: column; align-items: center; gap: 48px; padding: 24px 0 40px; text-align: center; }
.start-screen[hidden], .game-screen[hidden] { display: none; }
.game-screen { width: 100%; }
.start-title {
  margin: 0;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: clamp(48px, 11vw, 120px);
  letter-spacing: 0.04em;
  line-height: 1;
  color: var(--orange);
  text-shadow: 0.06em 0.06em 0 var(--orange-dark), 0.12em 0.12em 0 var(--black);
}
.start-menu { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.start-menu[hidden] { display: none; }
.start-label { margin: 0 0 6px; color: var(--yellow); }
.start-main, .start-sub {
  width: min(260px, 80vw);
  padding: 12px 16px;
  border: 3px solid var(--white);
  color: var(--white);
  background: var(--black);
  font-size: 20px;
  cursor: pointer;
}
.start-sub { width: min(180px, 60vw); padding: 8px 12px; font-size: 16px; border-color: var(--orange); color: var(--orange); }
.start-main:hover, .start-main:focus-visible { color: var(--black); border-color: var(--orange); background: var(--orange); }
.start-main:hover::before, .start-main:focus-visible::before { content: "▶ "; }
.start-sub:hover { color: var(--black); background: var(--orange); }
#start-button { font-size: 24px; padding: 14px 16px; }

/* ---------- 게임 화면 오른쪽 위: 랭킹 · 설정 ---------- */
#help-button, #settings-button { padding: 6px 12px; border: 3px solid var(--white); color: var(--white); background: var(--black); cursor: pointer; }
#help-button:hover, #settings-button:hover { color: var(--orange); border-color: var(--orange); }

/* ---------- 설정 창 ---------- */
.settings-popup { width: min(440px, calc(100vw - 32px)); }
.settings-label { margin: 20px 0 10px; font-size: 16px; font-weight: 400; color: var(--orange); }
.settings-popup .difficulty-buttons { gap: 8px; }
.settings-home { margin-top: 26px; width: 100%; padding: 10px 12px; border: 3px solid var(--white); color: var(--white); background: var(--black); cursor: pointer; }
.settings-home:hover { color: var(--orange); border-color: var(--orange); }
.settings-confirm { margin-top: 18px; }
.settings-confirm[hidden], #settings-main[hidden] { display: none; }
.settings-confirm p { margin: 0 0 8px; line-height: 1.6; }
#confirm-cancel { padding: 9px 16px; border: 3px solid var(--white); color: var(--white); background: var(--black); cursor: pointer; }
#confirm-cancel:hover { color: var(--orange); border-color: var(--orange); }
#confirm-ok { padding: 9px 16px; border: 3px solid var(--red); color: var(--white); background: var(--red); cursor: pointer; }
#confirm-ok:hover { color: var(--red); background: var(--black); }

/* 해설 첫 화면: 문장 속 느낌표 버튼 아이콘과 안내 목록 */
.inline-assist { display: inline-grid; place-items: center; width: 22px; height: 22px; vertical-align: -5px; border: 2px solid var(--orange); color: var(--orange); background: var(--black); }
.inline-assist svg { width: 8px; height: 16px; fill: currentColor; }
.inline-assist .pixel-shadow { fill: var(--orange-dark); }
.guide-body .idle-list { margin: 8px 0 0; padding-left: 1.1em; color: #c8c8c4; }
.guide-body .idle-list li + li { margin-top: 10px; }
.guide-body .idle-list b { color: var(--yellow); }
.guide-body .penalty-word { color: var(--red); }

/* 비상 발동 중: 게임판 전체가 살짝 붉어지고 테두리가 빨갛게 빛남(칸 열기가 끝나면 원래대로) */
.board { position: relative; }
.board::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  background: rgba(229, 66, 19, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s steps(3);
}
.board-wrap.emergency-red .board::after { opacity: 1; }
.board-wrap.emergency-red .board { box-shadow: 0 0 0 3px var(--red), 0 0 18px rgba(229, 66, 19, 0.45); }
.guide-body .nowrap { white-space: nowrap; }
.game-title { text-align: center; }

/* ---------- 도움말 창 ---------- */
.help-popup { width: min(560px, calc(100vw - 32px)); line-height: 1.6; }
.help-section { margin: 20px 0 8px; font-size: 17px; font-weight: 400; color: var(--orange); }
.help-list { margin: 0; padding-left: 0; list-style: none; }
.help-list li { display: grid; grid-template-columns: 96px 1fr; gap: 8px; margin: 6px 0; color: #d8d8d4; }
.help-list b { color: var(--yellow); font-weight: 400; }
.help-feature { margin: 12px 0 16px; padding: 12px 14px; background: #15161a; border-left: 4px solid var(--orange); }
.help-feature p { margin: 0 0 10px; color: #d8d8d4; }
.help-feature b { color: var(--yellow); font-weight: 400; }
.help-example { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.help-example figure { margin: 0; }
.help-example figcaption { margin-top: 4px; font-size: 12px; color: var(--gray); text-align: center; }
.help-arrow { font-family: var(--font-title); font-size: 22px; color: var(--orange); }
.help-caption { flex-basis: 100%; margin: 4px 0 0 !important; font-size: 13px; color: #a9a9a4 !important; }

/* ---------- 위쪽 버튼 정렬: 메뉴 버튼은 같은 높이, 새 게임은 숫자판과 같은 높이, 오른쪽 끝을 한 줄로 ---------- */
#ranking-button, #help-button, #settings-button { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; }
.lcd { height: 50px; }
#reset-button { display: inline-flex; align-items: center; height: 50px; padding: 0 22px; }
.top-controls { gap: 8px; }

/* ---------- 게임 카드 맨 윗줄 하나로: [새 게임] · [숫자판] · [랭킹·도움말·설정] ---------- */
.game-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr; /* 양쪽 열 너비가 같아서 숫자판은 카드 정가운데 */
  align-items: center;
  column-gap: 16px;
  margin: 0 0 20px;
}
.game-header > .game-actions { justify-self: start; }
.game-header > .status-bar { display: flex; gap: 14px; margin: 0; }
.game-header > .top-controls { justify-self: end; margin: 0; flex-wrap: nowrap; }
/* 좁은 화면: 메뉴 → 숫자판 → 새 게임 순서로 세로로 쌓기 */
@media (max-width: 860px) {
  .game-header { display: flex; flex-direction: column; align-items: center; gap: 12px; }
  .game-header > .top-controls { order: 1; justify-self: auto; }
  .game-header > .status-bar { order: 2; }
  .game-header > .game-actions { order: 3; }
}
.game-header #ranking-button, .game-header #help-button, .game-header #settings-button { white-space: nowrap; padding: 0 10px; }
.game-header > .top-controls { gap: 6px; }
.game-header #reset-button { white-space: nowrap; }

/* ---------- 새 게임: 회색 입체 블록 위 노란 도트 스마일 버튼(숫자판 바깥 테두리까지와 같은 56×56) ---------- */
.game-actions #reset-button {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  background: #2a2c33;
  clip-path: var(--cut-corners);
  box-shadow: inset -3px -3px 0 #15161a, inset 3px 3px 0 #4a4d57;
}
.game-actions #reset-button:hover { background: #33363e; }
.game-actions #reset-button:active { box-shadow: inset 3px 3px 0 #15161a, inset -3px -3px 0 #4a4d57; }
.game-actions #reset-button:active svg { transform: translate(1px, 1px); }

/* 맨 윗줄 배치 변경: 숫자판 왼쪽 · 스마일 가운데 · 메뉴 오른쪽 */
.game-header > .status-bar { justify-self: start; }
.game-header > .game-actions { justify-self: center; }

/* 해설 예시: 두 숫자가 함께 보는 칸(보라색) */
.ex.h.share { background: #8a63d2; box-shadow: inset -2px -2px 0 #5b3f97, inset 2px 2px 0 #b79af0; }
.ex.share:not(.h) { outline: 2px solid #b79af0; outline-offset: -2px; }
.guide-body .share-word { color: #b79af0; }
/* 잘못 꽂은 깃발: 깃발 위에 검은 윤곽선을 두른 도트 계단 X(16칸) */
.ex.X { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' shape-rendering='crispEdges'%3E%3Crect x='0' y='1' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='0' y='14' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='1' y='0' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='1' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='1' y='13' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='1' y='15' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='1' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='12' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='14' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='11' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='13' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='10' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='12' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='9' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='11' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='7' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='8' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='10' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='7' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='7' y='9' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='8' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='8' y='9' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='9' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='9' y='7' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='9' y='8' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='9' y='10' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='10' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='10' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='10' y='9' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='10' y='11' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='11' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='11' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='11' y='10' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='11' y='12' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='12' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='12' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='12' y='11' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='12' y='13' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='13' y='1' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='13' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='13' y='12' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='13' y='14' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='14' y='0' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='14' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='14' y='13' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='14' y='15' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='15' y='1' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='15' y='14' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='1' y='1' width='1' height='1' fill='%23e54213'/%3E%3Crect x='1' y='14' width='1' height='1' fill='%23e54213'/%3E%3Crect x='2' y='2' width='1' height='1' fill='%23e54213'/%3E%3Crect x='2' y='13' width='1' height='1' fill='%23e54213'/%3E%3Crect x='3' y='3' width='1' height='1' fill='%23e54213'/%3E%3Crect x='3' y='12' width='1' height='1' fill='%23e54213'/%3E%3Crect x='4' y='4' width='1' height='1' fill='%23e54213'/%3E%3Crect x='4' y='11' width='1' height='1' fill='%23e54213'/%3E%3Crect x='5' y='5' width='1' height='1' fill='%23e54213'/%3E%3Crect x='5' y='10' width='1' height='1' fill='%23e54213'/%3E%3Crect x='6' y='6' width='1' height='1' fill='%23e54213'/%3E%3Crect x='6' y='9' width='1' height='1' fill='%23e54213'/%3E%3Crect x='7' y='7' width='1' height='1' fill='%23e54213'/%3E%3Crect x='7' y='8' width='1' height='1' fill='%23e54213'/%3E%3Crect x='8' y='7' width='1' height='1' fill='%23e54213'/%3E%3Crect x='8' y='8' width='1' height='1' fill='%23e54213'/%3E%3Crect x='9' y='6' width='1' height='1' fill='%23e54213'/%3E%3Crect x='9' y='9' width='1' height='1' fill='%23e54213'/%3E%3Crect x='10' y='5' width='1' height='1' fill='%23e54213'/%3E%3Crect x='10' y='10' width='1' height='1' fill='%23e54213'/%3E%3Crect x='11' y='4' width='1' height='1' fill='%23e54213'/%3E%3Crect x='11' y='11' width='1' height='1' fill='%23e54213'/%3E%3Crect x='12' y='3' width='1' height='1' fill='%23e54213'/%3E%3Crect x='12' y='12' width='1' height='1' fill='%23e54213'/%3E%3Crect x='13' y='2' width='1' height='1' fill='%23e54213'/%3E%3Crect x='13' y='13' width='1' height='1' fill='%23e54213'/%3E%3Crect x='14' y='1' width='1' height='1' fill='%23e54213'/%3E%3Crect x='14' y='14' width='1' height='1' fill='%23e54213'/%3E%3C/svg%3E") center / 84% no-repeat, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' shape-rendering='crispEdges'%3E%3Crect x='4' y='1' width='2' height='12' fill='%23f6f6f2'/%3E%3Cg fill='%23e54213'%3E%3Crect x='6' y='1' width='6' height='1'/%3E%3Crect x='6' y='2' width='8' height='1'/%3E%3Crect x='6' y='3' width='9' height='1'/%3E%3Crect x='6' y='4' width='8' height='1'/%3E%3Crect x='6' y='5' width='6' height='1'/%3E%3C/g%3E%3Crect x='6' y='6' width='4' height='1' fill='%239b1a0d'/%3E%3Crect x='2' y='13' width='6' height='1' fill='%23bcbcbc'/%3E%3Crect x='1' y='14' width='8' height='1' fill='%237c7c7c'/%3E%3C/svg%3E") center / 80% no-repeat, var(--blue); box-shadow: inset -2px -2px 0 var(--blue-dark), inset 2px 2px 0 var(--blue-light); }
.inline-wf { display: inline-block; width: 18px; height: 18px; vertical-align: -4px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' shape-rendering='crispEdges'%3E%3Crect x='0' y='1' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='0' y='14' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='1' y='0' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='1' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='1' y='13' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='1' y='15' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='1' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='12' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='14' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='11' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='13' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='10' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='12' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='9' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='11' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='7' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='8' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='10' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='7' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='7' y='9' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='8' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='8' y='9' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='9' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='9' y='7' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='9' y='8' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='9' y='10' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='10' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='10' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='10' y='9' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='10' y='11' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='11' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='11' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='11' y='10' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='11' y='12' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='12' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='12' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='12' y='11' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='12' y='13' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='13' y='1' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='13' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='13' y='12' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='13' y='14' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='14' y='0' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='14' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='14' y='13' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='14' y='15' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='15' y='1' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='15' y='14' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='1' y='1' width='1' height='1' fill='%23e54213'/%3E%3Crect x='1' y='14' width='1' height='1' fill='%23e54213'/%3E%3Crect x='2' y='2' width='1' height='1' fill='%23e54213'/%3E%3Crect x='2' y='13' width='1' height='1' fill='%23e54213'/%3E%3Crect x='3' y='3' width='1' height='1' fill='%23e54213'/%3E%3Crect x='3' y='12' width='1' height='1' fill='%23e54213'/%3E%3Crect x='4' y='4' width='1' height='1' fill='%23e54213'/%3E%3Crect x='4' y='11' width='1' height='1' fill='%23e54213'/%3E%3Crect x='5' y='5' width='1' height='1' fill='%23e54213'/%3E%3Crect x='5' y='10' width='1' height='1' fill='%23e54213'/%3E%3Crect x='6' y='6' width='1' height='1' fill='%23e54213'/%3E%3Crect x='6' y='9' width='1' height='1' fill='%23e54213'/%3E%3Crect x='7' y='7' width='1' height='1' fill='%23e54213'/%3E%3Crect x='7' y='8' width='1' height='1' fill='%23e54213'/%3E%3Crect x='8' y='7' width='1' height='1' fill='%23e54213'/%3E%3Crect x='8' y='8' width='1' height='1' fill='%23e54213'/%3E%3Crect x='9' y='6' width='1' height='1' fill='%23e54213'/%3E%3Crect x='9' y='9' width='1' height='1' fill='%23e54213'/%3E%3Crect x='10' y='5' width='1' height='1' fill='%23e54213'/%3E%3Crect x='10' y='10' width='1' height='1' fill='%23e54213'/%3E%3Crect x='11' y='4' width='1' height='1' fill='%23e54213'/%3E%3Crect x='11' y='11' width='1' height='1' fill='%23e54213'/%3E%3Crect x='12' y='3' width='1' height='1' fill='%23e54213'/%3E%3Crect x='12' y='12' width='1' height='1' fill='%23e54213'/%3E%3Crect x='13' y='2' width='1' height='1' fill='%23e54213'/%3E%3Crect x='13' y='13' width='1' height='1' fill='%23e54213'/%3E%3Crect x='14' y='1' width='1' height='1' fill='%23e54213'/%3E%3Crect x='14' y='14' width='1' height='1' fill='%23e54213'/%3E%3C/svg%3E") center / 84% no-repeat, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' shape-rendering='crispEdges'%3E%3Crect x='4' y='1' width='2' height='12' fill='%23f6f6f2'/%3E%3Cg fill='%23e54213'%3E%3Crect x='6' y='1' width='6' height='1'/%3E%3Crect x='6' y='2' width='8' height='1'/%3E%3Crect x='6' y='3' width='9' height='1'/%3E%3Crect x='6' y='4' width='8' height='1'/%3E%3Crect x='6' y='5' width='6' height='1'/%3E%3C/g%3E%3Crect x='6' y='6' width='4' height='1' fill='%239b1a0d'/%3E%3Crect x='2' y='13' width='6' height='1' fill='%23bcbcbc'/%3E%3Crect x='1' y='14' width='8' height='1' fill='%237c7c7c'/%3E%3C/svg%3E") center / 80% no-repeat, var(--blue); box-shadow: inset -2px -2px 0 var(--blue-dark), inset 2px 2px 0 var(--blue-light); }

/* 게임 오버: 지뢰가 없는 칸에 꽂은 깃발은 게임판에서도 X깃발로 표시(해설의 X깃발과 같은 그림) */
.cell.flagged.wrong-flag {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' shape-rendering='crispEdges'%3E%3Crect x='0' y='1' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='0' y='14' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='1' y='0' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='1' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='1' y='13' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='1' y='15' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='1' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='12' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='2' y='14' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='11' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='3' y='13' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='10' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='4' y='12' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='9' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='5' y='11' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='7' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='8' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='6' y='10' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='7' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='7' y='9' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='8' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='8' y='9' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='9' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='9' y='7' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='9' y='8' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='9' y='10' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='10' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='10' y='6' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='10' y='9' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='10' y='11' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='11' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='11' y='5' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='11' y='10' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='11' y='12' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='12' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='12' y='4' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='12' y='11' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='12' y='13' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='13' y='1' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='13' y='3' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='13' y='12' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='13' y='14' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='14' y='0' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='14' y='2' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='14' y='13' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='14' y='15' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='15' y='1' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='15' y='14' width='1' height='1' fill='%230c0d10'/%3E%3Crect x='1' y='1' width='1' height='1' fill='%23e54213'/%3E%3Crect x='1' y='14' width='1' height='1' fill='%23e54213'/%3E%3Crect x='2' y='2' width='1' height='1' fill='%23e54213'/%3E%3Crect x='2' y='13' width='1' height='1' fill='%23e54213'/%3E%3Crect x='3' y='3' width='1' height='1' fill='%23e54213'/%3E%3Crect x='3' y='12' width='1' height='1' fill='%23e54213'/%3E%3Crect x='4' y='4' width='1' height='1' fill='%23e54213'/%3E%3Crect x='4' y='11' width='1' height='1' fill='%23e54213'/%3E%3Crect x='5' y='5' width='1' height='1' fill='%23e54213'/%3E%3Crect x='5' y='10' width='1' height='1' fill='%23e54213'/%3E%3Crect x='6' y='6' width='1' height='1' fill='%23e54213'/%3E%3Crect x='6' y='9' width='1' height='1' fill='%23e54213'/%3E%3Crect x='7' y='7' width='1' height='1' fill='%23e54213'/%3E%3Crect x='7' y='8' width='1' height='1' fill='%23e54213'/%3E%3Crect x='8' y='7' width='1' height='1' fill='%23e54213'/%3E%3Crect x='8' y='8' width='1' height='1' fill='%23e54213'/%3E%3Crect x='9' y='6' width='1' height='1' fill='%23e54213'/%3E%3Crect x='9' y='9' width='1' height='1' fill='%23e54213'/%3E%3Crect x='10' y='5' width='1' height='1' fill='%23e54213'/%3E%3Crect x='10' y='10' width='1' height='1' fill='%23e54213'/%3E%3Crect x='11' y='4' width='1' height='1' fill='%23e54213'/%3E%3Crect x='11' y='11' width='1' height='1' fill='%23e54213'/%3E%3Crect x='12' y='3' width='1' height='1' fill='%23e54213'/%3E%3Crect x='12' y='12' width='1' height='1' fill='%23e54213'/%3E%3Crect x='13' y='2' width='1' height='1' fill='%23e54213'/%3E%3Crect x='13' y='13' width='1' height='1' fill='%23e54213'/%3E%3Crect x='14' y='1' width='1' height='1' fill='%23e54213'/%3E%3Crect x='14' y='14' width='1' height='1' fill='%23e54213'/%3E%3C/svg%3E"), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' shape-rendering='crispEdges'%3E%3Crect x='4' y='1' width='2' height='12' fill='%23f6f6f2'/%3E%3Cg fill='%23e54213'%3E%3Crect x='6' y='1' width='6' height='1'/%3E%3Crect x='6' y='2' width='8' height='1'/%3E%3Crect x='6' y='3' width='9' height='1'/%3E%3Crect x='6' y='4' width='8' height='1'/%3E%3Crect x='6' y='5' width='6' height='1'/%3E%3C/g%3E%3Crect x='6' y='6' width='4' height='1' fill='%239b1a0d'/%3E%3Crect x='2' y='13' width='6' height='1' fill='%23bcbcbc'/%3E%3Crect x='1' y='14' width='8' height='1' fill='%237c7c7c'/%3E%3C/svg%3E");
  background-size: 27px 27px, 24px 24px;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
  image-rendering: pixelated;
}

/* ---------- 배치 변경: 남은 지뢰(왼쪽) · 스마일(가운데) · 시간(오른쪽), 메뉴는 화면 오른쪽 위 구석 ---------- */
.game-header { display: grid !important; grid-template-columns: 1fr auto 1fr; flex-direction: row; }
.game-header > .status-bar { justify-self: start; order: 0; }
.game-header > .game-actions { justify-self: center; order: 0; }
.game-header > #timer-box { justify-self: end; }
.corner-menu { position: fixed; top: 16px; right: 16px; z-index: 9; /* 팝업 창(10~11)보다 아래 */ display: flex; gap: 6px; margin: 0; flex-wrap: nowrap; }
.corner-menu > #ranking-button, .corner-menu > #profile-button, .corner-menu > #help-button, .corner-menu > #settings-button, .corner-menu > #exit-button {
  display: grid; place-items: center;
  width: 56px; height: 56px; padding: 0;
  border: 0; outline: 0; color: transparent;
  background: #2a2c33;
  clip-path: var(--cut-corners);
  box-shadow: inset -3px -3px 0 #15161a, inset 3px 3px 0 #4a4d57;
  cursor: pointer;
}
.corner-menu > #ranking-button:hover, .corner-menu > #profile-button:hover, .corner-menu > #help-button:hover, .corner-menu > #settings-button:hover, .corner-menu > #exit-button:hover { background: #33363e; color: transparent; }
.corner-menu > #ranking-button:active, .corner-menu > #profile-button:active, .corner-menu > #help-button:active, .corner-menu > #settings-button:active, .corner-menu > #exit-button:active { box-shadow: inset 3px 3px 0 #15161a, inset -3px -3px 0 #4a4d57; }
.corner-menu > #ranking-button:active svg, .corner-menu > #profile-button:active svg, .corner-menu > #help-button:active svg, .corner-menu > #settings-button:active svg, .corner-menu > #exit-button:active svg { transform: translate(1px, 1px); }
.corner-menu > #ranking-button:focus-visible, .corner-menu > #help-button:focus-visible, .corner-menu > #settings-button:focus-visible, .corner-menu > #exit-button:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

/* =====================================================================
   튜토리얼
   ===================================================================== */
/* 시작 화면: 난이도 맨 위 초록 버튼(T-a) */
.start-main.tut-start { border-color: var(--green-light); color: var(--black); background: var(--green); box-shadow: inset -3px -3px 0 var(--green-dark), inset 3px 3px 0 var(--green-light); }
.start-main.tut-start:hover, .start-main.tut-start:focus-visible { border-color: var(--green-light); background: var(--green-light); }
.tut-note { margin: -8px 0 6px; color: var(--green-light); font-size: 13px; }
/* 단계 목록(L-3) */
.tutorial-list { width: min(420px, calc(100vw - 48px)); padding: 20px; background: var(--black); border: var(--pixel) solid var(--white); box-shadow: 0 0 0 var(--pixel) var(--black), 0 0 0 calc(var(--pixel) * 2) var(--white); gap: 10px; }
.tutorial-list[hidden] { display: none; }
.tutorial-list-title { margin: 0; font-family: var(--font-title); font-size: 28px; color: var(--orange); }
.tutorial-progress { margin: 0; color: var(--yellow); font-size: 14px; }
.ls-wrap { width: 100%; max-height: min(56vh, 520px); overflow: auto; padding-right: 4px; text-align: left; }
.ls-gname { margin: 10px 0 4px; color: var(--orange); font-size: 14px; }
.ls-row { display: grid; grid-template-columns: 36px 1fr auto 24px; align-items: center; gap: 8px; width: 100%; margin: 0 0 4px; padding: 7px 10px; border: 3px solid #34363c; background: var(--black); color: var(--white); text-align: left; cursor: pointer; }
.ls-no { font-family: var(--font-number); font-weight: 800; color: var(--blue-light); }
.ls-state { font-size: 12px; color: var(--green-light); }
.ls-row i { line-height: 0; display: grid; place-items: center; }
.ls-row.cur { border-color: var(--orange); background: #2a1c10; }
.ls-row.cur .ls-state { color: var(--orange); }
.ls-arrow { color: var(--orange); font-size: 14px; line-height: 1; }
.ls-row.lock { color: #55585f; cursor: not-allowed; }
.ls-row.lock .ls-no { color: #55585f; }
.ls-row:not(.lock):hover, .ls-row:not(.lock):focus-visible { border-color: var(--orange); }
/* 게임 카드: 단계 표시 줄 */
.tutorial-bar { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 0 0 10px; }
.tutorial-bar[hidden] { display: none; }
.tut-badge { padding: 2px 10px; background: var(--green); color: var(--black); font-family: var(--font-title); font-weight: 700; }
.tut-sub { color: #c8c8c4; }
/* 1~13단계: 해설 창 숨김, 느낌표·되돌리기 막힘 */
.assist-button:disabled { opacity: 0.3; cursor: not-allowed; }
.assist-button:disabled:hover { color: var(--orange); background: var(--black); }
.assist-button:disabled:hover .pixel-shadow { fill: var(--orange-dark); opacity: 1; }
/* 판 강조: 주황(볼 숫자) · 노랑(주변 칸) · 보라(함께 보는 칸) · 초록(안전) · 분홍(지뢰) */
.board-wrap { position: relative; }
.cell.tut-focus { outline: 3px solid var(--orange); outline-offset: -3px; position: relative; z-index: 2; }
.cell.tut-area { outline: 2px solid var(--yellow); outline-offset: -2px; }
.cell.tut-area.open { background: #2c2d22; }
.cell.tut-share { outline: 3px solid #b79af0; outline-offset: -3px; }
.cell.tut-share:not(.open):not(.flagged) { background-color: #8a63d2; box-shadow: inset -2px -2px 0 #5b3f97, inset 2px 2px 0 #b79af0; }
.cell.tut-safe:not(.open) { background-color: var(--green); box-shadow: inset -1px -1px 0 var(--green-edge-dark), inset 1px 1px 0 var(--green-edge-light), inset -3px -3px 0 var(--green-dark), inset 3px 3px 0 var(--green-light); }
.cell.tut-mine:not(.open):not(.flagged) { background-color: var(--pink); box-shadow: inset -1px -1px 0 var(--pink-edge-dark), inset 1px 1px 0 var(--pink-edge-light), inset -3px -3px 0 var(--pink-dark), inset 3px 3px 0 var(--pink-light); }
.cell.tut-mine.flagged { outline: 3px solid var(--pink); outline-offset: -3px; }
.cell.tut-target { animation: tut-blink 0.7s steps(1) infinite; }
@keyframes tut-blink { 50% { outline: 3px solid var(--yellow); outline-offset: -3px; filter: brightness(1.35); } }
.cell.tut-dim { filter: brightness(0.35); }
.tut-pulse { animation: tut-pulse 0.7s steps(1) infinite; }
@keyframes tut-pulse { 50% { box-shadow: 0 0 0 4px var(--yellow); } }
/* 말풍선(B-2) */
.tut-bubble { position: absolute; z-index: 6; width: 208px; padding: 10px 12px; background: var(--white); color: var(--black); text-align: left; font-size: 14px; line-height: 1.6; box-shadow: 0 0 0 3px var(--black), 4px 4px 0 3px #000; }
.tut-bubble[hidden] { display: none; }
.tut-bubble p { margin: 0; }
.tut-bubble b { color: #b4500e; font-weight: 400; }
.tut-bubble .do { display: inline-block; margin-top: 4px; color: #0d7a0d; font-family: var(--font-title); font-weight: 700; }
.tut-bubble::after { content: ""; position: absolute; background: var(--white); }
.tut-bubble.side::after { left: -12px; top: var(--tail, 50%); width: 12px; height: 14px; margin-top: -7px; clip-path: polygon(100% 0, 100% 100%, 0 50%); }
.tut-bubble.below::after { top: -12px; left: var(--tail, 50%); width: 14px; height: 12px; margin-left: -7px; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.tut-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 8px; }
.tut-count { margin-right: auto; color: #7c7c7c; font-size: 12px; }
.tut-next { padding: 4px 10px; border: 3px solid var(--orange); color: var(--black); background: var(--orange); cursor: pointer; font-size: 14px; }
.tut-next:hover { background: var(--yellow); border-color: var(--yellow); }
.tut-ghost { padding: 4px 10px; border: 3px solid #7c7c7c; color: #3a3a3a; background: var(--white); cursor: pointer; font-size: 14px; }
.tut-ghost:hover { border-color: var(--orange); color: #b4500e; }
.tut-bubble.nudge { animation: tut-nudge 0.3s steps(4) 1; }
@keyframes tut-nudge { 25% { translate: -4px 0; } 75% { translate: 4px 0; } }
/* 설정 창 튜토리얼 버튼 · 축하 창 버튼 두 개 */
.settings-home.tut-set { border-color: var(--green-light); color: var(--green-light); }
.settings-home.tut-set:hover { color: var(--black); background: var(--green-light); }
.congrats-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
#celebration-list { padding: 9px 16px; border: 3px solid var(--white); color: var(--white); background: var(--black); cursor: pointer; }
#celebration-list:hover { color: var(--orange); border-color: var(--orange); }
#celebration-list[hidden] { display: none; }
/* 남은 지뢰 수 계산 힌트: 지뢰가 들어갈 수 있는 칸(노랑) */
.cell.hint-candidate:not(.hint-safe):not(.hint-mine):not(.open) { background-color: var(--yellow); box-shadow: inset -1px -1px 0 #6e5a1c, inset 1px 1px 0 #fff6cf, inset -3px -3px 0 #b8973f, inset 3px 3px 0 #fbeab4; }
.cell.hint-candidate.flagged:not(.hint-mine) { outline: 3px solid var(--yellow); outline-offset: -3px; }
.guide-body .candidate-word { color: var(--yellow); }

/* ---------- 도트 숫자판(D-3) · 도트 느낌표(E-1) ---------- */
.lcd b { display: flex; align-items: center; }
.lcd-digits { display: block; filter: drop-shadow(0 0 3px rgba(210, 108, 75, 0.4)); }
.lcd-digits .lcd-on { fill: #d26c4b; } /* 원래 주황에서 채도를 조금 낮춘 색 */
.lcd-digits .lcd-shadow { fill: #5e2a18; }
.ex-l { fill: #ffc28f; }
.ex-o { fill: #f08a4b; }
.ex-d { fill: #a8481f; }
.assist-button:hover { background: #3a2414; }
.assist-button:active svg { transform: translate(2px, 2px); }
.inline-assist svg { width: 11px; height: 17px; }

/* ---------- 프로필 · 로그인 ---------- */
.corner-menu > #profile-button { position: relative; }
#profile-button.logged-in::after { content: ""; position: absolute; right: 4px; bottom: 4px; width: 8px; height: 8px; background: var(--green-light); box-shadow: 0 0 0 2px var(--black); } /* 로그인 표시 */
.profile-popup { width: min(100%, 520px); }
.profile-body { margin-top: 14px; }
.profile-lead { margin: 0 0 14px; line-height: 1.7; }
.profile-lead b { color: var(--orange); font-weight: 400; }
.profile-notice { margin: 0 0 12px; padding: 8px 10px; color: var(--black); background: var(--yellow); line-height: 1.5; }
.profile-hint { margin: 12px 0 0; color: #8c8c88; font-size: 13px; line-height: 1.6; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.profile-main, .profile-sub { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border: 3px solid var(--orange); font-family: var(--font-title); font-size: 16px; cursor: pointer; }
.profile-main { color: var(--black); background: var(--orange); }
.profile-main:hover { background: var(--yellow); border-color: var(--yellow); }
.profile-sub { color: var(--white); background: var(--black); border-color: var(--white); }
.profile-sub:hover { color: var(--orange); border-color: var(--orange); }
.profile-bullets { margin: 0 0 12px; padding-left: 18px; line-height: 1.7; }
.profile-danger:hover { color: var(--red); border-color: var(--red); }
.profile-main.profile-danger-main { background: var(--red); border-color: var(--red); color: var(--white); }
.profile-main.profile-danger-main:hover { background: var(--black); color: var(--red); border-color: var(--red); }
.pf-policy { margin-top: 18px; }
.start-policy a { color: #5e5e5a; text-decoration: underline; text-decoration-color: #3f3f3c; }
.pf-policy, .pf-policy a { color: #5e5e5a; text-decoration: underline; text-decoration-color: #3f3f3c; }
.pf-policy { text-decoration: none; }
.pf-policy a:hover { color: var(--orange); }
.start-policy a:hover { color: var(--orange); }
/* 저작권 표기: 시작·게임 화면 왼쪽 아래(희미하게) */
.site-copy { position: fixed; left: 10px; bottom: 6px; margin: 0; padding: 2px 4px; font-size: 12px; color: #5e5e5a; pointer-events: none; z-index: 2; user-select: none; }
.start-policy { position: fixed; right: 10px; bottom: 6px; margin: 0; text-align: right; font-size: 12px; pointer-events: none; z-index: 2; }
.start-policy a { pointer-events: auto; padding: 2px 4px; }
.g-icon { display: block; flex: none; image-rendering: auto; }
/* 구글로 로그인: 어두운 버튼 + 투명 배경의 4색 G, 커서를 올리면 주황 */
.profile-main.profile-google { gap: 12px; color: var(--white); background: var(--black); border-color: var(--white); }
.profile-main.profile-google:hover { color: var(--orange); background: var(--black); border-color: var(--orange); }
.profile-main.profile-google:active { transform: translate(2px, 2px); }
.profile-form input { width: 100%; padding: 9px 10px; border: 3px solid var(--white); color: var(--white); background: #15161a; font-family: var(--font-body); font-size: 16px; }
.profile-form input:focus { outline: none; border-color: var(--orange); }
.profile-error { min-height: 1.4em; margin: 6px 0 0; color: var(--pink); font-size: 13px; }
.profile-card { display: flex; align-items: center; gap: 16px; }
.profile-photo { width: 64px; height: 64px; flex: 0 0 auto; object-fit: cover; image-rendering: pixelated; box-shadow: 0 0 0 3px var(--white), 0 0 0 6px var(--black); }
.profile-photo.empty { display: grid; place-items: center; background: #25262b; }
.profile-who p { margin: 0; line-height: 1.6; }
.profile-nick { font-family: var(--font-title); font-size: 22px; color: var(--orange); }
.profile-edit { margin-left: 6px; padding: 2px 6px; border: 2px solid #6c6f78; color: #c8c8c4; background: transparent; font-family: var(--font-body); font-size: 12px; cursor: pointer; vertical-align: 3px; }
.profile-edit:hover { color: var(--orange); border-color: var(--orange); }
.profile-name { color: var(--white); }
.profile-mail { color: #8c8c88; font-size: 13px; }
.profile-h { margin: 20px 0 8px; font-family: var(--font-title); font-size: 18px; color: var(--orange); }
.profile-stats th[scope="row"] { color: var(--white); text-align: left; }

/* 클리어 결과: 시간(0.01초)·3BV·3BV/s·효율 */
.congrats-stats {
  margin: 14px 0 4px;
  padding: 10px 12px;
  border: 3px solid var(--white);
  text-align: left;
}
.congrats-stats > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
}
.congrats-stats dt { color: var(--white); white-space: nowrap; }
.congrats-stats dd { margin: 0; color: var(--yellow); text-align: right; }
.congrats-note { margin: 6px 0 0; font-size: 12px; line-height: 1.5; color: var(--white); }
.congrats-note[hidden], .congrats-stats[hidden] { display: none; }

/* 프로필(시안 C): 회색 사람 아이콘, 연필 버튼, 난이도별 색 막대 목록 */
.profile-photo.empty { filter: grayscale(1); }
.profile-photo.empty svg { width: 48px; height: 48px; }
.profile-edit { display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; vertical-align: middle; }
.pf-head, .pf-list li { display: grid; grid-template-columns: 1fr 78px 150px; align-items: center; gap: 8px; }
.pf-head { padding: 0 10px 6px 18px; color: #8c8c88; font-size: 13px; border-bottom: 3px solid var(--white); }
.pf-head span:nth-child(n+2) { text-align: right; }
.pf-list { margin: 0; padding: 0; list-style: none; }
.pf-list li { padding: 9px 10px 9px 14px; border-left: 6px solid var(--c); border-bottom: 2px dashed #34363c; }
.pf-lb { color: var(--c); font-family: var(--font-title); }
.pf-cl { text-align: right; }
.pf-bt { text-align: right; color: var(--yellow); }
.pf-bt.none { color: #5a5c62; }

/* 프로필: 국기(사진 왼쪽 아래, 입체감 없이 평평한 이미지), 튜토리얼 졸업 배지, 국가 선택 */
.pf-avatar { position: relative; flex: 0 0 auto; }
.pf-flag { position: absolute; left: -6px; bottom: -5px; display: block; width: 28px; height: 21px; line-height: 0; }
.flag-img { display: block; width: 28px; height: 21px; object-fit: cover; }
.pf-badge { vertical-align: middle; margin-left: 2px; }
.profile-label { display: block; margin: 12px 0 4px; color: #8c8c88; font-size: 13px; }
.profile-country { display: flex; align-items: center; gap: 10px; }
.flag-preview { display: block; width: 28px; height: 21px; line-height: 0; flex: 0 0 auto; }
.flag-preview:empty { background: #25262b; }
.profile-country select { flex: 1; padding: 8px 10px; border: 3px solid var(--white); color: var(--white); background: var(--black); font-family: var(--font-body); font-size: 15px; }
.profile-country select:focus { outline: none; border-color: var(--orange); }

/* ---------- 글로벌 랭킹 ---------- */
.ranking-popup.global-popup { width: min(100%, 840px); }
.ranking-scope { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.ranking-scope button, .ranking-scope select, .rk-more {
  padding: 6px 12px; border: 3px solid var(--white); background: var(--black); color: var(--white); font: inherit; cursor: pointer;
}
.ranking-scope button:hover, .rk-more:hover { color: var(--black); background: var(--orange); }
.ranking-scope button.active { color: var(--black); background: var(--orange); border-color: var(--orange); }
.ranking-scope select[hidden] { display: none; }
.ranking-global .ranking-table th, .global-popup .ranking-table th { white-space: nowrap; }
.global-popup .ranking-table td { white-space: nowrap; }
.global-popup .ranking-table .rk-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.global-popup .ranking-table td:nth-child(4) { color: var(--yellow); }
.global-popup .ranking-table tbody tr:first-child td:nth-child(4) { color: var(--yellow); }
.rk-flag { display: inline-block; width: 24px; height: 18px; line-height: 0; vertical-align: middle; }
.rk-flag .flag-img { width: 24px; height: 18px; }
.ranking-table tr.rk-me td { background: #2a2118; color: var(--orange); }
.ranking-table tr.rk-gap td { text-align: center; color: var(--gray); border-bottom: 0; padding: 2px; }
.rk-more { display: block; margin: 12px auto 0; }
.rk-more[hidden] { display: none; }
.rk-mine { margin: 12px 0 0; padding: 10px 12px; border: 3px dashed #34363c; color: var(--orange); text-align: center; }
.rk-mine[hidden] { display: none; }
@media (max-width: 640px) {
  .global-popup .ranking-table { font-size: 13px; }
  .global-popup .ranking-table th, .global-popup .ranking-table td { padding: 8px 3px; }
  .global-popup .ranking-table .rk-name { max-width: 80px; }
}

/* 랭킹 창 크기 · 난이도 색 · 한 줄 배치 */
.ranking-popup.global-popup { width: min(100%, 1040px); max-height: min(90vh, 860px); padding: 26px; }
.global-popup .ranking-table-wrap { max-height: min(62vh, 620px); }
.global-popup .ranking-table { font-size: 18px; }
.global-popup .ranking-table th, .global-popup .ranking-table td { padding: 12px 10px; }
.global-popup .rk-flag { width: 30px; height: 22px; }
.global-popup .rk-flag .flag-img { width: 30px; height: 22px; }
.ranking-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-top: 18px; }
.ranking-bar .ranking-tabs, .ranking-bar .ranking-scope { margin-top: 0; }
.ranking-bar .ranking-scope { margin-left: auto; }
.ranking-tabs button[data-ranking-difficulty="easy"] { --dc: #8fd63a; }
.ranking-tabs button[data-ranking-difficulty="normal"] { --dc: #4ab7ee; }
.ranking-tabs button[data-ranking-difficulty="hard"] { --dc: #ed9847; }
.ranking-tabs button[data-ranking-difficulty="crazy"] { --dc: #ee82ee; }
.ranking-tabs button[data-ranking-difficulty="hell"] { --dc: #e54213; }
.ranking-tabs button[data-ranking-difficulty] { color: var(--dc); border-color: var(--dc); }
.ranking-tabs button[data-ranking-difficulty]:hover { color: var(--black); background: var(--dc); border-color: var(--dc); }
.ranking-tabs button[data-ranking-difficulty].active { color: var(--black); background: var(--dc); border-color: var(--dc); }
@media (max-width: 640px) {
  .ranking-bar .ranking-scope { margin-left: 0; }
}

/* 랭킹 표 가운데 맞춤 */
.global-popup .ranking-table th, .global-popup .ranking-table td { text-align: center; }
.global-popup .rk-flag { display: inline-block; }
.global-popup .ranking-table .rk-name { max-width: 220px; margin: 0 auto; }

/* 랭킹 창은 위쪽에 고정: 내용이 늘어나도 상단 위치는 그대로, 아래로만 늘어납니다 */
#ranking-overlay { align-items: start; padding-top: 18px; }
#ranking-overlay .global-popup { max-height: calc(100vh - 36px); }
.global-popup .ranking-table-wrap { max-height: calc(100vh - 340px); min-height: 120px; }

/* =====================================================================
   레트로 툴팁(CRT 호박색 모니터) — tooltip.js가 띄우는 도트 상자
   모서리를 계단식으로 깎고, 스캔라인 + 번지는 호박색 글씨 + 깜빡이는 커서
   ===================================================================== */
#retro-tip {
  --p: 4px; --bd: #7a4a00;
  position: fixed; z-index: 99999; left: 0; top: -999px;
  max-width: min(340px, calc(100vw - 12px));
  pointer-events: none; opacity: 0; visibility: hidden;
  font: 15px/1.5 "Galmuri14", monospace;
  filter: drop-shadow(4px 4px 0 rgba(0, 0, 0, 0.65));
}
#retro-tip.show { opacity: 1; visibility: visible; animation: rt-pop 0.18s steps(3); }
#retro-tip.above.show { animation-name: rt-pop-up; }
@keyframes rt-pop { from { transform: translateY(6px); } to { transform: none; } }
@keyframes rt-pop-up { from { transform: translateY(-6px); } to { transform: none; } }
#retro-tip .rt-bx, #retro-tip .rt-in {
  display: block;
  clip-path: polygon(0 var(--p), var(--p) var(--p), var(--p) 0, calc(100% - var(--p)) 0, calc(100% - var(--p)) var(--p), 100% var(--p), 100% calc(100% - var(--p)), calc(100% - var(--p)) calc(100% - var(--p)), calc(100% - var(--p)) 100%, var(--p) 100%, var(--p) calc(100% - var(--p)), 0 calc(100% - var(--p)));
}
#retro-tip .rt-bx { padding: var(--p); background: var(--bd); }
#retro-tip .rt-in {
  padding: 8px 16px; color: #ffb000; white-space: normal; word-break: keep-all;
  text-shadow: 0 0 6px #ff9a00, 0 0 1px #ffd27a;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.35) 0 2px, transparent 2px 4px), #120a00;
}
#retro-tip .rt-in::after { content: "_"; animation: rt-blink 0.6s steps(1) infinite; }
@keyframes rt-blink { 50% { opacity: 0; } }
/* 도트 계단 꼬리표(대상 쪽을 가리킴) */
#retro-tip::before {
  content: ""; position: absolute; left: var(--tail, 50%); top: -4px; width: 4px; height: 4px;
  background: var(--bd); box-shadow: -4px 4px 0 var(--bd), 0 4px 0 var(--bd), 4px 4px 0 var(--bd); z-index: 1;
}
#retro-tip.above::before { top: auto; bottom: -4px; box-shadow: -4px -4px 0 var(--bd), 0 -4px 0 var(--bd), 4px -4px 0 var(--bd); }

/* 게임 화면 전체: 드래그해도 글자·이미지가 선택(파란 하이라이트)되지 않게 합니다.
   닉네임 입력칸처럼 직접 타이핑하는 곳만 예외로 선택·편집을 허용합니다. */
html, body, body * { -webkit-user-select: none; user-select: none; }
input, textarea { -webkit-user-select: text; user-select: text; }
img, svg { -webkit-user-drag: none; }

/* 닉네임 수정 버튼: 회색 입체 블록 + 흰 점 3개, 올리면 밝아지고 누르면 꺼짐 (툴팁 "수정") */
.profile-edit {
  width: 20px; height: 20px; margin-left: 6px; border: 0; background: #6c6f7a; color: #fff;
  box-shadow: inset 2px 2px 0 #9b9ea9, inset -2px -2px 0 #43454e;
}
.profile-edit:hover { background: #7b7f8b; color: #fff; border-color: transparent; }
.profile-edit:active { box-shadow: inset 2px 2px 0 #43454e, inset -2px -2px 0 #9b9ea9; }

/* 시작 화면 난이도 버튼: 마우스를 올리면(키보드 초점도) 난이도별 색상으로 바뀝니다 */
.start-main[data-start-difficulty="easy"]   { --dc: #8fd63a; --dt: var(--black); }
.start-main[data-start-difficulty="normal"] { --dc: #4ab7ee; --dt: var(--black); }
.start-main[data-start-difficulty="hard"]   { --dc: #ed9847; --dt: var(--black); }
.start-main[data-start-difficulty="crazy"]  { --dc: #ee82ee; --dt: var(--black); }
.start-main[data-start-difficulty="hell"]   { --dc: #e54213; --dt: var(--white); }
.start-main[data-start-difficulty]:hover,
.start-main[data-start-difficulty]:focus-visible { color: var(--dc); border-color: var(--dc); background: color-mix(in srgb, var(--dc) 18%, var(--black)); }
.start-main[data-start-difficulty]:focus-visible { outline-color: var(--dc); }

/* ---------- 난이도별 상징 색: 게임 중 제목 · ! 버튼 · 도움말 · 나가기 ---------- */
body { --accent: var(--orange); --accent-dark: var(--orange-dark); }
body[data-mode="easy"]   { --accent: #8fd63a; --accent-dark: #4f7d1a; }
body[data-mode="normal"] { --accent: #4ab7ee; --accent-dark: #1f6b99; }
body[data-mode="hard"]   { --accent: #ed9847; --accent-dark: #98430c; }
body[data-mode="crazy"]  { --accent: #ee82ee; --accent-dark: #9a3f9a; }
body[data-mode="hell"]   { --accent: #e54213; --accent-dark: #7a1f05; }
.game-title { color: var(--accent); text-shadow: 3px 3px 0 var(--accent-dark); }
.assist-button { border-color: var(--accent); color: var(--accent); }
.assist-button .pixel-shadow { fill: var(--accent-dark); }
.assist-button:hover { background: var(--accent); }
.assist-button:disabled:hover { color: var(--accent); background: var(--black); }
.assist-button:disabled:hover .pixel-shadow { fill: var(--accent-dark); }
@keyframes assist-blink {
  0% { color: var(--accent); border-color: var(--accent); background: var(--black); }
  50% { color: var(--white); border-color: var(--red); background: var(--red); }
}
#help-button .ac, #settings-button .ac, #exit-button .ac { fill: var(--accent); }

/* ---------- 설정 창 난이도 버튼: 호버·선택 시 난이도 색 ---------- */
.settings-popup .difficulty-buttons button[data-difficulty="easy"]   { --dc: #8fd63a; }
.settings-popup .difficulty-buttons button[data-difficulty="normal"] { --dc: #4ab7ee; }
.settings-popup .difficulty-buttons button[data-difficulty="hard"]   { --dc: #ed9847; }
.settings-popup .difficulty-buttons button[data-difficulty="crazy"]  { --dc: #ee82ee; }
.settings-popup .difficulty-buttons button[data-difficulty="hell"]   { --dc: #e54213; }
.settings-popup .difficulty-buttons button[data-difficulty]:not([data-difficulty="custom"]):hover { color: var(--dc); border-color: var(--dc); background: color-mix(in srgb, var(--dc) 18%, var(--black)); }
.settings-popup .difficulty-buttons button[data-difficulty]:not([data-difficulty="custom"]).active { color: var(--dc); border-color: var(--dc); background: color-mix(in srgb, var(--dc) 18%, var(--black)); }
/* ! 모양(3단 명암)도 난이도 색으로 (어려움·사용자 설정·튜토리얼은 기존 주황 그대로) */
body[data-mode="easy"] .ex-l, body[data-mode="normal"] .ex-l, body[data-mode="crazy"] .ex-l, body[data-mode="hell"] .ex-l { fill: color-mix(in srgb, var(--accent) 55%, #fff); }
body[data-mode="easy"] .ex-o, body[data-mode="normal"] .ex-o, body[data-mode="crazy"] .ex-o, body[data-mode="hell"] .ex-o { fill: var(--accent); }
body[data-mode="easy"] .ex-d, body[data-mode="normal"] .ex-d, body[data-mode="crazy"] .ex-d, body[data-mode="hell"] .ex-d { fill: color-mix(in srgb, var(--accent) 60%, #000); }

/* ---------- 우상단 아이콘: HTML이 옛 버전이어도 적용되도록 색 값으로 직접 지정 ---------- */
#help-button rect[fill="#ed9847"], #settings-button rect[fill="#ed9847"], #exit-button rect[fill="#ed9847"] { fill: var(--accent); }

/* ---------- 해설 칸 글자색도 난이도 색 ---------- */
.guide-title, .guide-body b, .mine-left { color: var(--accent); }
.mine-left { border-color: var(--accent); }
.inline-assist { border-color: var(--accent); color: var(--accent); }
.inline-assist .pixel-shadow { fill: var(--accent-dark); }

/* 해설과 짝이 되는 표시(A·B 이름표, 가리키는 칸 테두리)도 난이도 색 */
.guide .tag, .ex[data-tag]::after, .cell.hint-source[data-tag]::after { background: var(--accent); }
.ex.src, .cell.hint-source { outline-color: var(--accent); }

/* 화면 왼쪽 아래 끝: 버전 표시(회색 작은 글자) */
#version-tag { position: fixed; left: 8px; bottom: 6px; z-index: 1; font-size: 11px; color: var(--gray); opacity: 0.7; pointer-events: none; user-select: none; }

.game-title { cursor: pointer; }
.game-title:focus-visible { outline: 3px solid var(--accent); outline-offset: 6px; }

/* ---------- 랭킹 난이도 탭: 설정 창 난이도 버튼과 같은 방식(평소 흰색, 호버·선택 시 난이도 색) ---------- */
.ranking-tabs button[data-ranking-difficulty] { color: var(--white); border-color: var(--white); background: var(--black); }
.ranking-tabs button[data-ranking-difficulty]:hover,
.ranking-tabs button[data-ranking-difficulty].active { color: var(--dc); border-color: var(--dc); background: color-mix(in srgb, var(--dc) 18%, var(--black)); }

/* 설정 창 '사용자 설정' 버튼: 호버 시 회색 */
.settings-popup .difficulty-buttons button[data-difficulty="custom"]:hover { color: #b4b4b0; border-color: #b4b4b0; background: color-mix(in srgb, #b4b4b0 18%, var(--black)); }
/* 버전 표시: 더 잘 보이게 (밝은 회색, 팝업 위에서도 보임) */
#version-tag { font-size: 13px; color: #a0a0a0; opacity: 1; z-index: 50; left: 10px; bottom: 8px; }

/* 개인 최고 기록 이펙트 */
#stat-time.rolling { color: #eed382; }
#stat-time.pop { display: inline-block; animation: best-pop 0.45s steps(5); }
.congrats-popup.shake { animation: best-shake 0.3s steps(6); }
.best-fx { pointer-events: none; }
.best-fx:not(.best-note) { position: fixed; width: 0; height: 0; z-index: 5; }
.bpt { position: absolute; left: 0; top: 0; animation: best-burst 0.9s steps(8) forwards; }
.spk { position: absolute; width: 8px; height: 8px; background: #eed382; opacity: 0; animation: best-twinkle 0.7s steps(4) forwards; }
.best-note { margin: 10px 0 14px; font-size: 14px; white-space: nowrap; color: #61ce5e !important; animation: best-stamp 0.35s steps(5) both; }
@keyframes best-burst { from { transform: translate(0, 0); opacity: 1; } to { transform: translate(var(--x), var(--y)); opacity: 0; } }
@keyframes best-twinkle { 0% { opacity: 0; transform: scale(0.4); } 40% { opacity: 1; transform: scale(1.3); } 100% { opacity: 0; transform: scale(0.6); } }
@keyframes best-pop { 0% { transform: scale(1); } 40% { transform: scale(1.35); color: #fff; text-shadow: 0 0 10px #fff; } 100% { transform: scale(1); } }
@keyframes best-shake { 0%,100% { transform: translate(0,0); } 20% { transform: translate(-5px,3px); } 40% { transform: translate(5px,-3px); } 60% { transform: translate(-4px,-2px); } 80% { transform: translate(4px,2px); } }
@keyframes best-stamp { from { transform: scale(3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* 클리어 창 통계: 설명이 있는 줄에 커서를 올리면 주황색 */
.congrats-stats > div[title]:hover dt,
.congrats-stats > div[title]:hover dd,
.congrats-stats > div[data-tip]:hover dt,
.congrats-stats > div[data-tip]:hover dd { color: var(--orange); }

/* ---------- 게임 제목 호버: 글리치(지직) 효과 ---------- */
.game-title, .start-title { --g1: #e54213; --g2: #4ab7ee; }
body[data-mode="normal"] .game-title { --g1: #ee82ee; --g2: #eed382; }
body[data-mode="hell"] .game-title { --g1: #eed382; --g2: #f6f6f2; }
.game-title:hover, .start-title:hover { animation: title-glitch 0.35s steps(2) infinite; text-shadow: -3px 0 var(--g1), 3px 0 var(--g2); }
@keyframes title-glitch {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2px, 1px); }
  50% { transform: translate(2px, -1px); }
  75% { transform: translate(-1px, -1px); }
  100% { transform: translate(1px, 1px); }
}
/* 시작 화면 제목은 글자가 커서 잔상·흔들림도 글자 크기에 비례 */
.start-title:hover { animation-name: start-title-glitch; text-shadow: -0.06em 0 var(--g1), 0.06em 0 var(--g2); }
@keyframes start-title-glitch {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-5px, 2px); }
  50% { transform: translate(5px, -2px); }
  75% { transform: translate(-2px, -2px); }
  100% { transform: translate(2px, 2px); }
}
@media (prefers-reduced-motion: reduce) { .game-title:hover, .start-title:hover { animation: none; } }

/* 도움말: 느낌표 버튼 설명 */
.help-note { margin: 8px 0 0 !important; font-size: 13px; color: #a8a8a4 !important; line-height: 1.6; }
.help-lead { margin: 0 0 10px; color: #d8d8d4; }
.help-feature .help-list { margin: 4px 0 0; }
.help-section .inline-assist, .help-assist .inline-assist { vertical-align: -4px; }

/* 설정 창 안 신고 / 문의 */
.rep-link { display: block; margin: 16px auto 0; padding: 4px 8px; background: none; border: 0; color: #a9a9a4; font-size: 13px; text-decoration: underline; cursor: pointer; }
.rep-link:hover { color: var(--orange); }
.rep-form { display: grid; gap: 6px; margin-top: 14px; }
.rep-form[hidden] { display: none; }
.rep-form label { margin-top: 8px; color: var(--orange); }
.rep-form select, .rep-form textarea { width: 100%; padding: 8px 10px; border: 3px solid var(--white); color: var(--white); background: var(--black); font: inherit; }
.rep-form textarea { min-height: 120px; resize: vertical; }
.rep-form select:focus-visible, .rep-form textarea:focus-visible { outline: none; border-color: var(--orange); }
.rep-form .hint { color: #a9a9a4; font-size: 12px; line-height: 1.6; }
#report-back { padding: 9px 16px; border: 3px solid var(--white); color: var(--white); background: var(--black); cursor: pointer; }
#report-back:hover { color: var(--orange); border-color: var(--orange); }
#report-send { padding: 9px 16px; border: 3px solid var(--orange); color: var(--black); background: var(--orange); cursor: pointer; }
#report-send:hover { color: var(--orange); background: var(--black); }

/* 버전 표시: 설정 창 맨 아래 */
.settings-version { margin: 10px 0 0; text-align: center; font-size: 12px; color: var(--gray); }
.settings-popup #version-tag { position: static; z-index: auto; display: inline; font-size: inherit; color: inherit; opacity: 1; pointer-events: none; }

/* ---------- 시작 화면 배경: 실제 지뢰찾기 판처럼 (start-bg.js) ---------- */
body { position: relative; }
.start-bg { position: absolute; left: 0; top: 0; width: 100%; z-index: 0; overflow: hidden; --g1: #e54213; --g2: #4ab7ee; }
.start-bg[hidden] { display: none; }
.start-bg .bg-row { display: flex; }
.start-bg .cell { flex: none; opacity: 0.5; cursor: default; position: relative; display: grid; place-items: center; }
.start-bg .cell.open { opacity: 0.85; }
.start-bg .cell:hover { background-color: var(--blue-hover); opacity: 1; z-index: 3; }
.start-bg .cell.open:hover { background-color: var(--dark-gray); }
.start-bg .cell.shake { animation: bg-shake 0.3s steps(2) infinite; opacity: 1; z-index: 3; }
.start-bg .cell.open.shake { text-shadow: -2px 0 var(--g1), 2px 0 var(--g2); }
.start-bg .cell.flagged.shake, .start-bg .cell.mine.shake { filter: drop-shadow(-2px 0 var(--g1)) drop-shadow(2px 0 var(--g2)); }
@keyframes bg-shake {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2px, 1px); }
  50% { transform: translate(2px, -1px); }
  75% { transform: translate(-1px, -1px); }
  100% { transform: translate(1px, 1px); }
}
.start-bg .cell.hint-safe, .start-bg .cell.hint-mine { animation: bg-pulse 2.4s steps(4) infinite; }
.start-bg .cell.hint-safe.shake, .start-bg .cell.hint-mine.shake { animation: bg-shake 0.3s steps(2) infinite; }
@keyframes bg-pulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 0.95; } }
/* 메뉴 영역 자체는 클릭을 가로채지 않고(배경 칸이 떨리도록), 제목·버튼만 클릭 */
.start-screen { position: relative; z-index: 1; pointer-events: none; }
.start-screen .start-title, .start-screen button, .start-screen .start-label, .start-screen .tut-note, .start-screen .tutorial-list { pointer-events: auto; }
@media (prefers-reduced-motion: reduce) { .start-bg .cell.shake, .start-bg .cell.hint-safe, .start-bg .cell.hint-mine { animation: none; } }

/* 모바일: 저작권 표기는 화면에 고정하지 않고 페이지 맨 끝에 둬서 아래 상자와 겹치지 않게 */
@media (max-width: 640px) { .site-copy { position: absolute; } }

/* 되돌리기 버튼 숨김(되돌리기 기능 코드는 그대로 남겨 둠) */
#undo-button[hidden] { display: none; }
