/* 크리비지 — 폰 세로 한 손. 위에서부터 페그보드 → 컷/합/크립 → 페깅 더미 →
   상태 → 내 손패 → 동작 버튼 순으로, 엄지가 닿는 아래쪽에 조작을 몰아둔다. */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #0a0a0a; color: #f5f5f5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
main {
  height: 100%; max-width: 480px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: max(60px, env(safe-area-inset-top)) 10px max(14px, env(safe-area-inset-bottom));
}
.score-bar { display: flex; gap: 6px; align-items: stretch; flex: 0 0 auto; }
.score-box {
  flex: 1; background: #161616; border: 1px solid #2a2a2a; border-radius: 12px;
  padding: 6px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-width: 0;
}
.score-label { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: #a0a0a0; }
.score-val, .best-val { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.new-btn {
  flex: 0 0 auto; font: inherit; color: #0a0a0a; background: #4f9eff; border: none;
  border-radius: 12px; padding: 0 14px; min-height: 56px; cursor: pointer;
  font-weight: 700; font-size: 14px;
}
.new-btn:active { background: #3d8ae8; }

#game {
  flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px;
  background: radial-gradient(120% 80% at 50% 30%, #16241c 0%, #101613 55%, #0d0f0e 100%);
  border: 1px solid #23282a; border-radius: 18px; padding: 12px 10px;
}

/* ── 페그보드: 61점 트랙 위의 두 말 ─────────────────────────────────────── */
.pegboard { display: flex; flex-direction: column; gap: 7px; flex: 0 0 auto; }
.peg-row { display: flex; align-items: center; gap: 8px; }
.peg-name { flex: 0 0 44px; font-size: 11px; font-weight: 700; color: #a0a0a0; }
.peg-track {
  flex: 1; position: relative; height: 10px; border-radius: 999px;
  background: #1d2a22; border: 1px solid #2c3a31;
}
.peg {
  position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%;
  transform: translateY(-50%); transition: left 0.35s ease-out;
}
.peg-me { background: #4f9eff; box-shadow: 0 0 0 2px rgba(79,158,255,0.28); }
.peg-ai { background: #ff8a5c; box-shadow: 0 0 0 2px rgba(255,138,92,0.28); }
.peg-num { flex: 0 0 26px; text-align: right; font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ── 컷 / 합 / 크립 ───────────────────────────────────────────────────── */
.table-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; flex: 0 0 auto; }
.slot-wrap, .count-wrap { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 54px; }
.slot-label { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: #8fa398; }
.slot { display: inline-flex; min-height: 50px; align-items: center; }
.count-val { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.dealer-tag { font-size: 11px; font-weight: 600; color: #8fa398; }

/* ── 페깅 더미 ────────────────────────────────────────────────────────── */
.stack {
  /* flex:1 로 남는 세로 공간을 여기서 먹는다 — 손패와 동작 버튼이 화면 아래(엄지
     닿는 곳)에 붙고, 페깅 카드는 그 위 빈 공간의 가운데에 모인다. */
  flex: 1 1 auto; min-height: 52px; display: flex; flex-wrap: wrap; gap: 4px;
  align-items: center; align-content: center; justify-content: center;
}

/* ── 카드 ─────────────────────────────────────────────────────────────── */
.card {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  width: 44px; height: 62px; border-radius: 7px; background: #f7f4ec;
  border: 1px solid #cfc9b8; line-height: 1; user-select: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.card .cr { font-size: 17px; font-weight: 800; }
.card .cs { font-size: 15px; margin-top: 2px; }
.card.blk { color: #16181d; }
.card.red { color: #c0182c; }
.card.sm { width: 34px; height: 48px; }
.card.sm .cr { font-size: 13px; }
.card.sm .cs { font-size: 12px; }
.card.back {
  background: repeating-linear-gradient(45deg, #2c4a6b 0 5px, #22405f 5px 10px);
  border-color: #3a5c80;
}
.card.cut { box-shadow: 0 0 0 2px #c8a020; }

/* ── 내 손패 ──────────────────────────────────────────────────────────── */
.hand {
  flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 6px;
  align-items: center; justify-content: center; min-height: 62px;
}
.hand .card { cursor: pointer; transition: transform 0.12s ease-out; }
.hand .card.picked { transform: translateY(-9px); box-shadow: 0 0 0 3px #4f9eff; }
.hand .card.dim { opacity: 0.34; cursor: default; }

/* ── 쇼(점수 세기) 패널 ───────────────────────────────────────────────── */
.show-box {
  flex: 0 1 auto; min-height: 0; max-height: 48%; overflow-y: auto;
  background: rgba(0,0,0,0.30); border: 1px solid #2c3a31; border-radius: 12px; padding: 10px;
}
.show-box[hidden] { display: none; }
.show-head { font-size: 15px; font-weight: 800; margin-bottom: 7px; }
.show-cards { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.show-detail { margin-top: 7px; font-size: 12px; color: #a8bcb0; text-align: center; }

.status { margin: 0; text-align: center; font-size: 13px; font-weight: 600; color: #a0a0a0; min-height: 18px; flex: 0 0 auto; }
.status.ok { color: #52d97f; }
.status.bad { color: #ff8a8a; }

.act-btn {
  flex: 0 0 auto; font: inherit; font-weight: 700; font-size: 15px;
  color: #0a0a0a; background: #4f9eff; border: none; border-radius: 12px;
  min-height: 48px; cursor: pointer; width: 100%;
}
.act-btn:active { background: #3d8ae8; }
.act-btn[hidden] { display: none; }

.home-link, .hof-link {
  position: fixed; top: max(12px, env(safe-area-inset-top)); z-index: 10;
  width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; background: rgba(0,0,0,0.35); color: #fff; text-decoration: none;
  font-size: 20px; font-weight: 600; line-height: 1; border: none; cursor: pointer;
  font-family: inherit; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.home-link { left: max(12px, env(safe-area-inset-left)); }
.hof-link { right: max(12px, env(safe-area-inset-right)); }

.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex;
  align-items: center; justify-content: center; z-index: 20; padding: 20px;
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.overlay[hidden] { display: none; }
.overlay-card {
  background: #161616; border: 1px solid #2a2a2a; border-radius: 18px; padding: 24px 22px;
  display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center;
  min-width: 240px; max-width: 320px; width: 100%;
}
.overlay-card h2 { margin: 0; font-size: 22px; font-weight: 800; }
.overlay-score { margin: 0; font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; }
.overlay-sub { margin: -4px 0 0; font-size: 14px; font-weight: 600; color: #a0a0a0; }
.overlay-card button {
  font: inherit; color: #fff; background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.22); border-radius: 999px; padding: 12px 20px;
  min-height: 44px; cursor: pointer; font-weight: 600; font-size: 14px; width: 100%;
}
.overlay-card button:active { background: rgba(255,255,255,0.18); }
.overlay-card .save-btn { background: #4f9eff; border-color: #4f9eff; color: #0a0a0a; }
