/* ============================================
   猫咪冒险 - Roguelike Game Styles
   ============================================ */

/* --- Fullscreen Overlay (不旋转，始终填满视口) --- */
.rl-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: #0f0f1a;
  z-index: 99999;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* --- Canvas --- */
.rl-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* --- Back Button --- */
.rl-back-btn {
  position: absolute;
  top: 8px; right: 8px;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.5);
  color: #aaa;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
}
.rl-back-btn:active { background: rgba(255,255,255,0.2); }

/* 竖屏时关闭按钮移到右上角（旋转后视觉上的右上） */
@media (orientation: portrait) {
  .rl-back-btn {
    top: 8px; right: 8px;
    left: auto;
  }
}

/* --- Ultimate Button (完全隐藏HTML按钮，改用Canvas渲染+触摸检测) --- */
.rl-ult-btn {
  display: none !important;
}

/* 竖屏时隐藏HTML按钮，改用Canvas内触摸检测 */
@media (orientation: portrait) {
  .rl-ult-btn { display: none; }
}

/* 桌面端也隐藏（用Q键） */
@media (hover: hover) and (pointer: fine) {
  .rl-ult-btn { display: none; }
}

/* --- Level Up Panel --- */
.rl-levelup {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.55);
  -webkit-backdrop-filter: blur(8px) saturate(1.2);
  backdrop-filter: blur(8px) saturate(1.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  animation: rl-fade-in 0.3s ease;
}

/* 竖屏时旋转面板（landscape-right：顺时针90°）
   先用 100vh×100vw 让内容按横屏尺寸排版，再旋转到竖屏 */
@media (orientation: portrait) {
  .rl-levelup {
    position: fixed;
    top: 0; left: 0;
    width: 100vh;
    height: 100vw;
    transform-origin: top left;
    transform: rotate(90deg) translateY(-100vw);
  }
  .rl-levelup-options {
    flex-wrap: wrap;
    justify-content: center;
    max-height: 85vw;
    max-width: 90vh;
    overflow-y: auto;
    gap: 8px;
  }
  .rl-levelup-option {
    min-width: 28vw;
    max-width: 30vw;
    padding: 10px 8px;
  }
  .rl-levelup-option .opt-icon { font-size: 24px; }
  .rl-levelup-option .opt-name { font-size: 11px; }
  .rl-levelup-option .opt-desc { font-size: 9px; }
}

.rl-levelup-title {
  color: #ffd700;
  font-family: system-ui, 'Courier New', monospace;
  font-size: clamp(20px, 4vmin, 28px);
  font-weight: bold;
  text-shadow: 0 0 20px rgba(255,215,0,0.5);
  margin-bottom: 16px;
  letter-spacing: 4px;
}

.rl-levelup-options {
  display: flex;
  gap: 10px;
  padding: 0 12px;
  max-width: 90%;
}

.rl-levelup-option {
  flex: 1 1 0;
  min-width: 120px;
  max-width: 180px;
  background: rgba(30,30,55,0.95);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  animation: rl-card-in 0.4s ease forwards;
}
.rl-levelup-option:nth-child(1) { animation-delay: 0.05s; }
.rl-levelup-option:nth-child(2) { animation-delay: 0.12s; }
.rl-levelup-option:nth-child(3) { animation-delay: 0.19s; }
.rl-levelup-option:nth-child(4) { animation-delay: 0.26s; }
.rl-levelup-option:hover,
.rl-levelup-option:active {
  transform: scale(1.05);
  border-color: #ffd700;
  box-shadow: 0 0 20px rgba(255,215,0,0.2);
}
.rl-levelup-option .opt-icon {
  font-size: clamp(28px, 5vmin, 40px);
  display: block;
  margin-bottom: 6px;
}
.rl-levelup-option .opt-icon.opt-icon-sprite {
  width: clamp(28px, 5vmin, 40px);
  height: clamp(28px, 5vmin, 40px);
  margin-left: auto;
  margin-right: auto;
  background-repeat: no-repeat;
}
.rl-levelup-option .opt-name {
  color: #fff;
  font-family: system-ui, monospace;
  font-size: clamp(12px, 2vmin, 15px);
  font-weight: bold;
  margin-bottom: 4px;
}
.rl-levelup-option .opt-desc {
  color: #8a8a9a;
  font-size: clamp(10px, 1.6vmin, 12px);
  line-height: 1.4;
}
.rl-levelup-option .opt-level {
  color: #ffd700;
  font-size: clamp(9px, 1.4vmin, 11px);
  margin-top: 4px;
  font-weight: bold;
}
.rl-levelup-option.rarity-weapon { border-color: rgba(100,200,255,0.4); box-shadow: 0 0 8px rgba(100,200,255,0.1); }
.rl-levelup-option.rarity-upgrade { border-color: rgba(100,255,100,0.4); box-shadow: 0 0 8px rgba(100,255,100,0.1); }
.rl-levelup-option.rarity-passive { border-color: rgba(200,150,255,0.4); box-shadow: 0 0 8px rgba(200,150,255,0.1); }
.rl-levelup-option.rarity-mech { border-color: rgba(255,140,50,0.5); box-shadow: 0 0 12px rgba(255,140,50,0.15); }
.rl-levelup-option.rarity-branch {
  border-color: rgba(255,215,0,0.6);
  box-shadow: 0 0 16px rgba(255,215,0,0.25), inset 0 0 12px rgba(255,215,0,0.08);
  background: linear-gradient(160deg, rgba(40,30,10,0.95), rgba(30,25,15,0.9));
  animation: branchGlow 1.5s ease-in-out infinite alternate;
}
@keyframes branchGlow {
  from { box-shadow: 0 0 12px rgba(255,215,0,0.2), inset 0 0 8px rgba(255,215,0,0.05); }
  to { box-shadow: 0 0 20px rgba(255,215,0,0.35), inset 0 0 16px rgba(255,215,0,0.12); }
}

