/* ==========================================================================
   五丈原 怀旧游戏厅 - 主布局与组件样式
   ========================================================================== */

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background-color: var(--bg-page);
  background-image:
    linear-gradient(to right, var(--bg-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--bg-grid) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--text-main);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

code,
kbd {
  font-family: var(--font-mono);
}

.hidden {
  display: none !important;
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 18px 36px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
}

/* --------------------------------------------------------------------------
   通用面板与按钮
   -------------------------------------------------------------------------- */
.panel {
  background: var(--bg-surface);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
}

.panel-alt {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  background: var(--bg-surface-alt);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: transform 0.14s ease, border-color 0.14s ease, background-color 0.14s ease;
}

.btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  box-shadow: var(--shadow-btn);
}

.btn-primary:hover {
  filter: brightness(1.08);
  border-color: var(--accent);
}

.btn.is-active {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

/* --------------------------------------------------------------------------
   顶部街机门头 Header
   -------------------------------------------------------------------------- */
.arcade-header {
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-area {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.coin-badge {
  display: inline-block;
  padding: 3px 9px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-btn);
}

.site-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(19px, 2.5vw, 24px);
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.brand-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

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

.stat-chips {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-chip {
  padding: 5px 11px;
  text-align: center;
  min-width: 68px;
}

.stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 800;
  color: var(--accent);
}

.stat-value.accent-2 {
  color: var(--accent-2);
}

.theme-switcher {
  display: inline-flex;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-surface-alt);
}

.theme-btn {
  border: none;
  border-right: 1px solid var(--border-color);
  background: transparent;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.theme-btn:last-child {
  border-right: none;
}

.theme-btn.is-active {
  background: var(--accent);
  color: var(--accent-contrast);
}

/* --------------------------------------------------------------------------
   大厅视图：筛选栏 + 最近玩过 + 卡带网格
   -------------------------------------------------------------------------- */
.lobby-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  width: 230px;
  max-width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  background: var(--bg-surface);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
}

.search-input:focus {
  border-color: var(--accent);
}

.recent-bar {
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.recent-label {
  color: var(--text-muted);
  font-weight: 700;
}

.recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recent-pill {
  padding: 4px 10px;
  font-size: 12px;
}

/* 游戏卡带网格 */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.cartridge-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.cartridge-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: var(--shadow-card-hover);
}

.cartridge-cover {
  position: relative;
  height: 144px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  overflow: hidden;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.08), transparent 68%),
    var(--bg-surface-alt);
}

/* 卡带顶部抓手凹槽纹 */
.cartridge-grip {
  position: absolute;
  top: 8px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  opacity: 0.45;
}

.cartridge-grip span {
  display: block;
  width: 34px;
  height: 2px;
  background: var(--text-muted);
}

.cartridge-stripe {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5px;
  background: var(--card-accent, var(--accent));
}

.cartridge-icon {
  font-size: 46px;
  line-height: 1;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35));
}

.cartridge-year {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

.cartridge-status {
  position: absolute;
  top: 8px;
  left: 54px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.cartridge-status.is-ready {
  color: var(--success);
  border-color: var(--success);
}

.cartridge-status.is-slot {
  color: var(--warning);
  border-color: var(--warning);
}

.fav-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  font-size: 15px;
  color: var(--text-muted);
}

.fav-btn.is-fav {
  color: var(--accent-3);
  border-color: var(--accent-3);
}

.cartridge-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.cartridge-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  font-family: var(--font-display);
}

.cartridge-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 38px;
}

.cartridge-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  font-size: 12px;
}

.cartridge-meta {
  color: var(--text-muted);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* --------------------------------------------------------------------------
   机台游玩视图
   -------------------------------------------------------------------------- */
.cabinet-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cabinet-topbar {
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cabinet-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.cabinet-title-text h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.cabinet-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface-alt);
  color: var(--accent);
}

.cabinet-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.cabinet-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.ratio-group {
  display: inline-flex;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-surface-alt);
}

.ratio-btn {
  border: none;
  border-right: 1px solid var(--border-color);
  background: transparent;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 600;
}

.ratio-btn:last-child {
  border-right: none;
}

.ratio-btn.is-active {
  background: var(--accent);
  color: var(--accent-contrast);
}

.cabinet-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 16px;
  align-items: start;
}

.cabinet-bezel {
  padding: 14px;
  background: var(--bezel-bg);
  border: 3px solid var(--bezel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bezel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 4px;
}

.status-led {
  color: var(--accent);
  font-weight: 700;
}

.screen-wrapper {
  position: relative;
  margin: 0 auto;
  background: var(--bg-screen);
  border: 3px solid #05070c;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.85);
}

.screen-wrapper.ratio-auto {
  width: 100%;
  height: min(68vh, 620px);
  min-height: 480px;
}

.screen-wrapper.ratio-16-9 {
  width: 100%;
  aspect-ratio: 16 / 9;
}

.screen-wrapper.ratio-4-3 {
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 72vh;
}

.screen-wrapper:fullscreen,
.screen-wrapper:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  max-height: none !important;
  border: none;
  border-radius: 0;
}

.game-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: var(--bg-screen);
}

/* CRT 扫描线叠层（必须 pointer-events: none，避免挡住游戏点击） */
.crt-overlay {
  display: none;
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.2) 0px,
      rgba(0, 0, 0, 0.2) 1px,
      transparent 1px,
      transparent 3px
    ),
    radial-gradient(circle at center, transparent 62%, rgba(0, 0, 0, 0.38) 100%);
}

body.crt-on .crt-overlay {
  display: block;
}

.bezel-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 4px 0;
}

/* 右侧信息侧边栏 */
.cabinet-sidebar {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-size: 13px;
}

.sidebar-section-title {
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.controls-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.controls-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.controls-list kbd {
  padding: 2px 7px;
  font-size: 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface-alt);
  white-space: nowrap;
}

.controls-list span {
  color: var(--text-muted);
  text-align: right;
  font-size: 12px;
}

.info-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.info-row span:first-child {
  color: var(--text-muted);
}

.sidebar-tip {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   页脚
   -------------------------------------------------------------------------- */
.arcade-footer {
  margin-top: auto;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.blink-cursor {
  display: inline-block;
  color: var(--accent);
  font-weight: 800;
  animation: blinkStep 1.1s steps(2, start) infinite;
}

@keyframes blinkStep {
  to {
    visibility: hidden;
  }
}

/* --------------------------------------------------------------------------
   响应式适配
   -------------------------------------------------------------------------- */
@media (max-width: 960px) {
  .cabinet-main {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 12px 12px 24px;
  }

  .arcade-header {
    padding: 14px;
  }

  .search-input {
    width: 100%;
  }

  .search-box {
    width: 100%;
  }

  .screen-wrapper.ratio-auto {
    height: 62vh;
    min-height: 360px;
  }
}
