/* ============================================
   미니오락실 — 공통 스타일
   컨셉: 학교 앞 오락기 컨트롤 패널
   ============================================ */

:root {
  /* 표면 */
  --bg:        #E4E9E4;   /* 오래된 플라스틱 케이스 */
  --paper:     #FBFAF6;   /* 카드/본문 지면 */
  --panel:     #1D2733;   /* 캐비닛 도장 네이비 */
  --panel-2:   #263243;
  --ink:       #17202B;
  --ink-soft:  #5A6675;
  --line:      #C9D1CA;

  /* 아케이드 버튼 4색 = 카테고리 색 */
  --c-puzzle:  #2D74E0;
  --c-arcade:  #E8453C;
  --c-reflex:  #F5B32D;
  --c-board:   #17A673;

  --shadow-hard: 0 5px 0 rgba(23, 32, 43, .85);
  --shadow-soft: 0 2px 0 rgba(23, 32, 43, .18);

  --wrap: 1120px;
  --radius: 14px;

  --font-display: 'Gothic A1', 'Apple SD Gothic Neo', sans-serif;
  --font-body: 'IBM Plex Sans KR', 'Apple SD Gothic Neo', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.75;
  overflow-x: hidden;
}

a { color: inherit; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- 헤더: 컨트롤 패널 ---------- */

.panel {
  background: var(--panel);
  color: #fff;
  border-bottom: 5px solid var(--c-arcade);
}

.panel-in {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 66px;
  padding-top: 10px;
  padding-bottom: 10px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 23px;
  letter-spacing: -.01em;
  color: #fff;
  margin-right: auto;
}

/* 동전 투입구 */
.coin {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--c-reflex);
  border: 3px solid #fff;
  position: relative;
  flex: none;
}
.coin::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 3px;
  height: 12px;
  background: var(--panel);
  border-radius: 2px;
}

.panel-nav {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.panel-nav a {
  color: #C8D2DE;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: 999px;
}
.panel-nav a:hover,
.panel-nav a:focus-visible { background: var(--panel-2); color: #fff; }

/* ---------- 히어로 ---------- */

.hero { padding: 52px 0 28px; }

.hero h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(32px, 6.4vw, 58px);
  line-height: 1.3;
  margin: 0 0 16px;
  letter-spacing: -.005em;
  word-break: keep-all;
}

.hero h1 em {
  font-style: normal;
  color: var(--c-arcade);
}

.hero p {
  margin: 0;
  max-width: 52ch;
  color: var(--ink-soft);
  font-size: 17px;
}

/* ---------- 카테고리 허브 (첫 화면 큰 원) ---------- */

.cat-hub {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 34px 0 6px;
}

.hub-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  font-family: var(--font-body);
  border-radius: 16px;
  transition: transform .1s ease;
}
.hub-item:hover { transform: translateY(-3px); }
.hub-item:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.hub-item.is-off { opacity: .38; }

.hub-cap {
  width: 100%;
  aspect-ratio: 1;
  max-width: 132px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 5px solid var(--ink);
  box-shadow: var(--shadow-hard);
  position: relative;
  overflow: hidden;
}
.hub-cap::before {
  content: "";
  position: absolute;
  top: 8%; left: 14%;
  width: 52%; height: 34%;
  border-radius: 50%;
  background: rgba(255,255,255,.34);
}
.hub-item.cat-puzzle .hub-cap { background: var(--c-puzzle); }
.hub-item.cat-arcade .hub-cap { background: var(--c-arcade); }
.hub-item.cat-reflex .hub-cap { background: var(--c-reflex); }
.hub-item.cat-board  .hub-cap { background: var(--c-board); }

.hub-icon { font-size: clamp(30px, 7vw, 48px); position: relative; }
.hub-label { font-family: var(--font-display); font-weight: 900; font-size: clamp(14px, 2.6vw, 18px); letter-spacing: -.01em; }

/* ---------- 검색 ---------- */

.controls {
  display: flex;
  align-items: center;
  margin: 26px 0 8px;
}

.search {
  margin-left: auto;
  font-family: var(--font-body);
  font-size: 15px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--paper);
  min-width: 200px;
  width: 100%;
  color: var(--ink);
}
.search:focus { outline: 3px solid var(--c-puzzle); outline-offset: 2px; }

/* ---------- 카테고리별 섹션 ---------- */

.cat-section { margin-top: 40px; scroll-margin-top: 90px; }
.cat-section.is-hidden { display: none; }

