/* ── KAKURO VARIABLES ────────────────────────────────────────── */
:root {
  --kk-cs:        52px;
  --kk-gap:       2px;
  --kk-black:     #1d3a6e;
  --kk-grid-bg:   #0e2040;
  --kk-line:      rgba(255,255,255,.38);
  --kk-clue-col:  rgba(255,255,255,.88);
  --kk-hover:     #e8f2fc;
  --kk-sel:       #b8d4f4;
  --kk-run:       #daeaf8;
  --kk-user:      #1a55a8;
}
[data-theme="dark"] {
  --kk-black:     #09172e;
  --kk-grid-bg:   #030c1a;
  --kk-line:      rgba(255,255,255,.25);
  --kk-clue-col:  rgba(255,255,255,.72);
  --kk-hover:     #0d2240;
  --kk-sel:       #1a3d6a;
  --kk-run:       #0f2a4e;
  --kk-user:      #7ab0e0;
}

/* ── HINT AD MODAL ──────────────────────────────────────────── */
#hintModal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5,15,45,.72);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#hintModal.show { display: flex; }

.hint-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 24px 72px rgba(0,0,40,.32);
  animation: pop .38s cubic-bezier(.34,1.56,.64,1);
  width: 360px;
  max-width: 90vw;
  position: relative;
}

#hintPhase1, #hintPhase2, #hintPhase3 { display: none; }
#hintPhase1.active, #hintPhase2.active, #hintPhase3.active { display: block; }

.hint-icon  { font-size: 50px; line-height: 1.15; }
.hint-title { font-size: 1.25em; font-weight: 800; color: var(--primary); margin: 10px 0 6px; }
.hint-sub   { font-size: 14px; color: var(--muted); line-height: 1.55; }

.hint-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }

.hint-btn-primary {
  padding: 11px 24px;
  border: none;
  border-radius: 26px;
  background: var(--primary);
  color: white;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: .16s;
}
.hint-btn-primary:hover { background: var(--primary-dk); transform: translateY(-1px); }

.hint-btn-ghost {
  padding: 9px 24px;
  border: 2px solid var(--btn-border);
  border-radius: 26px;
  background: transparent;
  color: var(--btn-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: .16s;
}
.hint-btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

#hintPhase2 { position: relative; }
.hint-close-btn {
  position: absolute;
  top: -8px; right: -8px;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid var(--btn-border);
  background: var(--card-bg);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: .14s;
}
.hint-close-btn:hover { border-color: var(--err-color); color: var(--err-color); }

#hintAdSlot { margin: 0 auto; }

.hint-progress-label { font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.hint-progress-wrap  { height: 8px; background: var(--border-light); border-radius: 4px; overflow: hidden; }
.hint-progress-bar   { height: 100%; width: 0%; background: var(--primary); border-radius: 4px; transition: width 1s linear; }

/* ── GAME CARD WIDTH ─────────────────────────────────────────── */
.game-card { max-width: 100%; }

/* ── GAME AREA ───────────────────────────────────────────────── */
.game-area {
  display: flex;
  gap: 16px;
  padding: 12px 12px 16px;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: center;
}

.kk-scroll { overflow-x: auto; flex-shrink: 0; }

/* ── GRID TABLE ──────────────────────────────────────────────── */
.kk-grid {
  border-collapse: separate;
  border-spacing: var(--kk-gap);
  background: var(--kk-grid-bg);
  border: 4px solid var(--kk-grid-bg);
  border-radius: 8px;
  user-select: none;
}

/* ── BASE CELL ───────────────────────────────────────────────── */
.kk-cell {
  width: var(--kk-cs);
  height: var(--kk-cs);
  min-width: var(--kk-cs);
  padding: 0;
  vertical-align: middle;
  font-family: 'Nunito', sans-serif;
}

/* ── BLACK / WALL CELL ───────────────────────────────────────── */
.kk-black { background: var(--kk-black); border-radius: 3px; }

/* ── CLUE CELL ───────────────────────────────────────────────── */
.kk-clue {
  background: var(--kk-black);
  position: relative;
  overflow: hidden;
  border-radius: 3px;
}

.kk-clue::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top right,
    transparent calc(50% - 0.7px),
    var(--kk-line) calc(50% - 0.7px),
    var(--kk-line) calc(50% + 0.7px),
    transparent calc(50% + 0.7px)
  );
  pointer-events: none;
}