/* 协同提示高亮 */
.rl-levelup-option .opt-desc .synergy-hint {
  color: #ffd700;
  font-weight: bold;
  font-size: clamp(9px, 1.4vmin, 11px);
}
.rl-levelup-option.has-synergy {
  border-color: rgba(255,215,0,0.5);
  box-shadow: 0 0 14px rgba(255,215,0,0.2), inset 0 0 8px rgba(255,215,0,0.06);
}
.rl-levelup-option .opt-synergy {
  color: #ffd700;
  font-size: clamp(9px, 1.3vmin, 11px);
  margin-top: 3px;
  opacity: 0.85;
}

/* --- Game Over Panel --- */
.rl-gameover {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  backdrop-filter: blur(10px) saturate(1.1);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 25;
  animation: rl-fade-in 0.5s ease;
}

/* 竖屏时旋转面板（landscape-right：顺时针90°） */
@media (orientation: portrait) {
  .rl-gameover {
    position: fixed;
    top: 0; left: 0;
    width: 100vh;
    height: 100vw;
    transform-origin: top left;
    transform: rotate(90deg) translateY(-100vw);
  }
}

.rl-gameover-panel {
  background: linear-gradient(160deg, rgba(25,25,50,0.97), rgba(18,18,35,0.95));
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 24px 28px;
  text-align: center;
  max-width: 340px;
  width: 85%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 1px rgba(255,255,255,0.1);
  animation: rl-gameover-in 0.6s cubic-bezier(0.34,1.56,0.64,1);
}

/* 竖屏时结算面板适配 */
@media (orientation: portrait) {
  .rl-gameover-panel {
    max-width: 80vmin;
    max-height: 70vmin;
    padding: 20px 24px;
  }
}
.rl-gameover-title {
  color: #ff6b6b;
  font-family: system-ui, monospace;
  font-size: clamp(20px, 3.5vmin, 26px);
  font-weight: bold;
  margin-bottom: 14px;
  letter-spacing: 3px;
  text-shadow: 0 0 12px rgba(255,100,100,0.4);
}
.rl-gameover-stats {
  color: #ccc;
  font-family: system-ui, monospace;
  font-size: clamp(13px, 2.2vmin, 16px);
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rl-gameover-stats .stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
}
.rl-gameover-stats .stat-value {
  color: #ffd700;
  font-weight: bold;
}
.rl-gameover-stars {
  color: #ffd700;
  font-size: clamp(16px, 3vmin, 22px);
  font-weight: bold;
  margin-bottom: 14px;
  padding: 8px;
  background: rgba(255,215,0,0.1);
  border-radius: 8px;
}
.rl-gameover-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.rl-btn {
  padding: 10px 24px;
  border-radius: 8px;
  border: 2px solid #ffd700;
  background: rgba(255,215,0,0.15);
  color: #ffd700;
  font-family: system-ui, monospace;
  font-size: clamp(13px, 2vmin, 16px);
  font-weight: bold;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.rl-btn:active { background: rgba(255,215,0,0.3); }
.rl-btn-secondary {
  border-color: rgba(255,255,255,0.3);
  color: #aaa;
  background: rgba(255,255,255,0.05);
}
.rl-btn-secondary:active { background: rgba(255,255,255,0.15); }

/* --- Animations --- */
@keyframes rl-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes rl-panel-in {
  from { opacity: 0; transform: scale(0.9) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes rl-card-in {
  from { opacity: 0; transform: translateY(20px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes rl-gameover-in {
  0% { opacity: 0; transform: scale(0.7) translateY(30px); }
  60% { opacity: 1; transform: scale(1.03) translateY(-4px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}/* --- 成就解锁横幅 --- */
.rl-achieve-banner {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%) translateY(-80px);
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, rgba(30,20,50,0.95), rgba(50,30,80,0.95));
  border: 1px solid rgba(255,215,0,0.4);
  border-radius: 12px;
  padding: 10px 18px;
  z-index: 100010;
  box-shadow: 0 4px 20px rgba(255,215,0,0.2), inset 0 0 15px rgba(255,215,0,0.05);
  transition: transform 0.5s cubic-bezier(0.34,1.56,0.64,1);
  pointer-events: none;
  max-width: 90vw;
}
.rl-achieve-banner.rl-achieve-show {
  transform: translateX(-50%) translateY(0);
}
.rl-achieve-icon {
  font-size: clamp(24px, 4vmin, 36px);
  flex-shrink: 0;
}
.rl-achieve-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.rl-achieve-title {
  font-size: clamp(10px, 1.5vmin, 12px);
  color: #ffd700;
  font-weight: bold;
  letter-spacing: 1px;
}
.rl-achieve-name {
  font-size: clamp(13px, 2vmin, 16px);
  color: #fff;
  font-weight: bold;
}
.rl-achieve-desc {
  font-size: clamp(9px, 1.3vmin, 11px);
  color: #aaa;
}
.rl-achieve-reward {
  font-size: clamp(9px, 1.3vmin, 11px);
  color: #88ddff;
}/* 竖屏适配 — 成就横幅需要旋转90度匹配横屏游戏画面 */
@media (orientation: portrait) {
  .rl-achieve-banner {
    /* 竖屏时：物理屏幕的右侧 = 游戏画面的顶部 */
    top: 12px;
    left: 50%;
    right: auto;
    bottom: auto;
    transform: rotate(90deg) translateY(-80px);
    transform-origin: center top;
    max-width: 80vh;
  }
  .rl-achieve-banner.rl-achieve-show {
    transform: rotate(90deg) translateY(0);
  }
}