/* 고양이 타워 — 디자인 토큰
 * 방향성: 코지 레트로 일본 인디게임. 베이지+코랄+진브라운 팔레트.
 * 그라데이션/소프트 블러 최소화, 하드섀도우 + 뚜렷한 보더로 수제감. */
:root {
  --bg: #F5E9D4;
  --bg-soft: #FBF2E0;
  --card: #FFFBF1;
  --ink: #2E1F17;
  --ink-soft: #5A4535;
  --accent: #E85A4F;
  --accent-dark: #B73E35;
  --yellow: #F2B43A;
  --sage: #90A583;
  --line: #3A2920;
  --shadow: 0 3px 0 0 var(--line);
  --shadow-deep: 0 5px 0 0 var(--line);
  --radius: 14px;
  --radius-sm: 10px;
  --mobile-browser-bottom-gap: 24px;
  --screen-max-width: 420px;
  --screen-max-height: 900px;
  --menu-pad-y: 32px;
  --menu-pad-x: 24px;
  --menu-gap: 28px;
  --title-emoji-size: 72px;
  --title-size: 40px;
  --tagline-size: 15px;
  --best-pad-y: 16px;
  --best-pad-x: 28px;
  --best-min-width: 220px;
  --best-label-size: 12px;
  --best-value-size: 32px;
  --menu-btn-max-width: 280px;
  --btn-font-size: 17px;
  --btn-pad-y: 14px;
  --btn-pad-x: 20px;
  --modal-shell-pad: 24px;
  --modal-body-max-width: 360px;
  --modal-body-pad-y: 24px;
  --modal-body-pad-x: 20px;
  --modal-gap: 14px;
  --modal-title-size: 24px;
  --final-value-size: 48px;
  --rank-row-font-size: 14px;
  --field-max-width: 400px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
}
body {
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  /* 은은한 점묘 패턴 — AI 그라데이션 느낌 제거, 종이 질감 */
  background-image:
    radial-gradient(rgba(58, 41, 32, 0.07) 1px, transparent 1.2px),
    radial-gradient(rgba(58, 41, 32, 0.05) 1px, transparent 1.2px);
  background-size: 22px 22px, 22px 22px;
  background-position: 0 0, 11px 11px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- 상단 전역 바 ---------- */
#topbar {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 30;
}
#topbar > * { pointer-events: auto; }
/* 게임 중에는 숨김 (ArcherLab 링크/언어 토글) — 몰입도 우선 */
body:has(#game:not(.hidden)) #topbar { display: none; }
.topbar-btn {
  background: rgba(255, 251, 241, 0.92);
  color: var(--ink);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-decoration: none;
  box-shadow: 0 2px 0 0 var(--line);
  transition: transform 0.08s, box-shadow 0.08s;
}
.topbar-btn:hover { transform: translateY(-1px); box-shadow: 0 3px 0 0 var(--line); }
.topbar-btn:active { transform: translateY(2px); box-shadow: none; }
.lang-switch {
  display: flex;
  gap: 0;
  background: rgba(255, 251, 241, 0.92);
  border: 2px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: 0 2px 0 0 var(--line);
}
.lang-btn {
  background: transparent;
  border: none;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink-soft);
  font-family: inherit;
  letter-spacing: 0;
}
.lang-btn.active {
  background: var(--accent);
  color: #FFF5EC;
}
.lang-btn:not(.active):hover { background: rgba(58, 41, 32, 0.06); color: var(--ink); }

.screen {
  width: 100%;
  max-width: var(--screen-max-width);
  height: 100%;
  max-height: var(--screen-max-height);
  display: flex;
  flex-direction: column;
}
.hidden { display: none !important; }

/* ---------- 메인 메뉴 ---------- */
#menu {
  padding: var(--menu-pad-y) var(--menu-pad-x);
  align-items: center;
  justify-content: center;
  gap: var(--menu-gap);
  text-align: center;
}

.title-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.title-emoji {
  font-size: var(--title-emoji-size);
  line-height: 1;
  filter: drop-shadow(0 4px 0 rgba(58, 41, 32, 0.12));
  animation: bob 3.2s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-6px) rotate(2deg); }
}
h1 {
  font-size: var(--title-size);
  font-weight: 800;
  letter-spacing: 0;
  color: var(--ink);
}
.tagline {
  color: var(--ink-soft);
  font-size: var(--tagline-size);
  letter-spacing: 0;
}

