/* ===== 克鲁克农场传说 - 4K写实风UI ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-glass: rgba(18, 22, 30, 0.55);
  --bg-glass-strong: rgba(14, 18, 26, 0.82);
  --border-glass: rgba(255, 255, 255, 0.12);
  --border-glow: rgba(255, 255, 255, 0.25);
  --accent: #ff8c42;
  --accent-dark: #d96a1c;
  --accent-glow: rgba(255, 140, 66, 0.45);
  --gold: #f5c041;
  --text-primary: #f2f5f8;
  --text-secondary: #9aa5b2;
  --text-dim: #6a7382;
  --shadow-xl: 0 12px 40px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.25);
  --radius-xl: 18px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 7px;
}

body {
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  user-select: none;
  background: #000;
  color: var(--text-primary);
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  touch-action: none;
  -webkit-touch-action: none;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  z-index: 1;
  position: absolute;
  top: 0;
  left: 0;
  cursor: default;
}

/* ===== 准星 ===== */
.crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  pointer-events: none;
  z-index: 10;
  opacity: 0.85;
}

.crosshair span {
  position: absolute;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
  border-radius: 1px;
}

.crosshair span:nth-child(1) {
  top: 50%;
  left: 0;
  width: 100%;
  height: 2px;
  transform: translateY(-50%);
}

.crosshair span:nth-child(2) {
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  transform: translateX(-50%);
}

/* ===== 顶部栏 ===== */
#top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
  pointer-events: none;
}

.top-left,
.top-right {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.top-center {
  pointer-events: none;
}

.quality-badge {
  padding: 7px 16px;
  background: linear-gradient(135deg, rgba(245, 192, 65, 0.18), rgba(255, 140, 66, 0.12));
  border: 1px solid rgba(245, 192, 65, 0.4);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--gold);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 2px 12px rgba(245, 192, 65, 0.2);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  color: var(--text-primary);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: rgba(255, 140, 66, 0.22);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 6px 22px var(--accent-glow);
}

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

.shop-btn {
  padding: 11px 22px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 18px var(--accent-glow);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.shop-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 26px var(--accent-glow);
}

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

