/* ==========================================================================
   games/pin/css/style.css
   见缝插针：一体化复古钟表工坊、黄铜机芯、蓝钢冷光与微浮雕触感按键
   ========================================================================== */

:root {
  --bg-dark: #0a0e16;
  --bg-panel: #131a26;
  --border-brass: #b8912d;
  --gold-primary: #ffd54f;
  --gold-glow: #d4af37;
  --steel-blue: #4a90e2;
  --flame-red: #e74c3c;
  --text-main: #f0f4f8;
  --text-muted: #8a9bb0;
  --text-gold: #ffd54f;

  --btn-bg: #1c2636;
  --btn-border: #8c6e23;
  --btn-shadow: #06090e;

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  background-color: var(--bg-dark);
  background: radial-gradient(circle at 50% 28%, #141c29 0%, var(--bg-dark) 60%, #05070a 100%);
  color: var(--text-main);
  font-family: var(--font-family);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#game-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  width: 100%;
  max-width: 520px; /* 一体化机台紧凑黄金比例 */
  margin: 0 auto;
  padding: 8px 12px;
  padding-bottom: max(68px, calc(16px + env(safe-area-inset-bottom)));
}

/* 顶部操作栏 */
#game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-panel);
  border: 1.5px solid var(--border-brass);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 215, 79, 0.2);
  margin-bottom: 8px;
  gap: 8px;
  flex-wrap: wrap;
}

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

#game-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gold-primary);
  letter-spacing: 0.5px;
  text-shadow: 0 0 10px rgba(255, 213, 79, 0.3);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* 实体触感按键 (Tactile Buttons) */
.tactile-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  background: linear-gradient(to bottom, #253347, var(--btn-bg));
  border: 1px solid var(--btn-border);
  border-radius: 9px;
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--btn-shadow), 0 4px 8px rgba(0, 0, 0, 0.35);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.tactile-btn:hover {
  background: linear-gradient(to bottom, #30425c, #222f42);
  border-color: var(--gold-primary);
}

.tactile-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--btn-shadow), 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tactile-btn.primary-btn {
  background: linear-gradient(to bottom, #ffd54f, #d4af37);
  border-color: #ffd54f;
  color: #17202a;
  box-shadow: 0 3px 0 #8c6e23;
  text-shadow: none;
}

.tactile-btn.primary-btn:hover {
  background: linear-gradient(to bottom, #ffdf79, #dfba42);
}

.tactile-btn.mode-btn {
  color: var(--gold-primary);
  border-color: var(--border-brass);
}

/* 一体化垂直机台 */
#game-workspace {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 8px;
  flex: 1;
}

/* 机顶一体化 HUD 仪表条 */
#cabinet-hud {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1.1fr;
  width: 100%;
  gap: 8px;
  background: rgba(19, 26, 38, 0.9);
  border: 1.5px solid rgba(184, 145, 45, 0.4);
  border-radius: 14px;
  padding: 8px 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
}

.hud-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
  white-space: nowrap;
}

.hud-value {
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.hud-value.highlight {
  color: var(--gold-primary);
}

.hud-value.big-number {
  font-size: 1.45rem;
  color: var(--steel-blue);
  line-height: 1.05;
}

.hud-sub {
  font-size: 0.66rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.hud-sub.highlight {
  color: var(--gold-primary);
}

.hud-combo-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: #ff9800;
  min-height: 1em;
}

/* Canvas 容器：严密包裹 480:700 黄金比例，零黑边透视 */
#canvas-container {
  position: relative;
  width: 100%;
  aspect-ratio: 480 / 700;
  max-height: calc(100vh - 215px);
  max-width: min(100%, calc((100vh - 215px) * (480 / 700)));
  margin: 0 auto;
  background: #05070c;
  border: 2px solid rgba(212, 175, 55, 0.55);
  border-radius: 20px;
  box-shadow: 
    0 12px 36px rgba(0, 0, 0, 0.7),
    inset 0 0 28px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  overscroll-behavior: none;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  overscroll-behavior: none;
}

