@import url('../global.css');

:root {
  --title-color: var(--color-tunnelrun);
}

/* Canvas palette tokens: read at runtime by TunnelrunCanvasRenderer via
   getComputedStyle (see src/games/tunnelrun/TunnelrunCanvasRenderer.ts) so the 4
   app color themes can recolor the background/tunnel material. Authentic (no
   [data-visual-theme]) keeps the original values. Ship and barrier colors stay
   fixed — they signal gameplay state, not scenery. */
.tunnelrun-board[data-visual-theme='arcade'] {
  --tunnelrun-background-top: #1c0a2e;
  --tunnelrun-background-middle: #3a0f34;
  --tunnelrun-background-bottom: #170714;
  --tunnelrun-tunnel-fill: rgba(74, 20, 64, 0.72);
  --tunnelrun-tunnel-rail: rgba(255, 79, 216, 0.82);
  --tunnelrun-tunnel-line: rgba(214, 114, 232, 0.2);
  --tunnelrun-tunnel-ring: rgba(162, 56, 201, 0.42);
}

.tunnelrun-board[data-visual-theme='midnight'] {
  --tunnelrun-background-top: #050c1a;
  --tunnelrun-background-middle: #0b1d3a;
  --tunnelrun-background-bottom: #050c1a;
  --tunnelrun-tunnel-fill: rgba(18, 52, 86, 0.72);
  --tunnelrun-tunnel-rail: rgba(56, 189, 248, 0.82);
  --tunnelrun-tunnel-line: rgba(125, 211, 252, 0.2);
  --tunnelrun-tunnel-ring: rgba(44, 74, 99, 0.42);
}

.tunnelrun-board[data-visual-theme='daylight'] {
  --tunnelrun-background-top: #241640;
  --tunnelrun-background-middle: #4c2f8a;
  --tunnelrun-background-bottom: #1c1136;
  --tunnelrun-tunnel-fill: rgba(91, 58, 158, 0.72);
  --tunnelrun-tunnel-rail: rgba(196, 181, 253, 0.82);
  --tunnelrun-tunnel-line: rgba(237, 233, 254, 0.2);
  --tunnelrun-tunnel-ring: rgba(124, 58, 237, 0.42);
}

.tunnelrun-board[data-visual-theme='amber'] {
  --tunnelrun-background-top: #1a1004;
  --tunnelrun-background-middle: #3d2408;
  --tunnelrun-background-bottom: #1a1004;
  --tunnelrun-tunnel-fill: rgba(90, 58, 15, 0.72);
  --tunnelrun-tunnel-rail: rgba(251, 191, 36, 0.82);
  --tunnelrun-tunnel-line: rgba(253, 230, 138, 0.2);
  --tunnelrun-tunnel-ring: rgba(138, 90, 30, 0.42);
}

.tunnelrun-board {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
  padding: 0;
  aspect-ratio: auto;
  background:
    linear-gradient(
      135deg,
      color-mix(in srgb, var(--color-tunnelrun) 14%, transparent),
      transparent 32%
    ),
    var(--surface-deep);
  border: 1px solid color-mix(in srgb, var(--color-tunnelrun) 62%, var(--line));
  border-radius: var(--border-radius-lg);
  box-shadow:
    inset 0 0 0 0.28rem rgba(2, 9, 22, 0.82),
    inset 0 0 1.5rem color-mix(in srgb, var(--color-tunnelrun) 17%, transparent),
    0 1rem 2.6rem rgba(0, 0, 0, 0.28);
}

.tunnelrun-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  flex: 0 1 auto;
  min-height: 0;
  margin: auto;
  isolation: isolate;
}

.tunnelrun-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  background: #020611;
}

.tunnelrun-touch-controls {
  position: absolute;
  inset: auto var(--spacing-sm) var(--spacing-sm);
  z-index: 2;
  display: none;
  justify-content: space-between;
  gap: var(--spacing-sm);
  pointer-events: none;
}

.tunnelrun-touch-button {
  min-width: 5.75rem;
  min-height: var(--tap-target-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs) var(--spacing-sm);
  border: 1px solid color-mix(in srgb, var(--white-color) 58%, var(--title-color));
  border-radius: var(--border-radius-lg);
  background: color-mix(in srgb, var(--surface-deep) 76%, transparent);
  color: var(--white-color);
  font: inherit;
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 0 1rem color-mix(in srgb, var(--title-color) 22%, transparent);
  backdrop-filter: blur(0.35rem);
  pointer-events: auto;
  touch-action: none;
  cursor: pointer;
}

.tunnelrun-touch-button:active {
  background: color-mix(in srgb, var(--title-color) 62%, var(--surface-deep));
  transform: translateY(1px);
}

.tunnelrun-touch-arrow {
  font-size: var(--font-size-lg);
  line-height: 1;
}

@media (max-width: 767px), (pointer: coarse) {
  .tunnelrun-touch-controls {
    display: flex;
  }
}
