:root {
  --paper-0: #fde7c2;
  --paper-1: #fff7e3;
  --ink: #3a2317;
  --ink-dim: #7a5a45;
  --apple-red: #c0271e;
  --apple-deep: #811414;
  --leaf: #3f8c3f;
  --wood: #8b5a2b;
  --wood-deep: #5a3a1a;
  --shadow: 0 12px 32px rgba(60, 30, 0, 0.18);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 50% -10%, #ffe1a8 0%, transparent 60%),
    linear-gradient(180deg, #fff2d4 0%, #fde2b1 100%);
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic UI", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.app {
  max-width: 920px;
  margin: 0 auto;
  padding: 12px 14px 24px;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto 1fr auto;
  gap: 14px;
  min-height: calc(100vh - var(--safe-top) - var(--safe-bottom));
  min-height: calc(100dvh - var(--safe-top) - var(--safe-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  grid-column: 1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
  }

  .topbar-controls { justify-content: flex-end; }
}

.brand-icon {
  font-size: 32px;
  filter: drop-shadow(0 4px 6px rgba(120, 30, 20, 0.3));
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-jp {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--ink);
  margin: 0;
  line-height: 1;
  white-space: nowrap;
}

.brand-en {
  font-size: 10px;
  letter-spacing: 0.28em;
  color: var(--ink-dim);
  margin: 4px 0 0;
  line-height: 1;
}

.hud {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-start;
  grid-column: 1;
}

.hud-cell {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(120, 70, 30, 0.18);
  border-radius: 14px;
  padding: 6px 14px;
  text-align: center;
  min-width: 76px;
  box-shadow: 0 4px 10px rgba(120, 70, 30, 0.08);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.hud-label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.18em;
  font-weight: 700;
  color: var(--ink-dim);
  text-transform: uppercase;
}

.hud-value {
  display: block;
  font-size: 22px;
  font-weight: 900;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.hud-next {
  padding: 4px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.hud-next canvas {
  width: 48px;
  height: 48px;
  display: block;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(120, 70, 30, 0.18);
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(120, 70, 30, 0.08);
  transition: transform 0.12s ease, background 0.2s ease;
  position: relative;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.9); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0); }

.icon-btn .ico-off { display: none; }
.icon-btn.muted .ico-on { display: none; }
.icon-btn.muted .ico-off { display: inline; color: #b94a4a; }

.menu-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.play-area {
  display: flex;
  gap: 14px;
  align-items: stretch;
  justify-content: center;
  flex: 1;
  min-height: 0;
  grid-column: 1;
}

.play-wrap {
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  display: block;
  width: min(100%, 480px);
  aspect-ratio: 480 / 720;
  border-radius: 20px;
  background: var(--paper-1);
  border: 4px solid var(--wood);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.4),
    0 16px 40px rgba(120, 60, 20, 0.25);
  cursor: crosshair;
  touch-action: none;
}

.evolution {
  flex: 0 0 140px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(120, 70, 30, 0.16);
  border-radius: 16px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  overflow: hidden;
}

.evolution h3 {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.2em;
  font-weight: 800;
  color: var(--ink-dim);
  text-align: center;
}

.evolution ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.evo-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  opacity: 0.4;
  transition: opacity 0.3s ease, background 0.3s ease, transform 0.3s ease;
}

.evo-row.reached {
  opacity: 1;
  background: rgba(255, 255, 255, 0.6);
}

.evo-row.just-reached {
  background: rgba(255, 220, 100, 0.7);
  transform: translateX(3px);
}

.evo-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex: 0 0 18px;
  box-shadow:
    inset 2px 2px 4px rgba(255, 255, 255, 0.4),
    0 1px 2px rgba(0, 0, 0, 0.2);
  position: relative;
}
.evo-dot::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 7px;
  width: 2px;
  height: 4px;
  background: var(--wood-deep);
  border-radius: 1px;
}

.evo-name {
  flex: 1;
  font-size: 12px;
}

.evo-num {
  font-size: 10px;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
  min-width: 18px;
  text-align: right;
}

.footer {
  text-align: center;
  font-size: 12px;
  color: var(--ink-dim);
  letter-spacing: 0.05em;
  display: flex;
  flex-direction: column;
  gap: 4px;
  grid-column: 1;
}

.footer .credit {
  font-size: 10px;
  opacity: 0.7;
}

.footer a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(120, 70, 30, 0.4);
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(800px 600px at 50% 40%, rgba(60, 20, 0, 0.45), rgba(40, 20, 0, 0.7));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 16px;
  z-index: 20;
  animation: fadeIn 0.25s ease;
}