.coin-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--bg-glass);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--border-glass);
  border-radius: 22px;
  box-shadow: var(--shadow-md);
  font-weight: 700;
  color: var(--gold);
  font-size: 16px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.coin-icon {
  font-size: 18px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

/* ===== 侧边栏 ===== */
.side-bar {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 84px;
  background: var(--bg-glass);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 12px 8px;
  box-shadow: var(--shadow-xl);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

.left-bar {
  left: 18px;
}

.right-bar {
  right: 18px;
}

.bar-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 2px;
}

.scroll-btn {
  width: 100%;
  height: 30px;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scroll-btn:hover {
  background: rgba(255, 140, 66, 0.22);
  color: var(--accent);
}

.scroll-btn[style*="hidden"] {
  display: none;
}

.bar-items {
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
  overflow: hidden;
  min-height: 340px;
  max-height: 62vh;
}

.item-slot {
  width: 68px;
  height: 68px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.item-slot:hover {
  border-color: var(--accent);
  background: rgba(255, 140, 66, 0.12);
  transform: scale(1.06);
  box-shadow: 0 4px 14px var(--accent-glow);
}

.item-slot.active {
  border-color: var(--accent);
  background: rgba(255, 140, 66, 0.18);
  box-shadow: 0 0 0 2px var(--accent-glow), 0 4px 14px var(--accent-glow);
}

.item-icon {
  font-size: 30px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.item-count {
  position: absolute;
  bottom: 3px;
  right: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: rgba(0, 0, 0, 0.75);
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
}

.item-name {
  font-size: 9px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60px;
}

.empty-bar-hint {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--text-dim);
  opacity: 0.6;
  text-align: center;
  line-height: 1.3;
}

.empty-bar-hint small {
  font-size: 10px;
  margin-top: 6px;
}

/* ===== 弹窗 ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.25s ease;
}

.modal.hidden {
  display: none;
}

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

.modal-content {
  background: linear-gradient(145deg, #1e2530 0%, #141821 100%);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  color: var(--text-primary);
}

.shop-content {
  width: 980px;
  height: 700px;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  padding: 18px 26px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  gap: 24px;
}

.shop-tabs {
  display: flex;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.tab-btn {
  padding: 10px 26px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 22px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 4px 14px var(--accent-glow);
}

.shop-grid {
  flex: 1;
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  overflow-y: auto;
  align-content: start;
}

.shop-grid::-webkit-scrollbar {
  width: 6px;
}

.shop-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.shop-item {
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md);
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  background: rgba(255, 255, 255, 0.03);
}

.shop-item:hover {
  border-color: var(--accent);
  background: rgba(255, 140, 66, 0.1);
  transform: translateY(-3px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

.shop-item-icon {
  font-size: 44px;
  margin: 0 auto 12px;
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
  box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.25), inset 0 -3px 8px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.shop-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.shop-item-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
}

.shop-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 26px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.page-btn {
  padding: 9px 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255, 140, 66, 0.1);
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#shop-page-info {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ===== 保存弹窗 ===== */
.save-content {
  padding: 44px 54px;
  text-align: center;
  min-width: 440px;
}

.save-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.save-content h3 {
  font-size: 20px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.save-hint {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.save-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn {
  padding: 12px 34px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px var(--accent-glow);
}

.btn-danger {
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
  color: white;
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(231, 76, 60, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ===== Toast 提示 ===== */
.toast {
  position: fixed;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 30px;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  color: white;
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  z-index: 2000;
  box-shadow: var(--shadow-xl);
  animation: fadeInDown 0.3s ease;
}

.toast.hidden {
  display: none;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ===== 统计面板 ===== */
.stats-panel {
  position: absolute;
  bottom: 16px;
  right: 16px;
  padding: 10px 14px;
  background: var(--bg-glass);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  z-index: 50;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 150px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  font-size: 11px;
}

.stat-label {
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-value {
  color: var(--text-primary);
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.stat-value.low {
  color: #ff6b6b;
}

.stat-value.ok {
  color: #5cd987;
}

/* ===== 操作提示 ===== */
.controls-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 22px;
  background: var(--bg-glass);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  z-index: 50;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  opacity: 0.72;
  transition: opacity 0.3s;
}

.controls-hint:hover {
  opacity: 1;
}

.hint-row {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

kbd {
  display: inline-block;
  padding: 1px 7px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  color: var(--text-primary);
  margin: 0 2px;
}

/* ===== 开始界面 ===== */
.start-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(135deg, #1a1d2e 0%, #2d3561 40%, #1e2345 100%);
}

.start-screen.hidden {
  display: none;
}

.start-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  overflow: hidden;
}

.start-bg::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 20%, rgba(255, 140, 66, 0.08) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(100, 180, 255, 0.1) 0%, transparent 50%),
              radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.03) 0%, transparent 60%);
  animation: bgFloat 20s ease-in-out infinite;
}

@keyframes bgFloat {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(3%, -3%) rotate(1deg); }
  66% { transform: translate(-3%, 3%) rotate(-1deg); }
}

.start-content {
  position: relative;
  z-index: 1;
  text-align: center;
  animation: fadeInUp 1s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.start-logo {
  margin-bottom: 48px;
}

.logo-icon {
  font-size: 80px;
  margin-bottom: 16px;
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.start-logo h1 {
  font-size: 48px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 8px 0;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  letter-spacing: 2px;
}

.start-subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  margin: 0;
  font-weight: 400;
  letter-spacing: 4px;
}

.start-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.btn-start {
  min-width: 220px;
  padding: 18px 48px;
  font-size: 18px;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  box-shadow: 0 8px 30px var(--accent-glow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.btn-start:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px var(--accent-glow);
  background: linear-gradient(135deg, #ff9c56 0%, #ff7a30 100%);
}

.btn-start:active {
  transform: translateY(-1px);
}

.btn-continue {
  min-width: 220px;
  padding: 16px 48px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  letter-spacing: 1px;
}

.btn-continue:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.start-footer {
  margin-top: 60px;
  opacity: 0.6;
}

.start-footer p {
  font-size: 14px;
  color: var(--text-dim);
}

.start-footer kbd {
  padding: 4px 12px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

/* 背景星星效果 */
.start-bg::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(2px 2px at 20px 30px, rgba(255,255,255,0.3), transparent),
    radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 90px 40px, rgba(255,255,255,0.4), transparent),
    radial-gradient(2px 2px at 130px 80px, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 160px 120px, rgba(255,255,255,0.3), transparent),
    radial-gradient(2px 2px at 200px 50px, rgba(255,255,255,0.25), transparent),
    radial-gradient(1px 1px at 250px 150px, rgba(255,255,255,0.35), transparent),
    radial-gradient(2px 2px at 300px 90px, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 350px 200px, rgba(255,255,255,0.3), transparent),
    radial-gradient(2px 2px at 400px 130px, rgba(255,255,255,0.25), transparent);
  background-size: 500px 300px;
  animation: starsMove 30s linear infinite;
}

@keyframes starsMove {
  from { background-position: 0 0; }
  to { background-position: 500px 300px; }
}