/* down clue — bottom-left triangle, close to the white cells below */
.kk-d {
  position: absolute;
  bottom: 3px;
  left: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--kk-clue-col);
  line-height: 1;
  z-index: 1;
}

/* across clue — top-right triangle, close to the white cells to the right */
.kk-a {
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--kk-clue-col);
  line-height: 1;
  z-index: 1;
}

/* ── WHITE (PLAYABLE) CELL ───────────────────────────────────── */
.kk-white {
  background: var(--card-bg);
  cursor: pointer;
  position: relative;
  border-radius: 2px;
  transition: background .1s;
}
.kk-white:hover       { background: var(--kk-hover); }
.kk-white.kk-run      { background: var(--kk-run); }
.kk-white.kk-sel      { background: var(--kk-sel); }

.kk-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--kk-user);
  pointer-events: none;
  line-height: 1;
}
.kk-white.kk-err .kk-num { color: var(--err-color); }

/* ── SIDE PANEL ──────────────────────────────────────────────── */
.actions { display: flex; flex-direction: column; gap: 6px; }

.kk-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 140px;
  flex-shrink: 0;
}

/* ── NUMPAD ──────────────────────────────────────────────────── */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.num-btn {
  padding: 0;
  height: 38px;
  border: 2px solid var(--btn-border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--btn-text);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  transition: .15s;
}
.num-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--btn-hover-bg); }

/* ── BLURRED GRID (pause) ────────────────────────────────────── */
.kk-grid.blurred { filter: blur(8px); pointer-events: none; }

/* ── PAUSED OVERLAY ──────────────────────────────────────────── */
.kk-paused-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.45);
  border-radius: 8px;
  color: white;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  backdrop-filter: blur(3px);
}

/* ── SIDE PANEL ADS (hidden by default) ─────────────────────── */
.side-panel-ad     { display: none; }
.side-panel-mid-ad { display: none; }
.game-mid-ad { display: none; margin: 0 auto 14px; }

@media (max-width: 775px) {
  .hdr-nav .ad-leaderboard { display: none; }
  .game-mid-ad { display: flex; }
}

@media (max-width: 1100px) {
  .content-row { grid-template-columns: 1fr; }
}

@media (min-width: 775px) and (max-width: 1100px) {
  .right-sidebar { display: none; }
  .kk-side { width: 300px; }
  .side-panel-ad { display: flex; }

  /* Actions on one row */
  .actions { display: flex; flex-direction: row; gap: 6px; }
  .act-btn  { flex: 1; }

  /* Numpad on 2 rows (5 columns × 2 = 9 buttons) */
  .numpad { grid-template-columns: repeat(5, 1fr); gap: 5px; }
}

@media (max-width: 650px) {
  .kk-side { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .numpad  { grid-template-columns: repeat(5, 1fr); order: 1; flex: 1 1 100%; }
  .side-panel-mid-ad { display: flex; order: 2; flex: 1 1 100%; margin: 0 auto; }
  .actions { display: flex; flex-direction: row; order: 3; gap: 6px; }
  .act-btn  { flex: 1; }
  .best-box { order: 4; }
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 520px) {
  :root { --kk-cs: 42px; }
  .kk-d, .kk-a { font-size: 11px; }
  .kk-num { font-size: 17px; }
  .game-area { gap: 12px; padding: 8px; }
}

@media (max-width: 400px) {
  :root { --kk-cs: 36px; }
  .kk-d, .kk-a { font-size: 11px; }
  .kk-num { font-size: 14px; }
}