.overlay[hidden] { display: none; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.panel {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, #fff7e3, #fde7c2);
  border: 2px solid var(--wood);
  border-radius: 24px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: panelIn 0.4s cubic-bezier(0.2, 1, 0.3, 1);
}

/* Game over modal (スマホ向け): 内容が縦に長いときにスクロールさせる */
#gameOverModal {
  align-items: flex-start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: 20px;
  padding-bottom: 20px;
}

#gameOverModal .panel {
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
}

@keyframes panelIn {
  from { transform: translateY(12px) scale(0.96); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.panel-title {
  margin: 0 0 14px;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--apple-deep);
}

.lead {
  margin: 8px 0 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.big-score {
  font-size: 56px;
  font-weight: 900;
  color: var(--ink);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.lead-label {
  font-size: 11px;
  letter-spacing: 0.24em;
  color: var(--ink-dim);
}

.record {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--apple-red);
  height: 18px;
}

.best-tier-line {
  margin: 4px 0 16px;
  font-size: 13px;
  color: var(--ink-dim);
}

.ranking-panel {
  margin: 16px 0 0;
  text-align: left;
}

.ranking-field {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--ink-dim);
}

.ranking-field span {
  font-weight: 700;
}

.ranking-field input {
  width: 100%;
  border: 1px solid rgba(120, 70, 30, 0.22);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
  box-sizing: border-box;
}

.ranking-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.ranking-projected-rank {
  margin: 0 0 10px;
  min-height: 20px;
  color: var(--apple-red);
  font-size: 13px;
  font-weight: 700;
}

.ranking-status {
  flex: 1;
  font-size: 13px;
  color: var(--ink-dim);
  min-height: 20px;
}

.ranking-list {
  max-height: 240px;
  overflow-y: auto;
  padding: 12px 12px 10px;
  border: 1px solid rgba(120, 70, 30, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
}

.ranking-caption {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--apple-red);
  margin-bottom: 10px;
}

.ranking-entry {
  display: grid;
  grid-template-columns: 32px 1fr 80px;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid rgba(120, 70, 30, 0.08);
}

.ranking-entry:first-child {
  border-top: none;
}

.ranking-pos {
  font-weight: 800;
  color: var(--apple-deep);
}

.ranking-name {
  font-size: 14px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-score {
  font-size: 14px;
  font-weight: 800;
  text-align: right;
  color: var(--ink);
}

.ranking-empty {
  padding: 12px 0;
  color: var(--ink-dim);
  font-size: 13px;
  text-align: center;
}

.btn {
  display: inline-block;
  border: none;
  border-radius: 14px;
  padding: 12px 28px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.05em;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.12s ease, filter 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #d8362a, #a01818);
  box-shadow: 0 8px 22px rgba(160, 24, 24, 0.4);
}

.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(1px); }

.btn-ghost {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(120, 70, 30, 0.2);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.9); }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 4px;
}

.modal-actions .btn { padding: 12px 22px; }

.overlay-home {
  background:
    radial-gradient(900px 500px at 50% 0%, #ffe1a8 0%, transparent 70%),
    linear-gradient(180deg, rgba(255, 242, 212, 0.96) 0%, rgba(253, 226, 177, 0.96) 100%);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: auto;
}

.home-panel {
  max-width: 460px;
  border: 3px solid var(--wood);
  background: linear-gradient(180deg, #fffaef, #fde7c2);
}

.home-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: center;
  margin-bottom: 8px;
}

.home-emoji {
  font-size: 56px;
  filter: drop-shadow(0 6px 12px rgba(120, 30, 20, 0.3));
}

.home-headings { text-align: left; }

.home-title {
  font-size: 36px;
  font-weight: 900;
  color: var(--ink);
  margin: 0;
  letter-spacing: 0.04em;
  line-height: 1;
  white-space: nowrap;
}

.home-sub {
  font-size: 13px;
  letter-spacing: 0.32em;
  color: var(--apple-red);
  font-weight: 800;
  margin: 6px 0 0;
}

.home-desc {
  font-size: 16px;
  color: var(--ink-dim);
  line-height: 1.6;
  margin: 12px 0 24px;
}

.home-desc strong {
  color: var(--apple-deep);
  font-weight: 900;
}

.home-platform-back {
  margin-bottom: 12px;
  text-decoration: none;
}

.home-modes-title {
  font-size: 12px;
  letter-spacing: 0.28em;
  font-weight: 900;
  color: var(--ink-dim);
  margin: 0 0 12px;
  text-transform: uppercase;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

@media (max-width: 480px) {
  .mode-grid { grid-template-columns: 1fr; }
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 12px;
  border-radius: 16px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.55);
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  text-align: center;
  color: var(--ink);
}

.mode-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(120, 60, 20, 0.18);
  background: rgba(255, 255, 255, 0.85);
}