/* 底部实体击发底座 */
#launch-dock {
  width: 100%;
  max-width: min(100%, calc((100vh - 215px) * (480 / 700)));
  margin: 0 auto;
}

.tactile-launch-pad {
  width: 100%;
  padding: 10px 14px;
  background: linear-gradient(180deg, #243247 0%, #151e2c 100%);
  border: 1.5px solid var(--border-brass);
  border-radius: 12px;
  box-shadow: 0 4px 0 #070b12, 0 6px 14px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 215, 79, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  color: var(--gold-primary);
  font-weight: 700;
  font-size: 0.88rem;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s ease;
  user-select: none;
}

.tactile-launch-pad:hover {
  background: linear-gradient(180deg, #2d3e56 0%, #1a2538 100%);
  border-color: #ffd54f;
}

.tactile-launch-pad:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #070b12, 0 2px 6px rgba(0, 0, 0, 0.35);
}

.launch-icon {
  font-size: 1.05rem;
}

.launch-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 6px;
}

/* 模态弹窗系统 */
.game-dialog {
  border: none;
  border-radius: 20px;
  padding: 0;
  background: transparent;
  margin: auto;
  max-width: 90vw;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.75);
}

.game-dialog::backdrop {
  background: rgba(3, 5, 8, 0.75);
  backdrop-filter: blur(4px);
}

.dialog-content {
  background: #141b27;
  border: 2px solid var(--border-brass);
  border-radius: 20px;
  padding: 24px 28px;
  color: var(--text-main);
  max-width: 440px;
}

.wide-dialog .dialog-content {
  max-width: 500px;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.dialog-header h2 {
  font-size: 1.3rem;
  color: var(--gold-primary);
}

.close-x {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
}

.dialog-actions {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

/* 关卡网格 */
.levels-scroll-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 10px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 6px;
}

.level-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 4px;
  background: #1c2636;
  border: 1.5px solid #3c4c66;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 3px 0 #0d131c;
  transition: transform 0.08s ease, background 0.15s ease;
}

.level-card:hover:not(:disabled) {
  background: #27354c;
  border-color: var(--gold-primary);
}

.level-card:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #0d131c;
}

.level-card.active {
  border-color: var(--gold-primary);
  background: #2a3750;
}

.level-card:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.level-num {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.level-stars {
  font-size: 0.72rem;
  color: var(--gold-primary);
  margin-top: 4px;
}

/* 结算胜利铭牌 */
.won-dialog .won-card {
  background: #151d2a;
  border: 2px solid var(--border-brass);
  border-radius: 20px;
  padding: 24px 26px;
  text-align: center;
  color: var(--text-main);
  width: 340px;
  max-width: 90vw;
}

.won-badge {
  font-size: 3.2rem;
  margin-bottom: 8px;
}

.won-card h2 {
  font-size: 1.2rem;
  color: var(--gold-primary);
  margin-bottom: 10px;
}

.won-stars-row {
  font-size: 1.5rem;
  color: var(--gold-primary);
  letter-spacing: 4px;
  margin-bottom: 14px;
}

.won-stats-grid {
  display: flex;
  justify-content: space-around;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.won-stats-grid strong {
  color: var(--text-main);
}

.won-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* 响应式媒体查询 */
@media (max-width: 480px) {
  #game-app {
    padding: 6px 8px;
  }

  #game-header {
    padding: 6px 10px;
    gap: 6px;
  }

  #game-title {
    font-size: 1.05rem;
  }

  .tactile-btn {
    padding: 4px 8px;
    font-size: 0.76rem;
  }

  #cabinet-hud {
    padding: 6px 8px;
    gap: 6px;
  }

  .hud-value {
    font-size: 0.88rem;
  }

  .hud-value.big-number {
    font-size: 1.3rem;
  }

  .tactile-launch-pad {
    padding: 8px 12px;
    font-size: 0.82rem;
  }
}

/* 动效降级 */
@media (prefers-reduced-motion: reduce) {
  .tactile-btn,
  .tactile-launch-pad,
  .level-card {
    transition: none !important;
  }
}