.best-card {
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  padding: var(--best-pad-y) var(--best-pad-x);
  box-shadow: var(--shadow-deep);
  min-width: var(--best-min-width);
}
.best-label {
  font-size: var(--best-label-size);
  font-weight: 700;
  letter-spacing: 0;
  color: var(--accent);
  margin-bottom: 4px;
}
.best-value {
  font-size: var(--best-value-size);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.menu-btns {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: var(--menu-btn-max-width);
}

.btn {
  font: inherit;
  font-weight: 700;
  font-size: var(--btn-font-size);
  letter-spacing: 0;
  padding: var(--btn-pad-y) var(--btn-pad-x);
  border-radius: var(--radius);
  cursor: pointer;
  border: 3px solid var(--line);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  box-shadow: var(--shadow);
}
.btn:not(:disabled):hover { transform: translate(-1px, -1px); box-shadow: 0 4px 0 0 var(--line); }
.btn:not(:disabled):active {
  transform: translate(0, 3px);
  box-shadow: 0 0 0 0 var(--line);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #FFF5EC; }
.btn-secondary { background: var(--card); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: rgba(58, 41, 32, 0.25); box-shadow: none; }
.btn-ghost:not(:disabled):hover { color: var(--ink); border-color: var(--line); box-shadow: var(--shadow); }

.credit {
  margin-top: auto;
  font-size: 11px;
  color: var(--ink-soft);
  opacity: 0.65;
  letter-spacing: 0;
}

/* ---------- 게임 화면 ---------- */
#game {
  --game-pad-top: 10px;
  --game-pad-x: 12px;
  --game-pad-bottom: 10px;
  --game-gap: 4px;
  --hud-pad-y: 10px;
  --hud-pad-x: 14px;
  --hud-border: 3px;
  --hud-gap: 10px;
  --icon-size: 42px;
  --next-cat-size: 46px;
  --stat-label-size: 10px;
  --stat-value-size: 24px;
  --chip-font-size: 10px;
  --chip-pad-y: 2px;
  --chip-pad-x: 7px;
  --next-name-font-size: 9px;
  --strip-gap: 5px;
  --strip-padding: 6px;
  --tier-icon-size: 18px;
  --tier-num-size: 9px;
  --tier-name-size: 8px;
  --tier-cell-gap: 3px;
  --tier-cell-pad-y: 3px;
  --tier-cell-pad-x: 4px;
  --game-hint-font-size: 12px;
  padding: var(--game-pad-top) var(--game-pad-x) calc(var(--game-pad-bottom) + env(safe-area-inset-bottom));
  gap: var(--game-gap);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.hud {
  display: flex;
  align-items: center;
  gap: var(--hud-gap);
  background: var(--card);
  border: var(--hud-border) solid var(--line);
  border-radius: var(--radius);
  padding: var(--hud-pad-y) var(--hud-pad-x);
  box-shadow: var(--shadow);
}
.stat { display: flex; flex-direction: column; }
.score-stat { flex: 1; }
.cat-name-chip {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  min-height: 18px;
  max-width: 148px;
  margin-top: 3px;
  padding: var(--chip-pad-y) var(--chip-pad-x);
  border: 1px solid rgba(58, 41, 32, 0.20);
  border-radius: 999px;
  background: rgba(251, 242, 224, 0.86);
  color: var(--ink-soft);
  font-size: var(--chip-font-size);
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-label {
  font-size: var(--stat-label-size);
  font-weight: 700;
  letter-spacing: 0;
  color: var(--accent);
}
.stat-value {
  font-size: var(--stat-value-size);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  line-height: 1.1;
}
.next-stat { align-items: center; }
.next-stat canvas {
  width: var(--next-cat-size);
  height: var(--next-cat-size);
  background: var(--bg-soft);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  margin-top: 2px;
}
.next-cat-name {
  width: 64px;
  min-height: 13px;
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: var(--next-name-font-size);
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  width: var(--icon-size);
  height: var(--icon-size);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-soft);
  border: var(--hud-border) solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  letter-spacing: 0;
  color: var(--ink);
  font-weight: 700;
  box-shadow: var(--shadow);
  transition: transform 0.08s, box-shadow 0.08s;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 0 0 0 var(--line); }
.icon-btn.muted { color: var(--ink-soft); background: rgba(58, 41, 32, 0.06); opacity: 0.75; }

.game-tier-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--strip-gap);
  width: 100%;
  max-width: var(--field-max-width);
  align-self: center;
  padding: var(--strip-padding);
  background: rgba(255, 251, 241, 0.88);
  border: 2px solid rgba(58, 41, 32, 0.28);
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 0 rgba(58, 41, 32, 0.24);
  margin-bottom: 0;
}
.game-tier-cell {
  min-width: 0;
  display: grid;
  grid-template-columns: var(--tier-icon-size) 1fr;
  align-items: center;
  gap: var(--tier-cell-gap);
  padding: var(--tier-cell-pad-y) var(--tier-cell-pad-x);
  border: 1px solid rgba(58, 41, 32, 0.14);
  border-radius: 8px;
  background: var(--bg-soft);
}
.game-tier-cell canvas {
  width: var(--tier-icon-size);
  height: var(--tier-icon-size);
}
.game-tier-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1;
}
.game-tier-num {
  color: var(--accent);
  font-size: var(--tier-num-size);
  font-weight: 900;
}
.game-tier-name {
  color: var(--ink-soft);
  font-size: var(--tier-name-size);
  font-weight: 800;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-wrap {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 0;
}
#canvas {
  width: 100%;
  max-width: var(--field-max-width);
  aspect-ratio: 400 / 540;
  background: var(--bg-soft);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-deep);
  display: block;
  margin: 0 auto;
  touch-action: none;
  cursor: grab;
}
#canvas:active { cursor: grabbing; }