.mode-btn:active { transform: translateY(0); }

.mode-normal { border-color: rgba(63, 140, 63, 0.4); }
.mode-normal:hover { border-color: var(--leaf); box-shadow: 0 10px 24px rgba(63, 140, 63, 0.25); }

.mode-hard { border-color: rgba(192, 39, 30, 0.4); }
.mode-hard:hover { border-color: var(--apple-red); box-shadow: 0 10px 24px rgba(192, 39, 30, 0.3); }

.mode-skull {
  border-color: rgba(40, 40, 50, 0.5);
  background: linear-gradient(135deg, rgba(40, 40, 50, 0.92), rgba(70, 30, 50, 0.92));
  color: #fff;
}
.mode-skull .mode-desc { color: rgba(255, 255, 255, 0.8); }
.mode-skull .mode-best {
  background: rgba(255, 255, 255, 0.15);
  color: #ffd6e8;
}
.mode-skull:hover {
  border-color: #ff5fa2;
  box-shadow: 0 10px 24px rgba(255, 95, 162, 0.4);
}

.mode-icon { font-size: 32px; line-height: 1; }
.mode-name { font-size: 18px; font-weight: 900; letter-spacing: 0.05em; }
.mode-desc { font-size: 11px; color: var(--ink-dim); }
.mode-best {
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 0.18em;
  font-weight: 800;
  color: var(--apple-red);
  background: rgba(192, 39, 30, 0.08);
  padding: 3px 8px;
  border-radius: 999px;
}

.home-footnote {
  font-size: 11px;
  color: var(--ink-dim);
  line-height: 1.6;
  margin: 0;
  opacity: 0.8;
}

.score-pop-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.score-pop {
  position: absolute;
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  text-shadow:
    -2px 0 0 var(--apple-deep), 2px 0 0 var(--apple-deep),
    0 -2px 0 var(--apple-deep), 0 2px 0 var(--apple-deep),
    0 4px 12px rgba(0, 0, 0, 0.4);
  letter-spacing: 0.04em;
  animation: scorePop 0.9s cubic-bezier(0.18, 1.24, 0.4, 1) forwards;
  pointer-events: none;
  white-space: nowrap;
  transform: translate(-50%, -50%);
}

@keyframes scorePop {
  0%   { opacity: 0; transform: translate(-50%, -30%) scale(0.6); }
  20%  { opacity: 1; transform: translate(-50%, -55%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -130%) scale(0.95); }
}

.horror-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 50;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 18px;
  animation: horrorEnter 0.18s steps(2) forwards;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.horror-overlay:fullscreen {
  background: #000;
  width: 100vw;
  height: 100vh;
}

.horror-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  z-index: 0;
  pointer-events: none;
}

.horror-overlay[hidden] { display: none; }

@keyframes horrorEnter {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

.horror-noise {
  position: absolute;
  inset: -10%;
  background-image:
    repeating-linear-gradient(0deg, rgba(255, 30, 30, 0.06) 0 2px, transparent 2px 5px),
    radial-gradient(circle at 20% 30%, rgba(255, 50, 50, 0.18), transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(120, 0, 30, 0.4), transparent 60%);
  mix-blend-mode: screen;
  pointer-events: none;
  animation: horrorJitter 0.06s steps(2) infinite;
  filter: contrast(1.4);
}

@keyframes horrorJitter {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-3px, 2px); }
  50%  { transform: translate(2px, -3px); }
  75%  { transform: translate(-2px, -1px); }
  100% { transform: translate(1px, 1px); }
}

.horror-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  padding: 24px;
  animation: horrorShake 0.12s steps(3) infinite;
}

.horror-overlay.has-video .horror-noise,
.horror-overlay.has-video .horror-skull,
.horror-overlay.has-video .horror-text {
  display: none;
}

.horror-overlay.has-video .horror-content {
  position: absolute;
  top: max(20px, calc(env(safe-area-inset-top, 0px) + 12px));
  right: max(20px, calc(env(safe-area-inset-right, 0px) + 12px));
  z-index: 10;
  padding: 0;
  animation: none;
  pointer-events: none;
}

.horror-overlay.has-video .horror-close {
  pointer-events: auto;
}

.horror-tap-hint {
  position: absolute;
  bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 12px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  color: rgba(255, 220, 220, 0.7);
  font-size: 12px;
  letter-spacing: 0.24em;
  font-weight: 700;
  pointer-events: none;
  animation: horrorBlink 1.4s steps(2) infinite;
  text-shadow: 0 0 10px rgba(255, 60, 60, 0.6);
}

