:root {
  color-scheme: dark;
  --bg-1: #040816;
  --bg-2: #0c1f47;
  --panel: rgba(8, 15, 33, 0.78);
  --panel-border: rgba(164, 207, 255, 0.2);
  --text: #f5f7ff;
  --muted: #9bb4df;
  --accent: #8be3ff;
  --accent-2: #ffd86b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Pretendard", "Noto Sans KR", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(88, 132, 255, 0.32), transparent 30%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 65%, #010308 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.02) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.02) 50%, rgba(255, 255, 255, 0.02) 75%, transparent 75%, transparent);
  background-size: 40px 40px;
  opacity: 0.15;
  pointer-events: none;
}

.page-shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 24px auto;
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(340px, 430px);
  gap: 20px;
  align-items: start;
}

.game-panel,
.leaderboard-panel {
  position: relative;
  z-index: 1;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(14px);
}

.game-panel {
  padding: 24px;
}

.leaderboard-panel {
  padding: 22px 18px;
}

.panel-head,
.leaderboard-head {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: start;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  font-weight: 700;
}

.panel-head .eyebrow {
  font-size: 18px;
  letter-spacing: 0.08em;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: clamp(28px, 4vw, 38px);
  max-width: 12ch;
}

h2 {
  font-size: 26px;
}

h3 {
  font-size: 17px;
  color: #ffffff;
}

.profile-box {
  min-width: 220px;
}

.profile-box label,
.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.profile-meta {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
}

.profile-meta span {
  color: var(--muted);
  font-size: 14px;
}

input,
button {
  font: inherit;
}

#open-start-modal
#start-game,
#retry-game,
#open-game-picker,
#quit-before-start {
  min-height: 58px;
  padding: 16px 24px;
  font-size: 17px;
  box-shadow: 0 16px 32px rgba(139, 227, 255, 0.2);
}

#open-start-modal {
  min-width: 220px;
  font-size: 18px;
  background: linear-gradient(135deg, #ffd86b 0%, #fff4a8 100%);
}

input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  color: #08111f;
  background: linear-gradient(135deg, var(--accent) 0%, #b8f5ff 100%);
  cursor: pointer;
}

button:hover {
  filter: brightness(1.05);
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.3);
  opacity: 0.65;
}

button.ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.hud {
  margin: 20px 0 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.hud strong {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
}

.hud #player-hud {
  white-space: normal;
  line-height: 1.35;
}

.hud #org-hud,
.hud #state {
  display: none;
}