.game-hint {
  text-align: center;
  font-size: var(--game-hint-font-size);
  color: var(--ink-soft);
  opacity: 0.75;
  letter-spacing: 0;
}

.combo-flash {
  position: fixed;
  top: 32%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: var(--yellow);
  color: var(--ink);
  font-weight: 800;
  font-size: 26px;
  padding: 8px 18px;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-deep);
  pointer-events: none;
  opacity: 0;
  z-index: 20;
}
.combo-flash.pop {
  animation: comboPop 0.8s cubic-bezier(0.2, 0.9, 0.3, 1.15) forwards;
}
.combo-flash.legend {
  background: linear-gradient(135deg, #F2B43A 0%, #FFD46E 50%, #F2B43A 100%);
  font-size: 30px;
  padding: 12px 26px;
  box-shadow: 0 5px 0 0 var(--line), 0 0 24px rgba(242, 180, 58, 0.65);
}
.combo-flash.legend.pop {
  animation: legendPop 1.8s cubic-bezier(0.2, 0.9, 0.3, 1.15) forwards;
}
@keyframes comboPop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6) rotate(-5deg); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1.1) rotate(3deg); }
  60%  { opacity: 1; transform: translate(-50%, -60%) scale(1) rotate(-1deg); }
  100% { opacity: 0; transform: translate(-50%, -85%) scale(0.95) rotate(0); }
}
@keyframes legendPop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.5) rotate(-8deg); }
  15%  { opacity: 1; transform: translate(-50%, -50%) scale(1.25) rotate(4deg); }
  30%  { opacity: 1; transform: translate(-50%, -50%) scale(1.05) rotate(-2deg); }
  70%  { opacity: 1; transform: translate(-50%, -55%) scale(1.05) rotate(1deg); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(1) rotate(0); }
}