.cat-heading {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  letter-spacing: -.01em;
}
.cat-dot { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid var(--ink); flex: none; }
.cat-heading.cat-puzzle .cat-dot { background: var(--c-puzzle); }
.cat-heading.cat-arcade .cat-dot { background: var(--c-arcade); }
.cat-heading.cat-reflex .cat-dot { background: var(--c-reflex); }
.cat-heading.cat-board  .cat-dot { background: var(--c-board); }
.cat-n { font-family: var(--font-mono); font-weight: 400; font-size: 13px; color: var(--ink-soft); }

.count {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-soft);
  margin: 6px 0 0;
}

/* ---------- 시그니처: 아케이드 버튼 그리드 ---------- */

.grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 26px 20px;
}

.btn-game {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  gap: 12px;
}

.btn-cap {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 4px solid var(--ink);
  box-shadow: var(--shadow-hard);
  transition: transform .1s ease, box-shadow .1s ease;
  position: relative;
  overflow: hidden;
}

/* 버튼 상단 하이라이트 */
.btn-cap::before {
  content: "";
  position: absolute;
  top: 8%;
  left: 14%;
  width: 52%;
  height: 34%;
  border-radius: 50%;
  background: rgba(255, 255, 255, .34);
}

.btn-game:hover .btn-cap,
.btn-game:focus-visible .btn-cap {
  transform: translateY(5px);
  box-shadow: 0 0 0 rgba(23, 32, 43, .85);
}

.btn-game:focus-visible { outline: none; }
.btn-game:focus-visible .btn-cap { outline: 3px solid var(--ink); outline-offset: 5px; }

.btn-icon {
  font-size: clamp(38px, 6vw, 52px);
  line-height: 1;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,.18));
  position: relative;
}

.btn-label {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 16px;
  text-align: center;
  line-height: 1.35;
  letter-spacing: -.02em;
  word-break: keep-all;
}

.btn-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: -9px;
  text-align: center;
  letter-spacing: .02em;
}

.cat-puzzle .btn-cap { background: var(--c-puzzle); }
.cat-arcade .btn-cap { background: var(--c-arcade); }
.cat-reflex .btn-cap { background: var(--c-reflex); }
.cat-board  .btn-cap { background: var(--c-board); }

.empty {
  padding: 44px 0;
  font-size: 17px;
  color: var(--ink-soft);
}

/* ---------- 게임 페이지 ---------- */

.crumb {
  padding: 20px 0 0;
  font-size: 14px;
}
.crumb a {
  text-decoration: none;
  font-weight: 600;
  border-bottom: 2px solid var(--line);
  padding-bottom: 1px;
}
.crumb a:hover { border-color: var(--ink); }

.game-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 0 20px;
  flex-wrap: wrap;
}

.game-head .badge {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 4px solid var(--ink);
  display: grid;
  place-items: center;
  font-size: 30px;
  box-shadow: var(--shadow-soft);
  flex: none;
}

.game-head h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(26px, 4.6vw, 40px);
  margin: 0;
  line-height: 1.3;
  letter-spacing: -.01em;
  word-break: keep-all;
}

.game-head .tagline {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-size: 15px;
}

/* 게임 조작 영역 — 광고와 반드시 분리 */
.stage-wrap {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 6px 0 rgba(23,32,43,.25);
}

.stage {
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #fff;
  text-align: center;
}

.stage canvas {
  background: #0F1620;
  border-radius: 8px;
  max-width: 100%;
  height: auto;
  touch-action: none;
}

.hud {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 13px;
}

