/* CRT Play - Control Bar for PICO-8 exported games */
:root {
  --cr-primary: #F59E0B;
  --cr-surface: rgba(13, 13, 26, 0.85);
  --cr-on-surface: #F1F1F6;
  --cr-surface-high: rgba(34, 34, 58, 0.9);
  --cr-btn-hover: rgba(245, 158, 11, 0.15);
}

.cr-control-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--cr-surface);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  transition: opacity 0.3s ease;
  opacity: 1;
}

.cr-control-bar:hover,
.cr-control-bar:focus-within {
  opacity: 1;
}

.cr-control-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--cr-on-surface);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.cr-control-btn:hover {
  background: var(--cr-btn-hover);
  color: var(--cr-primary);
}

.cr-control-btn:active {
  transform: scale(0.95);
}

.cr-control-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cr-control-btn.active {
  color: var(--cr-primary);
}

.cr-control-btn.active::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--cr-primary);
}

.cr-control-divider {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.1);
  margin: 0 4px;
}

/* CRT Filter Overlay */
.cr-crt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  pointer-events: none;
  display: none;
  mix-blend-mode: overlay;
}

.cr-crt-overlay.active {
  display: block;
}

/* Scanline effect */
.cr-crt-overlay::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.15) 2px,
    rgba(0, 0, 0, 0.15) 4px
  );
}

/* Screen curvature effect */
.cr-crt-overlay::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at center,
    transparent 60%,
    rgba(0, 0, 0, 0.4) 100%
  );
}

/* Auto-hide bar after inactivity */
@media (hover: hover) {
  .cr-control-bar:not(:hover):not(:focus-within) {
    opacity: 0.15;
  }
}

/* ════════════════════════════════════════
   PICO-8 内置触摸控制器隐藏
   所有 PICO-8 导出 HTML 文件自带虚拟手柄
   (D-Pad + A/B 按钮)，在手机端显示在游戏
   画面下方。由于 CRT Play 网站有自己统一
   的虚拟手柄控件，PICO-8 内置的触摸控件
   需要隐藏，避免干扰。
   
   注：JS 每帧通过 style.display="table" 显示
   这些元素，使用 !important 强制覆盖。
   ════════════════════════════════════════ */
#touch_controls_gfx,
#touch_controls_background {
  display: none !important;
}
/* 也隐藏底部的 D-Pad / 按钮贴图 */
#controls_left_panel,
#controls_right_panel {
  display: none !important;
}

/* Loading spinner overlay for restart */
.cr-loading {
  position: absolute;
  top: 48px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(13, 13, 26, 0.8);
}

.cr-loading.active {
  display: flex;
}

.cr-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(245, 158, 11, 0.2);
  border-top-color: var(--cr-primary);
  border-radius: 50%;
  animation: cr-spin 0.8s linear infinite;
}

@keyframes cr-spin {
  to { transform: rotate(360deg); }
}