/* ==========================================================
   Nyan Hero · 彩虹英雄 · 全局样式
   - 响应式 + 横竖屏 + UI 界面
   ========================================================== */

/* ---------- 重置 ---------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue",
               "Segoe UI", Roboto, "Microsoft YaHei", sans-serif;
  color: #fff;
  touch-action: manipulation;
  overscroll-behavior: none;
}

/* ---------- 应用根容器 ---------- */
.app {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #0b0420;
}

/* canvas 自适应: 竖屏高宽比 9:16, 横屏 16:9 */
.game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #0b0420;
  /* canvas 元素需要被其他 UI 元素叠加, 这里 z-index 较低 */
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* ---------- 屏幕层 ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- 通用按钮 ---------- */
.btn-primary, .btn-secondary, .opt-btn, .save-btn, .hud-btn {
  font: inherit;
  border: none;
  outline: none;
  cursor: pointer;
  border-radius: 14px;
  padding: 14px 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary:active,
.btn-secondary:active,
.opt-btn:active,
.save-btn:active,
.hud-btn:active {
  transform: scale(0.96);
}

.btn-primary {
  font-size: 18px;
  width: 100%;
  padding: 16px;
  margin-top: 18px;
  background: linear-gradient(135deg, #ff5f9e 0%, #ff8a5b 30%, #ffd24c 60%, #5ce1ff 100%);
  color: #1a0033;
  box-shadow:
    0 4px 0 rgba(0,0,0,0.2),
    0 8px 24px rgba(255,95,158,0.4),
    inset 0 -4px 0 rgba(0,0,0,0.1),
    inset 0 1px 0 rgba(255,255,255,0.5);
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-secondary {
  font-size: 16px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 2px solid rgba(255,255,255,0.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.btn-secondary:hover { background: rgba(255,255,255,0.2); }

/* =========================================================
   主菜单
   ========================================================= */
.screen-menu {
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
}
.screen-menu::-webkit-scrollbar { display: none; }

.menu-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255,95,158,0.25), transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(92,225,255,0.25), transparent 50%),
    linear-gradient(180deg, #0b0420 0%, #1a0a3e 50%, #0b0420 100%);
  z-index: -1;
}

.menu-content {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 24px 16px 32px;
  text-align: center;
}

.title {
  font-size: 56px;
  font-weight: 900;
  letter-spacing: 2px;
  line-height: 1;
  margin-bottom: 8px;
  display: flex;
  justify-content: center;
  gap: 8px;
  animation: titleFloat 3s ease-in-out infinite;
}
.title-nyan {
  background: linear-gradient(180deg, #ff5f9e, #ff8a5b);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 8px rgba(255,95,158,0.4));
}
.title-hero {
  background: linear-gradient(180deg, #5ce1ff, #b388ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 8px rgba(92,225,255,0.4));
}
@keyframes titleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.subtitle {
  font-size: 14px;
  opacity: 0.8;
  margin-bottom: 24px;
  letter-spacing: 4px;
}

/* 选择器 */
.picker {
  margin-bottom: 16px;
}
.picker-label {
  font-size: 13px;
  opacity: 0.8;
  margin-bottom: 8px;
  letter-spacing: 2px;
}
.picker-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.picker-card {
  width: 76px;
  height: 96px;
  border-radius: 14px;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  padding: 6px 4px;
}
.picker-card:hover {
  background: rgba(255,255,255,0.14);
  transform: translateY(-2px);
}
.picker-card.selected {
  border-color: #ffd24c;
  background: rgba(255,210,76,0.15);
  box-shadow: 0 0 0 3px rgba(255,210,76,0.25), 0 8px 20px rgba(255,210,76,0.3);
}
.picker-card.selected::after {
  content: "✓";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  background: #ffd24c;
  color: #1a0033;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}
.picker-card .pc-emoji {
  font-size: 36px;
  line-height: 1;
  margin-bottom: 4px;
}
.picker-card .pc-name {
  font-size: 11px;
  opacity: 0.9;
  letter-spacing: 0.5px;
}

/* 最高分 */
.best-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(0,0,0,0.25);
  border-radius: 12px;
  margin-bottom: 12px;
}
.best-label { opacity: 0.7; font-size: 13px; }
.best-value { font-size: 22px; font-weight: 900; color: #ffd24c; }

/* 选项按钮 */
.opts-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.opt-btn {
  flex: 1;
  padding: 12px;
  font-size: 14px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
}

/* 存档行 */
.save-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.save-btn {
  flex: 1;
  padding: 10px;
  font-size: 13px;
  background: rgba(92,225,255,0.15);
  color: #5ce1ff;
  border: 1px solid rgba(92,225,255,0.3);
}

.hint {
  margin-top: 16px;
  font-size: 12px;
  opacity: 0.55;
  letter-spacing: 1px;
}

/* 版本号显示 */
.version-label {
  margin-top: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  opacity: 0.5;
  color: #ffd24c;
  font-family: monospace;
}

/* =========================================================
   游戏内 HUD
   ========================================================= */
.screen-hud {
  z-index: 15;
  pointer-events: none;
  align-items: flex-start;
  justify-content: stretch;
  flex-direction: column;
}
.screen-hud > * { pointer-events: auto; }

.hud-top {
  width: 100%;
  display: flex;
  align-items: center;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  gap: 10px;
  background: linear-gradient(180deg, rgba(0,0,0,0.45), transparent);
}

.hud-score, .hud-best, .hud-difficulty {
  background: rgba(0,0,0,0.5);
  padding: 6px 12px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.hud-label { font-size: 10px; opacity: 0.7; letter-spacing: 1px; }
.hud-value { font-size: 22px; font-weight: 900; color: #ffd24c; line-height: 1; }
.hud-value-sm { font-size: 14px; font-weight: 700; color: #fff; line-height: 1; }

.hud-combo {
  background: linear-gradient(135deg, #ff5f9e, #ff8a5b);
  padding: 6px 12px;
  border-radius: 10px;
  font-weight: 900;
  font-size: 16px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(255,95,158,0.4);
  animation: comboPop 0.3s ease;
}
@keyframes comboPop {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.hud-btn {
  margin-left: auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 18px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* =========================================================
   浮层(暂停 / 结算 / 音频门)
   ========================================================= */
.screen-overlay {
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 30;
}

.overlay-card {
  width: 88%;
  max-width: 360px;
  padding: 28px 22px;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(40,20,80,0.95), rgba(15,8,40,0.95));
  border: 2px solid rgba(255,255,255,0.15);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  text-align: center;
  animation: cardIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes cardIn {
  0% { transform: scale(0.6) translateY(20px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.overlay-card h2 {
  font-size: 28px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #ff5f9e, #ffd24c, #5ce1ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.overlay-desc { font-size: 14px; opacity: 0.7; margin-bottom: 16px; line-height: 1.5; }

.overlay-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}
.overlay-stats > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255,255,255,0.06);
  border-radius: 12px;
}
.overlay-stats span { opacity: 0.7; font-size: 14px; }
.overlay-stats strong { font-size: 22px; color: #ffd24c; font-weight: 900; }
.overlay-stats-large strong { font-size: 26px; }

.over-badge {
  display: inline-block;
  margin-bottom: 12px;
  padding: 8px 16px;
  border-radius: 20px;
  background: linear-gradient(135deg, #ffd24c, #ff8a5b);
  color: #1a0033;
  font-weight: 900;
  font-size: 14px;
  animation: badgePulse 1s ease-in-out infinite;
}
@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.overlay-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* =========================================================
   屏幕方向
   ========================================================= */
/* 横屏时主菜单内容居中变小,HUD 不变 */
.app[data-orientation="landscape"] .menu-content {
  max-width: 600px;
  padding: 16px 32px;
}
.app[data-orientation="landscape"] .title { font-size: 44px; }
.app[data-orientation="landscape"] .picker-card { width: 80px; height: 88px; }
.app[data-orientation="landscape"] .picker-card .pc-emoji { font-size: 32px; }

/* =========================================================
   响应式
   ========================================================= */
@media (max-width: 360px) {
  .title { font-size: 44px; }
  .picker-card { width: 68px; height: 88px; }
  .picker-card .pc-emoji { font-size: 30px; }
  .picker-card .pc-name { font-size: 10px; }
}

@media (min-width: 768px) {
  .menu-content { padding: 40px 24px; }
  .title { font-size: 72px; }
}

/* iOS 顶部安全区 */
@supports (padding: max(0px)) {
  .hud-top { padding-top: max(12px, env(safe-area-inset-top)); }
}

/* 隐藏工具类 */
[hidden] { display: none !important; }