.hud span {
  background: var(--panel-2);
  border-radius: 999px;
  padding: 6px 14px;
  color: #DCE5EF;
}
.hud b { color: #fff; }

.gbtn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  padding: 11px 22px;
  border-radius: 999px;
  border: none;
  background: var(--c-reflex);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 4px 0 #B98413;
  transition: transform .08s, box-shadow .08s;
}
.gbtn:hover { transform: translateY(2px); box-shadow: 0 2px 0 #B98413; }
.gbtn:active { transform: translateY(4px); box-shadow: none; }
.gbtn.ghost { background: var(--panel-2); color: #fff; box-shadow: 0 4px 0 #131C26; }
.gbtn.ghost:hover { box-shadow: 0 2px 0 #131C26; }

.msg { font-size: 18px; font-weight: 600; min-height: 1.4em; }

/* 방향키 패드 (모바일) */
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 58px);
  grid-template-rows: repeat(2, 52px);
  gap: 7px;
  justify-content: center;
}
.dpad button {
  border: none;
  border-radius: 10px;
  background: var(--panel-2);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 3px 0 #10171F;
}
.dpad button:active { transform: translateY(3px); box-shadow: none; }
.dpad .up    { grid-column: 2; grid-row: 1; }
.dpad .left  { grid-column: 1; grid-row: 2; }
.dpad .down  { grid-column: 2; grid-row: 2; }
.dpad .right { grid-column: 3; grid-row: 2; }

/* ---------- 광고 슬롯 (조작 영역과 이격) ---------- */

/* 광고 슬롯 — 게임 조작 영역과 반드시 이격.
   승인 전에는 비어 있으므로 화면에 아무것도 그리지 않습니다.
   광고 코드를 넣으면 :not(:empty) 규칙이 적용되어 여백과 구분선이 살아납니다. */
.ad-slot { text-align: center; }

.ad-slot:not(:empty) {
  margin: 52px auto;
  padding: 18px 0;
  border-top: 2px dashed var(--line);
  border-bottom: 2px dashed var(--line);
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ---------- 본문 텍스트 ---------- */

.doc {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 34px 32px;
  border: 2px solid var(--line);
  margin-bottom: 40px;
}

.doc h2 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -.01em;
  word-break: keep-all;
  margin: 34px 0 12px;
  padding-left: 14px;
  border-left: 6px solid var(--c-arcade);
  line-height: 1.35;
}
.doc h2:first-child { margin-top: 0; }

.doc h3 {
  font-size: 17px;
  margin: 22px 0 8px;
  font-weight: 700;
}

.doc p { margin: 0 0 14px; }
.doc ul, .doc ol { margin: 0 0 16px; padding-left: 22px; }
.doc li { margin-bottom: 7px; }

.doc table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 18px;
  font-size: 15px;
}
.doc th, .doc td {
  border: 1px solid var(--line);
  padding: 9px 12px;
  text-align: left;
}
.doc th { background: #EFEEE7; font-weight: 700; }

.doc kbd {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 5px;
  padding: 1px 7px;
}

/* ---------- 다른 게임 추천 ---------- */

.more h2 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 21px;
  letter-spacing: -.01em;
  margin: 0 0 16px;
}

.more .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 20px 16px; }
.more .btn-label { font-size: 15px; }

/* ---------- 푸터 ---------- */

.foot {
  background: var(--panel);
  color: #9DAABA;
  margin-top: 60px;
  padding: 40px 0 46px;
  font-size: 14px;
}
.foot a { color: #DCE5EF; text-decoration: none; margin-right: 18px; }
.foot a:hover { text-decoration: underline; }
.foot .foot-links { margin-bottom: 14px; }
.foot p { margin: 0; line-height: 1.7; }

/* ---------- 반응형 ---------- */

@media (max-width: 620px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 22px 14px; }
  .doc { padding: 26px 20px; }
  .stage-wrap { padding: 14px; }
  .search { margin-left: 0; width: 100%; }
  .hero { padding: 36px 0 20px; }
  .cat-hub { gap: 10px; }
  .hub-label { font-size: 12px; line-height: 1.25; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- 내 기록보기 ---------- */

.rec-open {
  margin-left: auto;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  background: var(--panel-2);
  border: 2px solid #3B4A5E;
  border-radius: 999px;
  padding: 8px 17px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, transform .08s;
}
.rec-open:hover { background: #33425A; }
.rec-open:active { transform: translateY(1px); }
.rec-open:focus-visible { outline: 3px solid var(--c-reflex); outline-offset: 2px; }

.rec-back {
  position: fixed;
  inset: 0;
  background: rgba(15, 22, 32, .62);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 16px 16px;
  z-index: 60;
  overflow-y: auto;
}

.rec-box {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 8px 0 rgba(23, 32, 43, .5);
  width: 100%;
  max-width: 560px;
  padding: 24px 24px 20px;
  margin-bottom: 5vh;
}

.rec-head { display: flex; align-items: center; gap: 12px; }
.rec-head h2 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 27px;
  margin: 0;
  margin-right: auto;
  letter-spacing: -.01em;
}
.rec-x {
  border: none;
  background: var(--bg);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 15px;
  cursor: pointer;
  color: var(--ink);
  flex: none;
}
.rec-x:hover { background: var(--line); }

.rec-sum { margin: 6px 0 18px; font-size: 14px; color: var(--ink-soft); }
.rec-sum b { color: var(--ink); font-family: var(--font-mono); }

.rec-sec { margin-bottom: 18px; }
.rec-sec h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  margin: 0 0 8px;
  letter-spacing: .04em;
}

.rec-list { list-style: none; margin: 0; padding: 0; }

.rec-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--ink);
}
.rec-link:hover { background: var(--bg); }

.rec-dot {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2.5px solid var(--ink);
  display: grid;
  place-items: center;
  font-size: 19px;
  flex: none;
}
.rec-dot.cat-puzzle { background: var(--c-puzzle); }
.rec-dot.cat-arcade { background: var(--c-arcade); }
.rec-dot.cat-reflex { background: var(--c-reflex); }
.rec-dot.cat-board  { background: var(--c-board); }