/* ---------- 모달 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(46, 31, 23, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: var(--modal-shell-pad);
  animation: fadeIn 0.18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-body {
  width: 100%;
  max-width: var(--modal-body-max-width);
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-deep);
  padding: var(--modal-body-pad-y) var(--modal-body-pad-x) calc(var(--modal-body-pad-y) - 4px);
  display: flex;
  flex-direction: column;
  gap: var(--modal-gap);
  text-align: center;
  animation: slideUp 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.modal-body h2 { font-size: var(--modal-title-size); font-weight: 800; letter-spacing: 0; }
.modal-body h3 { font-size: 14px; font-weight: 700; color: var(--accent); letter-spacing: 0; margin-top: 4px; }

.final-block { padding: 8px 0; }
.final-label {
  font-size: 11px;
  letter-spacing: 0;
  color: var(--accent);
  font-weight: 700;
}
.final-value {
  font-size: var(--final-value-size);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  line-height: 1.1;
}
.new-record {
  display: inline-block;
  margin-top: 8px;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 800;
  padding: 4px 14px;
  border-radius: 999px;
  border: 2px solid var(--line);
}

.how-body { max-width: 420px; max-height: 90vh; overflow-y: auto; }
.how-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  padding: 0 4px;
}
.how-list li {
  padding-left: 22px;
  position: relative;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-soft);
}
.how-list li::before {
  content: '🐾';
  position: absolute;
  left: 0;
  top: 1px;
  font-size: 12px;
}

/* ---------- 랭킹 모달 ---------- */
.rank-body { max-width: 400px; max-height: calc(100vh - 48px); }
.rank-content {
  min-height: 240px;
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 2px;
}
.rank-loading, .rank-empty, .rank-error {
  padding: 40px 10px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
}
.rank-error { color: var(--accent-dark); }
.rank-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-soft);
  border: 2px solid rgba(58, 41, 32, 0.1);
  border-radius: var(--radius-sm);
  font-size: var(--rank-row-font-size);
}
.rank-row.top1 { background: #FFF4D6; border-color: var(--yellow); }
.rank-row.top2 { background: #F2F2F2; border-color: #B5B5B5; }
.rank-row.top3 { background: #FBE2D5; border-color: #D78A52; }
.rank-row.me { border-color: var(--accent); background: #FFF0EC; }
.rank-pos {
  font-weight: 800;
  font-size: 16px;
  text-align: center;
}
.rank-name {
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.rank-score {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--ink);
}

/* ---------- 랭킹 제출 (게임오버) ---------- */
.rank-submit-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0 4px;
  border-top: 1px dashed rgba(58, 41, 32, 0.15);
  border-bottom: 1px dashed rgba(58, 41, 32, 0.15);
  margin: 4px 0;
}
.rank-submit-row input {
  font: inherit;
  font-size: 15px;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--ink);
  text-align: center;
  font-weight: 700;
  letter-spacing: 0;
}
.rank-submit-row input:focus {
  outline: none;
  border-color: var(--accent);
}
.rank-submit-buttons {
  display: flex;
  gap: 8px;
}
.rank-submit-buttons .btn { flex: 1; padding: 10px 14px; font-size: 14px; }
.rank-submit-buttons .btn-ghost { flex: 0 0 72px; }
.submit-status {
  min-height: 18px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.submit-status.ok { color: var(--sage); }
.submit-status.fail { color: var(--accent-dark); }

.tier-preview {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 4px 0;
}
.tier-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  background: var(--bg-soft);
  border: 2px solid rgba(58, 41, 32, 0.12);
  border-radius: var(--radius-sm);
}
.tier-cell canvas { width: 44px; height: 44px; }
.tier-name { font-size: 10px; color: var(--ink-soft); text-align: center; line-height: 1.2; }

/* ---------- 반응형 ---------- */
@media (max-width: 380px) {
  :root {
    --menu-pad-y: 24px;
    --menu-pad-x: 18px;
    --menu-gap: 22px;
    --title-emoji-size: 60px;
    --title-size: 34px;
    --tagline-size: 14px;
    --best-pad-y: 14px;
    --best-pad-x: 22px;
    --best-min-width: 200px;
    --best-value-size: 30px;
    --menu-btn-max-width: 260px;
    --btn-font-size: 16px;
    --btn-pad-y: 12px;
    --btn-pad-x: 18px;
    --modal-shell-pad: 16px;
    --modal-body-pad-y: 20px;
    --modal-body-pad-x: 16px;
    --modal-gap: 12px;
    --modal-title-size: 22px;
    --final-value-size: 42px;
    --rank-row-font-size: 13px;
  }
  #game {
    --game-pad-x: 8px;
    --stat-value-size: 20px;
    --strip-gap: 3px;
    --strip-padding: 5px;
    --tier-icon-size: 16px;
    --tier-num-size: 8px;
    --tier-name-size: 7px;
    --tier-cell-gap: 2px;
    --tier-cell-pad-y: 2px;
    --tier-cell-pad-x: 3px;
  }
  .tier-preview { grid-template-columns: repeat(3, 1fr); }
  .tier-cell canvas { width: 40px; height: 40px; }
}

@media (orientation: portrait) and (max-width: 720px) {
  #game {
    padding-bottom: calc(var(--mobile-browser-bottom-gap) + env(safe-area-inset-bottom));
  }
}