.horror-overlay:not(.has-video) .horror-tap-hint { display: none; }

@keyframes horrorBlink {
  0%, 100% { opacity: 0.95; }
  50%      { opacity: 0.35; }
}

@keyframes horrorShake {
  0%   { transform: translate(0, 0) rotate(0deg); }
  33%  { transform: translate(2px, -1px) rotate(-0.4deg); }
  66%  { transform: translate(-2px, 1px) rotate(0.4deg); }
  100% { transform: translate(1px, 0) rotate(0deg); }
}

.horror-skull {
  font-size: 220px;
  line-height: 1;
  filter:
    drop-shadow(0 0 32px rgba(255, 60, 60, 0.7))
    drop-shadow(0 0 64px rgba(120, 0, 0, 0.5));
  animation: horrorBreath 1.4s ease-in-out infinite;
}

@keyframes horrorBreath {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

.horror-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: "Hiragino Sans", "Yu Gothic UI", system-ui, sans-serif;
}

.horror-line-1 {
  font-size: 38px;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: #ff3838;
  text-shadow:
    0 0 12px rgba(255, 50, 50, 0.7),
    0 0 32px rgba(180, 0, 0, 0.5),
    -2px 2px 0 #1a0008,
    2px 2px 0 #1a0008;
}

.horror-line-2 {
  font-size: 56px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow:
    0 0 18px rgba(255, 30, 30, 0.9),
    0 0 36px rgba(255, 0, 0, 0.6),
    -3px 3px 0 #6b0010;
}

.horror-line-3 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.32em;
  color: rgba(255, 220, 220, 0.7);
  margin-top: 4px;
}

.horror-close {
  margin-top: 16px;
  background: linear-gradient(180deg, #2a0010, #6b0010);
  color: #fff;
  border: 1px solid rgba(255, 80, 80, 0.5);
  border-radius: 14px;
  padding: 14px 30px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.22em;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 0 28px rgba(255, 30, 30, 0.55), 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: filter 0.2s ease, transform 0.15s ease;
  min-width: 88px;
  min-height: 44px;
}
.horror-close:hover { filter: brightness(1.25); }
.horror-close:active { transform: scale(0.96); }

@media (max-width: 480px) {
  .horror-skull { font-size: 140px; }
  .horror-line-1 { font-size: 26px; }
  .horror-line-2 { font-size: 38px; }
  .horror-line-3 { font-size: 16px; }
  .horror-close {
    padding: 16px 26px;
    font-size: 17px;
    min-height: 52px;
  }
  .horror-tap-hint { font-size: 11px; }
}

@media (max-width: 640px) {
  .app {
    display: flex;
    flex-direction: column;
    padding: 8px 10px 16px;
    gap: 8px;
  }
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .topbar-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
  }
  .hud {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .brand-icon { font-size: 26px; }
  .brand-jp { font-size: 18px; }
  .brand-en { font-size: 9px; letter-spacing: 0.22em; }
  .hud-cell { min-width: 60px; padding: 4px 10px; }
  .hud-value { font-size: 18px; }
  .hud-next canvas { width: 40px; height: 40px; }
  .icon-btn { width: 40px; height: 40px; }
  .play-area { gap: 8px; }
  .evolution {
    flex: 0 0 110px;
    padding: 8px 6px;
  }
  .evo-row { gap: 6px; padding: 2px 4px; font-size: 11px; }
  .evo-name { font-size: 11px; }
  .evo-dot { width: 14px; height: 14px; flex-basis: 14px; }
  .overlay-home {
    align-items: flex-start;
    padding-top: 24px;
    padding-bottom: 24px;
  }

  .home-panel {
    width: 100%;
  }
  .home-title-row {
    justify-content: flex-start;
    align-items: flex-start;
  }
  .home-emoji {
    margin-top: 4px;
  }
  .home-title { max-width: none; }
}

@media (max-width: 480px) {
  .evolution {
    flex: 0 0 96px;
  }
  .evo-name { display: none; }
  .evo-row { justify-content: center; }
}

.menu-container {
  position: relative;
}

.menu-dropdown {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(120, 70, 30, 0.18);
  border-radius: 20px;
  min-width: min(320px, calc(100vw - 40px));
  box-shadow: 0 8px 24px rgba(120, 70, 30, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: hidden;
  z-index: 1000;
}

.menu-item {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  border-bottom: 1px solid rgba(120, 70, 30, 0.1);
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item:hover {
  background: rgba(192, 39, 30, 0.1);
  color: var(--apple-red);
}

.menu-item:active {
  background: rgba(192, 39, 30, 0.2);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