.rec-name { display: flex; flex-direction: column; line-height: 1.35; margin-right: auto; }
.rec-name b { font-size: 15px; font-weight: 700; }
.rec-name em { font-style: normal; font-size: 12px; color: var(--ink-soft); }

.rec-val {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 16px;
  text-align: right;
  flex: none;
}

.rec-item.is-empty .rec-dot { opacity: .3; }
.rec-item.is-empty .rec-name b { color: var(--ink-soft); font-weight: 500; }
.rec-item.is-empty .rec-val { color: var(--line); }

.rec-empty {
  text-align: center;
  padding: 32px 0 36px;
  color: var(--ink-soft);
}
.rec-empty p { margin: 0 0 6px; }

.rec-foot {
  border-top: 2px solid var(--line);
  padding-top: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.rec-note { margin: 0; font-size: 12.5px; color: var(--ink-soft); flex: 1; min-width: 200px; line-height: 1.6; }

@media (max-width: 620px) {
  .rec-open { font-size: 13px; padding: 7px 13px; }
  .rec-box { padding: 20px 16px 16px; }
  .rec-back { padding: 3vh 10px 10px; }
}

/* ---------- 화면 조작 버튼 ---------- */

.act-pad {
  display: flex;
  gap: 9px;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  max-width: 420px;
}

.act-pad button {
  border: none;
  border-radius: 12px;
  background: var(--panel-2);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 16px;
  min-width: 62px;
  padding: 15px 18px;
  cursor: pointer;
  box-shadow: 0 4px 0 #10171F;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.act-pad button.wide { flex: 1; min-width: 96px; }
.act-pad button:active { transform: translateY(4px); box-shadow: none; }
.act-pad button:focus-visible { outline: 3px solid var(--c-reflex); outline-offset: 2px; }

/* 조작 영역과 '다시 시작' 버튼을 확실히 분리해 오조작 방지 */
.restart-zone {
  margin-top: 12px;
  padding-top: 18px;
  border-top: 1px solid #33425A;
  width: 100%;
  max-width: 420px;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.restart-zone .gbtn {
  background: var(--panel-2);
  color: #C8D2DE;
  box-shadow: 0 3px 0 #10171F;
  font-size: 14px;
  padding: 9px 20px;
}
.restart-zone .gbtn:hover { box-shadow: 0 1px 0 #10171F; }

.dpad { margin-bottom: 2px; }

@media (max-width: 620px) {
  .act-pad button { font-size: 15px; padding: 16px 14px; min-width: 56px; }
}



/* ---------- 앱처럼 설치하기 버튼 ---------- */

.install-btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  background: var(--c-arcade);
  border: 2px solid #ff6b60;
  border-radius: 999px;
  padding: 8px 17px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, transform .08s;
  margin-left: auto;
}
.install-btn:hover { background: #d63a30; }
.install-btn:active { transform: translateY(1px); }
.install-btn:focus-visible { outline: 3px solid var(--c-reflex); outline-offset: 2px; }

/* 설치 버튼이 있으면 그게 margin-left:auto를 갖고, 기록보기 버튼은 그 뒤에 바로 붙는다 */
.install-btn + .rec-open { margin-left: 0; }

@media (max-width: 620px) {
  .install-btn { font-size: 13px; padding: 7px 13px; }
}


/* ---------- 공략 블로그 카드 ---------- */
.blog-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 20px; }
.blog-card a {
  display: flex; gap: 20px; text-decoration: none; color: var(--ink);
  background: var(--paper); border: 2px solid var(--line); border-radius: 14px; padding: 14px;
  transition: transform .1s ease, box-shadow .1s ease;
}
.blog-card a:hover { transform: translateY(-2px); box-shadow: 0 4px 0 rgba(23,32,43,.15); }
.blog-thumb {
  position: relative; flex: none; width: 220px; aspect-ratio: 16/10;
  border-radius: 10px; overflow: hidden; background: var(--panel); display: grid; place-items: center;
}
.blog-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.blog-tag {
  position: absolute; top: 8px; left: 8px; background: var(--c-arcade); color: #fff;
  font-family: var(--font-body); font-weight: 700; font-size: 12px; padding: 4px 10px; border-radius: 999px;
}
.blog-body { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.blog-body h3 { font-family: var(--font-display); font-weight: 900; font-size: 19px; margin: 0 0 8px; letter-spacing: -.01em; line-height: 1.35; }
.blog-body p {
  margin: 0 0 10px; font-size: 14px; color: var(--ink-soft); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.blog-meta { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); }
@media (max-width: 620px) {
  .blog-card a { flex-direction: column; }
  .blog-thumb { width: 100%; aspect-ratio: 16/9; }
}