@media (orientation: portrait) and (max-height: 700px) {
  :root {
    --menu-pad-y: 22px;
    --menu-gap: 20px;
    --title-emoji-size: 58px;
    --title-size: 34px;
    --best-pad-y: 12px;
    --best-value-size: 28px;
    --btn-font-size: 15px;
    --btn-pad-y: 11px;
    --modal-shell-pad: 14px;
    --modal-body-pad-y: 18px;
    --modal-gap: 10px;
    --final-value-size: 40px;
  }
  #game {
    --game-pad-top: 6px;
    --game-gap: 3px;
    --hud-pad-y: 6px;
    --hud-pad-x: 12px;
    --hud-border: 2px;
    --hud-gap: 8px;
    --icon-size: 36px;
    --next-cat-size: 36px;
    --stat-label-size: 9px;
    --stat-value-size: 21px;
    --chip-font-size: 9px;
    --chip-pad-y: 1px;
    --chip-pad-x: 6px;
    --next-name-font-size: 8px;
    --strip-gap: 2px;
    --strip-padding: 4px;
    --tier-icon-size: 14px;
    --tier-num-size: 7px;
    --tier-name-size: 6.5px;
    --tier-cell-gap: 2px;
    --tier-cell-pad-y: 1px;
    --tier-cell-pad-x: 3px;
    --game-hint-font-size: 11px;
  }
  .cat-name-chip {
    min-height: 15px;
    margin-top: 1px;
  }
  .next-stat canvas { margin-top: 1px; }
  .next-cat-name {
    min-height: 11px;
    margin-top: 1px;
  }
  .icon-btn { box-shadow: 0 2px 0 0 var(--line); }
  .game-tier-text { gap: 0; }
}

@media (orientation: portrait) and (max-height: 600px) {
  :root {
    --menu-pad-y: 18px;
    --menu-gap: 16px;
    --title-emoji-size: 52px;
    --title-size: 30px;
    --tagline-size: 13px;
    --best-min-width: 190px;
    --best-value-size: 26px;
    --btn-font-size: 14px;
    --btn-pad-y: 10px;
    --modal-body-pad-y: 16px;
    --modal-title-size: 20px;
    --final-value-size: 36px;
  }
  #game {
    --game-pad-top: 4px;
    --game-pad-x: 8px;
    --game-gap: 2px;
    --hud-pad-y: 4px;
    --hud-pad-x: 10px;
    --hud-gap: 7px;
    --icon-size: 32px;
    --next-cat-size: 32px;
    --stat-label-size: 8px;
    --stat-value-size: 20px;
    --chip-font-size: 8px;
    --next-name-font-size: 7.5px;
    --strip-padding: 3px;
    --tier-icon-size: 13px;
    --tier-num-size: 6.5px;
    --tier-name-size: 6px;
    --game-hint-font-size: 10px;
  }
  .cat-name-chip { max-width: 126px; }
}

@media (orientation: portrait) and (min-width: 390px) and (min-height: 820px) {
  :root {
    --screen-max-width: 430px;
    --screen-max-height: 940px;
    --menu-pad-y: 40px;
    --menu-gap: 32px;
    --title-emoji-size: 84px;
    --title-size: 44px;
    --tagline-size: 16px;
    --best-pad-y: 18px;
    --best-pad-x: 30px;
    --best-value-size: 34px;
    --menu-btn-max-width: 300px;
    --btn-font-size: 18px;
    --modal-body-max-width: 380px;
  }
  #game {
    --game-pad-top: 12px;
    --game-pad-x: 15px;
    --hud-pad-y: 11px;
    --hud-pad-x: 15px;
    --icon-size: 44px;
    --next-cat-size: 50px;
    --stat-value-size: 26px;
    --chip-font-size: 11px;
    --next-name-font-size: 10px;
    --strip-gap: 6px;
    --strip-padding: 7px;
    --tier-icon-size: 20px;
    --tier-num-size: 10px;
    --tier-name-size: 9px;
    --tier-cell-pad-y: 4px;
  }
}

@media (min-width: 720px) {
  /* 태블릿/PC — 세로 게임 영역 유지, 좌우 여백 */
  :root {
    --screen-max-width: 460px;
    --screen-max-height: 920px;
    --menu-pad-y: 48px;
    --menu-pad-x: 32px;
    --menu-gap: 32px;
    --title-emoji-size: 96px;
    --title-size: 48px;
    --tagline-size: 16px;
    --best-pad-y: 18px;
    --best-pad-x: 32px;
    --best-value-size: 36px;
    --menu-btn-max-width: 300px;
    --btn-font-size: 18px;
    --modal-body-max-width: 400px;
    --modal-title-size: 26px;
    --final-value-size: 52px;
  }
}

/* 가로모드에서 경고 (세로 전용 게임) */
@media (orientation: landscape) and (max-height: 500px) {
  #app::before {
    content: '📱 세로 모드에서 플레이해 주세요';
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    color: var(--ink);
    font-weight: 700;
    font-size: 16px;
    z-index: 1000;
  }
}