.canvas-frame {
  position: relative;
  max-width: 780px;
  margin: 0 auto;
  padding: 16px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(104, 148, 255, 0.24), rgba(5, 12, 24, 0.32));
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  user-select: none;
  border-radius: 18px;
  border: 1px solid rgba(176, 219, 255, 0.28);
  background: linear-gradient(180deg, #4b74ff 0%, #1b295d 48%, #07101f 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.mobile-controls {
  display: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.mobile-controls.quad {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mobile-controls.arrow-pad {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.touch-button {
  min-height: 56px;
  border-radius: 18px;
  touch-action: manipulation;
  user-select: none;
}

.touch-spacer {
  min-height: 56px;
  visibility: hidden;
}

.touch-button.jump {
  background: linear-gradient(135deg, #ffd86b 0%, #fff0b5 100%);
}

.touch-button {
  position: relative;
  font-size: 0;
  color: transparent;
  text-indent: -9999px;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

.touch-button::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 28px;
  height: 28px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  pointer-events: none;
}

.touch-button[data-control="left"]::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath fill='%2308111f' d='M19.5 6 9 16l10.5 10 2.5-2.6-7.8-7.4 7.8-7.4z'/%3E%3C/svg%3E"); }
.touch-button[data-control="right"]::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath fill='%2308111f' d='m12.5 6-2.5 2.6 7.8 7.4-7.8 7.4 2.5 2.6L23 16z'/%3E%3C/svg%3E"); }
.touch-button[data-control="up"]::before, .touch-button.jump::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath fill='%2308111f' d='m16 8 10 10-2.6 2.5-7.4-7.8-7.4 7.8L6 18z'/%3E%3C/svg%3E"); }
.touch-button[data-control="down"]::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath fill='%2308111f' d='m6 14 2.6-2.5 7.4 7.8 7.4-7.8L26 14 16 24z'/%3E%3C/svg%3E"); }
.touch-button[data-control="attack"]::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath fill='%2308111f' d='M22.8 4.8 27 9l-3 3-2.4-2.4-4.3 4.3 1.4 1.4-2.1 2.1-1.4-1.4-7.5 7.5-2.8.7.7-2.8 7.5-7.5-1.4-1.4 2.1-2.1 1.4 1.4 4.3-4.3L17 6z'/%3E%3C/svg%3E"); }
.touch-button[data-control="special"]::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath fill='%2308111f' d='m16 4 3.1 8.1L28 15l-8.9 2.9L16 26l-3.1-8.1L4 15l8.9-2.9z'/%3E%3C/svg%3E"); }
.canvas-action-controls {
  display: none;
}

.touch-button--ghost {
  width: 78px;
  min-height: 78px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.24);
}

body.is-playing-game .page-shell { width: min(100vw - 20px, 760px); margin: 6px auto; grid-template-columns: 1fr; }
body.is-playing-game .leaderboard-panel,
body.is-playing-game .panel-head,
body.is-playing-game .game-intro-card,
body.is-playing-game .guide-card,
body.is-playing-game .coin-legend,
body.is-playing-game .my-stats-card { display: none; }
body.is-playing-game .game-panel { padding: 8px; }
body.is-playing-game .hud { margin: 0 0 8px; }
body.is-playing-game .canvas-frame { max-width: 720px; padding: 8px; }
body.is-playing-game .mobile-controls { display: grid; }

.guide-card {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.guide-card p {
  margin: 6px 0;
}

.game-intro-card {
  margin-top: 16px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
}

.intro-copy {
  color: var(--muted);
}

.intro-copy {
  margin: 12px 0 0;
}

.page-start-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-start;
}

.panel-head h1,
.game-intro-card h2 {
  font-size: 17px;
  max-width: none;
}

.coin-legend,
.my-stats-card {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
}

.coin-legend-grid,
.my-stats-grid {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.coin-legend-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.coin-legend-item {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
}

.coin-legend-item img {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
}

.card-header {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
}

.my-stats-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.my-stats-grid div {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.stats-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sync-status {
  margin: 14px 0;
  color: var(--muted);
  font-size: 14px;
}

.rank-section + .rank-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.leaderboard-list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  max-height: 520px;
  overflow: auto;
}

.leaderboard-list.secondary {
  max-height: 520px;
}

.leaderboard-item {
  display: grid;
  grid-template-columns: 76px 50px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.leaderboard-item.top3 {
  background: linear-gradient(135deg, rgba(255, 216, 107, 0.2), rgba(139, 227, 255, 0.08));
  border-color: rgba(255, 216, 107, 0.25);
}

.leaderboard-rank {
  display: flex;
  align-items: center;
  color: var(--accent-2);
  font-weight: 800;
}

.leaderboard-name {
  line-height: 1.2;
}

.leaderboard-name small {
  color: var(--muted);
}
.tier-emblem {
  display: inline-block;
  width: 39px;
  height: 39px;
  vertical-align: middle;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.tier-deities {
  background-image: url("../../images/rank-tier-deities.svg");
}

.tier-legends {
  background-image: url("../../images/rank-tier-legends.svg");
}

.tier-elites {
  background-image: url("../../images/rank-tier-elites.svg");
}

.tier-guardians {
  background-image: url("../../images/rank-tier-guardians.svg");
}

.tier-challengers {
  background-image: url("../../images/rank-tier-challengers.svg");
}

.rank-tier-legend {
  margin: 12px 0 16px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.rank-tier-legend h3 {
  margin: 0 0 10px;
}

.rank-tier-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
}

.rank-tier-grid span {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.leaderboard-score {
  color: var(--accent);
  font-weight: 700;
}

.overlay-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 8, 20, 0.78);
  backdrop-filter: blur(8px);
}

.overlay-modal.hidden {
  display: none;
}

.overlay-card {
  width: min(100%, 620px);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 26px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(17, 29, 61, 0.98), rgba(7, 12, 28, 0.96));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.overlay-card input + .field-label,
.overlay-card .field-label + input {
  margin-top: 10px;
}

.overlay-card h2 {
  margin-bottom: 14px;
  font-size: clamp(0.72rem, 2.2vw, 1rem);
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.overlay-copy {
  margin: 0 0 14px;
  color: var(--muted);
}

.modal-guide-card {
  margin: 14px 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.modal-guide-card p {
  margin: 8px 0 0;
  color: var(--muted);
}

.modal-coin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.modal-coin-grid .coin-legend-item {
  align-items: flex-start;
  min-width: 0;
}

.modal-coin-grid .coin-legend-item span {
  line-height: 1.35;
}

.result-summary {
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.result-summary p {
  margin: 0;
  padding: 12px 14px;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4em;
  flex: 0 1 auto;
  max-width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(135deg, rgba(139, 227, 255, 0.12), rgba(255, 216, 107, 0.12));
  color: #f4f8ff;
  font-weight: 700;
  line-height: 1.4;
}

.result-summary-label {
  color: rgba(244, 248, 255, 0.72);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-summary-main {
  display: block;
  font-size: clamp(1.05rem, 2.5vw, 1.28rem);
  line-height: 1.15;
}

.result-summary-meta {
  display: block;
  line-height: 1.4;
}

.result-score-value {
  color: #8be3ff;
}

.result-score-muted {
  color: rgba(244, 248, 255, 0.72);
}

.result-rank-value,
.result-rank-miss {
  color: #ffd86b;
}

.result-meta-label {
  display: inline-block;
  margin-right: 0.38em;
  color: rgba(244, 248, 255, 0.76);
}

.result-tier-value {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  color: #f4f8ff;
}

.result-tier-value .tier-emblem {
  width: 1.8em;
  height: 1.8em;
}

.overlay-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.overlay-actions > * {
  width: 100%;
  min-width: 0;
}

.overlay-actions--start {
  margin-top: 18px;
}

.overlay-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.overlay-head h2 {
  margin-bottom: 0;
  white-space: normal;
}

.modal-close-button {
  flex: 0 0 auto;
}

.overlay-status {
  margin: 14px 0 0;
}

.overlay-status[hidden] {
  display: none !important;
}

.other-game-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.game-picker-link {
  display: block;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.game-picker-link:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
}

.game-picker-link strong {
  display: block;
  margin-bottom: 6px;
  color: #ffffff;
}

.game-picker-link span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.share-card {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.share-copy,
.share-status {
  margin: 10px 0 0;
  color: var(--muted);
}

.share-preview {
  display: block;
  width: 100%;
  margin-top: 12px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
}

.share-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.modal-ranking-grid {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.rank-section.compact {
  margin-top: 0;
  padding: 14px 14px 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
}

.rank-section.compact + .rank-section.compact {
  margin-top: 0;
}

.modal-ranking-grid .leaderboard-list {
  max-height: 152px;
}

.gameover-ad {
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.start-ad-wrap {
  margin-top: 14px;
  margin-bottom: 0;
}

.other-game-ad-wrap {
  margin-top: 18px;
  margin-bottom: 0;
}

.page-ad-wrap {
  margin: 16px 0;
}

.game-adsense {
  display: block;
  width: 100%;
  min-height: 120px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
}

@media (max-width: 980px) {
  .page-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 18px, 100%);
    margin: 10px auto;
    gap: 12px;
  }

  .game-panel,
  .leaderboard-panel {
    border-radius: 20px;
  }

  .game-panel {
    padding: 16px;
  }

  .panel-head,
  .leaderboard-head {
    flex-direction: column;
  }

  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-controls {
    display: grid;
  }

  .coin-legend-grid,
  .my-stats-grid,
  .share-grid {
    grid-template-columns: 1fr;
  }

  .overlay-modal {
    place-items: start center;
    padding: 8px;
  }

  .overlay-card {
    width: min(100%, 520px);
    max-height: calc(100dvh - 16px);
    padding: 16px;
  }

  .overlay-actions {
    gap: 8px;
  }

  .modal-coin-grid {
    gap: 8px;
  }

  .modal-coin-grid .coin-legend-item img {
    width: 32px;
    height: 32px;
  }

  .other-game-grid {
    grid-template-columns: 1fr;
  }

  .gameover-ad,
  .start-ad-wrap,
  .other-game-ad-wrap {
    padding: 10px;
  }

  .game-adsense {
    min-height: 92px;
  }

}

html,
body,
canvas,
.game-panel,
.game-panel *,
.canvas-frame {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body.touch-canvas-mode {
  touch-action: manipulation;
}

body.touch-canvas-mode canvas {
  touch-action: none;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

body.touch-canvas-mode.is-playing-game {
  overflow: hidden;
  background: #020611;
}

body.touch-canvas-mode.is-playing-game .page-shell,
body.touch-canvas-mode.is-playing-game .game-panel {
  width: 100vw;
  max-width: none;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

body.touch-canvas-mode.is-playing-game .leaderboard-panel,
body.touch-canvas-mode.is-playing-game .panel-head,
body.touch-canvas-mode.is-playing-game .game-intro-card,
body.touch-canvas-mode.is-playing-game .guide-card,
body.touch-canvas-mode.is-playing-game .coin-legend,
body.touch-canvas-mode.is-playing-game .my-stats-card,
body.touch-canvas-mode.is-playing-game .page-ad-wrap,
body.touch-canvas-mode.is-playing-game .mobile-controls,
body.touch-canvas-mode.is-playing-game .card-header {
  display: none !important;
}

body.touch-canvas-mode.is-playing-game .hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  margin: 0;
  padding: max(10px, env(safe-area-inset-top)) 10px 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  pointer-events: none;
}

body.touch-canvas-mode.is-playing-game .hud strong {
  padding: 10px 12px;
  font-size: 13px;
  background: rgba(4, 10, 24, 0.72);
  backdrop-filter: blur(10px);
}

body.touch-canvas-mode.is-playing-game .canvas-frame {
  position: fixed;
  inset: 0;
  z-index: 1;
  max-width: none;
  padding: 0;
  border-radius: 0;
  background: #020611;
}

body.touch-canvas-mode.is-playing-game canvas {
  width: 100vw;
  height: 100dvh;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

body.touch-canvas-mode.is-playing-game .canvas-action-controls {
  position: fixed;
  right: max(16px, calc(env(safe-area-inset-right) + 10px));
  bottom: max(22px, calc(env(safe-area-inset-bottom) + 18px));
  z-index: 7;
  display: flex;
  pointer-events: auto;
}


body.is-playing-game .page-ad-wrap {
  display: none !important;
}

.result-tier-empty {
  min-width: 1.2em;
  justify-content: center;
}

.mobile-ranking-dock {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 65;
  display: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.mobile-ranking-dock[hidden] {
  display: none !important;
}

.mobile-ranking-actions {
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.mobile-ranking-dock.expanded .mobile-ranking-actions {
  display: flex;
}

.mobile-ranking-action {
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  color: var(--text);
  background: rgba(7, 15, 30, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.28);
}

.mobile-ranking-toggle {
  min-width: 132px;
  min-height: 54px;
  border-radius: 999px;
  padding: 14px 18px;
  box-shadow: 0 16px 32px rgba(139, 227, 255, 0.26);
}

.mobile-ranking-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: end center;
  padding: 14px;
  background: rgba(3, 8, 20, 0.8);
  backdrop-filter: blur(8px);
}

.mobile-ranking-modal.hidden {
  display: none;
}

.mobile-ranking-card {
  width: min(100%, 440px);
  max-height: min(80vh, 620px);
  overflow: auto;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(17, 29, 61, 0.98), rgba(7, 12, 28, 0.96));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.mobile-ranking-head {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
}

.mobile-ranking-list {
  max-height: min(48vh, 460px);
}

.mobile-ranking-ad-wrap {
  margin-top: 14px;
  margin-bottom: 0;
}

@media (min-width: 721px) {
  .mobile-ranking-dock,
  .mobile-ranking-modal {
    display: none !important;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 14px;
  }

  .leaderboard-panel,
  .modal-ranking-grid,
  .overlay-modal .rank-tier-legend {
    display: none !important;
  }

  .mobile-ranking-dock {
    display: flex;
  }

  .page-shell {
    width: min(100vw - 14px, 100%);
    gap: 10px;
  }

  .game-panel {
    padding: 14px;
  }

  .panel-head .eyebrow {
    font-size: 14px;
  }

  h1 {
    font-size: clamp(22px, 7vw, 28px);
  }

  h2 {
    font-size: 18px;
  }

  h3 {
    font-size: 15px;
  }

  .guide-card,
  .game-intro-card,
  .coin-legend,
  .my-stats-card {
    padding: 14px;
  }

  .intro-copy,
  .guide-card p,
  .coin-legend-item span,
  .overlay-copy,
  .sync-status,
  .leaderboard-name,
  .leaderboard-name small {
    font-size: 13px;
  }

  .profile-box label,
  .field-label,
  .profile-meta span,
  .stats-label,
  .rank-tier-grid span {
    font-size: 11px;
  }

  .hud strong {
    font-size: 12px;
  }

  button,
  input {
    font-size: 14px;
  }

  #open-start-modal,
  #start-game,
  #retry-game,
  #open-game-picker,
  #quit-before-start {
    min-height: 50px;
    padding: 14px 18px;
    font-size: 15px;
  }

  .overlay-card {
    padding: 18px;
    border-radius: 18px;
  }

  .overlay-card h2 {
    font-size: clamp(0.9rem, 4vw, 1.08rem);
    white-space: normal;
  }

  .result-summary p,
  .leaderboard-item {
    font-size: 13px;
  }

  .leaderboard-item {
    grid-template-columns: 68px 42px minmax(0, 1fr) auto;
    gap: 8px;
    padding: 9px 10px;
  }

  .tier-emblem {
    width: 34px;
    height: 34px;
  }

  .game-adsense {
    min-height: 92px;
  }
}
/* mobile-density-20260505a */
.my-stats-card {
  display: none !important;
}

@media (max-width: 720px) {
  body {
    font-size: 12px;
  }

  .page-shell {
    width: min(100vw - 8px, 100%);
    gap: 8px;
    margin: 8px auto;
  }

  .game-panel,
  .leaderboard-panel {
    border-radius: 16px;
  }

  .game-panel {
    padding: 11px;
  }

  .panel-head {
    gap: 10px;
  }

  .panel-head .eyebrow {
    font-size: 12px;
  }

  h1 {
    font-size: clamp(19px, 6.2vw, 24px);
  }

  h2 {
    font-size: 16px;
  }

  h3 {
    font-size: 13px;
  }

  .guide-card,
  .game-intro-card,
  .coin-legend {
    padding: 11px;
    margin-top: 12px;
  }

  .intro-copy,
  .guide-card p,
  .coin-legend-item span,
  .overlay-copy,
  .sync-status,
  .leaderboard-name,
  .leaderboard-name small,
  .game-picker-link span {
    font-size: 12px;
    line-height: 1.45;
  }

  .profile-box label,
  .field-label,
  .profile-meta span,
  .stats-label,
  .rank-tier-grid span,
  .result-summary-label {
    font-size: 10px;
  }

  .profile-meta,
  input,
  .hud strong,
  .leaderboard-item,
  .result-summary p,
  .game-picker-link {
    border-radius: 12px;
  }

  .profile-meta,
  input {
    padding: 10px 12px;
  }

  .hud {
    margin: 16px 0 12px;
    gap: 8px;
  }

  .hud strong {
    padding: 10px 11px;
    font-size: 11px;
  }

  button,
  input {
    font-size: 12px;
  }

  #open-start-modal,
  #start-game,
  #retry-game,
  #open-game-picker,
  #quit-before-start {
    min-height: 44px;
    padding: 11px 14px;
    font-size: 13px;
  }

  .canvas-frame {
    padding: 10px;
    border-radius: 18px;
  }

  .overlay-card,
  .mobile-ranking-card {
    padding: 14px;
    border-radius: 16px;
  }

  .overlay-card h2 {
    font-size: clamp(0.82rem, 3.5vw, 0.98rem);
  }

  .overlay-actions {
    gap: 7px;
  }

  .modal-guide-card,
  .share-card,
  .rank-section.compact,
  .gameover-ad,
  .start-ad-wrap,
  .other-game-ad-wrap {
    padding: 10px;
    border-radius: 12px;
  }

  .modal-coin-grid .coin-legend-item img {
    width: 28px;
    height: 28px;
  }

  .result-summary p,
  .leaderboard-item {
    font-size: 12px;
  }

  .leaderboard-item {
    grid-template-columns: 60px 36px minmax(0, 1fr) auto;
    gap: 6px;
    padding: 8px;
  }

  .tier-emblem {
    width: 30px;
    height: 30px;
  }

  .mobile-ranking-head {
    gap: 8px;
  }

  .mobile-ranking-list {
    max-height: min(42vh, 360px);
  }

  .mobile-ranking-action,
  .mobile-ranking-toggle,
  .mobile-ranking-close,
  .modal-close-button {
    font-size: 12px;
  }

  .game-adsense {
    min-height: 78px;
  }
}
