/* ============================================================
   ADAPTIVE MEMORY — style.css
   ============================================================ */

/* ── FONTS ─────────────────────────────────────────────────── */
@font-face {
  font-family: 'Orbitron';
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  src: url('fonts/orbitron.woff2') format('woff2');
}
@font-face {
  font-family: 'Rajdhani';
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url('fonts/rajdhani.woff2') format('woff2');
}

/* ── CSS VARIABLES ─────────────────────────────────────────── */
:root {
  --bg:          #0d0d1a;
  --surface:     #1a1a2e;
  --surface-2:   #12122b;
  --gold-flat:   #ffcc00;
  --cyan:        #00f5ff;
  --text:        #ffffff;
  --text-muted:  #8888aa;
  --red:         #ff3355;
  --green:       #00dd88;
  --border:      rgba(0, 245, 255, 0.2);
  --card-border: rgba(255, 255, 255, 0.25);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Rajdhani', 'Segoe UI', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

.hidden { display: none !important; }

/* ── ERROR BANNER ──────────────────────────────────────────── */
#error-banner {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--red);
  color: #fff;
  padding: 8px 16px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  z-index: 99999;
  word-break: break-all;
}

/* ── SPLASH ─────────────────────────────────────────────────── */
#splash {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 1000;
  cursor: pointer;
}

.splash-inner {
  text-align: center;
  padding: 44px 40px;
  background: rgba(26, 26, 46, 0.85);
  border: 1px solid var(--border);
  border-radius: 16px;
  backdrop-filter: blur(16px);
  box-shadow: 0 0 60px rgba(0, 245, 255, 0.08),
              inset 0 1px 0 rgba(255, 255, 255, 0.08);
  max-width: 500px;
  width: 90vw;
}

.splash-brain {
  font-size: 64px;
  display: block;
  margin-bottom: 16px;
  filter: drop-shadow(0 0 24px rgba(0, 245, 255, 0.6));
  animation: float 3s ease-in-out infinite;
}

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

.splash-inner h1 {
  font-family: 'Orbitron', 'Courier New', monospace;
  font-size: clamp(22px, 5vw, 32px);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text);
  margin-bottom: 10px;
  text-shadow: 0 0 24px rgba(0, 245, 255, 0.35);
}

.splash-subtitle {
  color: var(--text-muted);
  font-size: 16px;
  margin-bottom: 24px;
}

.splash-features {
  list-style: none;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 2.0;
  text-align: left;
  margin-bottom: 32px;
}

.tap-to-play {
  font-family: 'Orbitron', 'Courier New', monospace;
  font-size: clamp(15px, 3vw, 20px);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--gold-flat);
  border: 2px solid var(--gold-flat);
  padding: 14px 36px;
  border-radius: 8px;
  display: inline-block;
  animation: pulse-border 2s ease-in-out infinite;
}

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 rgba(255,204,0,0); }
  50%       { box-shadow: 0 0 24px rgba(255,204,0,0.4); }
}

.splash-goal {
  font-family: 'Rajdhani', sans-serif;
  font-size: 13px;
  color: var(--cyan);
  margin-top: 16px;
  margin-bottom: 4px;
  opacity: 0.8;
  font-style: italic;
}

.splash-features strong {
  color: var(--text);
  font-weight: 700;
}

.splash-hint {
  margin-top: 16px;
  font-size: 11px;
  color: rgba(136, 136, 170, 0.5);
  letter-spacing: 0.05em;
}

/* ── GAME WRAPPER ───────────────────────────────────────────── */
#game-wrapper {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* Scanline + vignette overlay */
#game-wrapper::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9990;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0,0,0,0.03) 0px, rgba(0,0,0,0.03) 1px,
      transparent 1px, transparent 3px
    ),
    radial-gradient(ellipse at center, transparent 58%, rgba(0,0,0,0.5) 100%);
}

/* ── HUD ────────────────────────────────────────────────────── */
#hud {
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  background: rgba(13, 13, 26, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  box-shadow:
    0 4px 24px rgba(0,245,255,0.05),
    inset 0 1px 0 rgba(255,255,255,0.07);
}

.hud-panel {
  flex: 1;
  padding: 7px 10px;
  border-right: 1px solid rgba(255,255,255,0.07);
  overflow: hidden;
}

.hud-panel:last-child { border-right: none; }

.hud-center {
  flex: 4;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-right: 1px solid rgba(255,255,255,0.07);
}

.hud-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 1px;
}

.hud-value {
  font-family: 'Orbitron', 'Courier New', monospace;
  font-size: clamp(14px, 1.8vw, 20px);
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text);
  line-height: 1.1;
}

.hud-sub {
  font-family: 'Rajdhani', sans-serif;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.hud-reason {
  font-family: 'Rajdhani', sans-serif;
  font-size: 10px;
  color: var(--cyan);
  margin-top: 2px;
  line-height: 1.3;
  display: none;
}

.diff-change-badge {
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-top: 2px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255,255,255,0.07);
  display: inline-block;
}
.diff-change-badge.hidden { display: none; }

.diff-next {
  font-family: 'Rajdhani', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-top: 2px;
  opacity: 0.85;
}

/* ── FLOW GAUGE ─────────────────────────────────────────────── */
#flow-gauge-wrap {
  width: 100%;
  padding: 1px 0 3px;
}

#flow-gauge-label {
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 3px;
}

#flow-gauge-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.flow-emoji {
  font-size: 14px;
  flex-shrink: 0;
  line-height: 1;
}

#flow-track {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  position: relative;
  /* Gradient: danger red → sweet green → dull grey */
  background: linear-gradient(to right,
    #ff3355 0%,
    #ff8800 22%,
    #00dd88 38%, #00dd88 62%,
    #8866aa 78%,
    #445566 100%);
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.7);
}

/* Bracket overlay marking the target flow zone (center 30%) */
#flow-zone-bracket {
  position: absolute;
  top: -5px;
  left: 35%;
  width: 30%;
  height: calc(100% + 10px);
  border: 1.5px solid rgba(255,255,255,0.35);
  border-radius: 3px;
  pointer-events: none;
}
#flow-zone-bracket::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 60%;
  background: rgba(255,255,255,0.2);
}

#flow-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--green);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255,255,255,0.5);
  box-shadow: 0 0 8px currentColor, 0 0 0 3px rgba(255,255,255,0.1);
  transition: background 0.4s;
  z-index: 2;
}

#flow-zone-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(136,136,170,0.5);
  padding: 0 20px;
}

.flow-zone-sweet {
  color: #00dd88;
  opacity: 0.85;
}

/* ── CHURN PANEL ────────────────────────────────────────────── */
#hud-churn { flex: 1; }

#churn-light {
  font-family: 'Orbitron', 'Courier New', monospace;
  font-size: clamp(10px, 1.4vw, 13px);
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
  transition: color 0.4s;
}

/* Risk bar */
#churn-risk-track {
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  margin-bottom: 3px;
  overflow: hidden;
}

#churn-risk-bar {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: var(--green);
  transition: background 0.4s;
}

/* ── SIGNAL GRID ─────────────────────────────────────────────── */
#churn-signals {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 2px 4px;
  margin-top: 3px;
  width: 100%;
}

.sr {
  opacity: 0.28;
  transition: opacity 0.3s;
  padding: 2px 4px;
  border-radius: 3px;
  background: rgba(255,255,255,0.02);
  cursor: default;
}
.sr.sr-on {
  opacity: 1;
  background: rgba(255,255,255,0.05);
}

.sr-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
  gap: 3px;
}

.sr-name {
  font-family: 'Rajdhani', sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #555577;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sr.sr-on .sr-name { color: #ccccdd; }

.sr-contrib {
  font-family: 'Orbitron', monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.sr-bar-track {
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}

.sr-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease, background 0.3s ease;
}

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.14);
  color: var(--text-muted);
  font-family: 'Rajdhani', sans-serif;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  line-height: 1.6;
}

.btn-ghost:hover {
  border-color: var(--cyan);
  color: var(--text);
}

/* ── SIGNAL DEFINITIONS ─────────────────────────────────────── */
#signal-defs-btn {
  margin-top: 4px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-muted);
  font-family: 'Rajdhani', sans-serif;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  width: 100%;
  text-align: left;
}
#signal-defs-btn:hover { border-color: var(--cyan); color: var(--text); }

#signal-defs-panel {
  margin-top: 5px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 5px;
  padding: 6px 8px;
  max-height: 180px;
  overflow-y: auto;
}

.sd-row {
  display: flex;
  flex-direction: column;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.sd-row:last-child { border-bottom: none; }

.sd-name {
  font-family: 'Orbitron', monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--cyan);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.sd-desc {
  font-family: 'Rajdhani', sans-serif;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── SCORE PANEL ────────────────────────────────────────────── */
#streak-hud {
  font-family: 'Rajdhani', sans-serif;
  font-size: 11px;
  color: var(--gold-flat);
  margin-top: 1px;
  min-height: 14px;
}

#reward-rate {
  font-family: 'Rajdhani', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-top: 1px;
  opacity: 0.85;
}

#spend-panel {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
  width: 100%;
}

.spend-btn {
  width: 100%;
  padding: 5px 8px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 5px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.spend-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.09);
  border-color: rgba(0,245,255,0.35);
  color: var(--text);
}
.spend-btn:active:not(:disabled) { transform: scale(0.97); }
.spend-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.spend-cost {
  font-size: 11px;
  color: #ff9944;
  font-weight: 700;
}

/* ── ADAPTIVE TOGGLE BAR ─────────────────────────────────────── */
#adaptive-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px;
  background: rgba(0,245,255,0.04);
  border-top: 1px solid rgba(0,245,255,0.1);
  border-bottom: 1px solid rgba(0,245,255,0.1);
  transition: background 0.4s, border-color 0.4s;
  flex-shrink: 0;
}

#adaptive-bar.adaptive-bar-off {
  background: rgba(255,51,85,0.04);
  border-color: rgba(255,51,85,0.15);
}

#adaptive-left {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

#adaptive-icon { font-size: 15px; }

#adaptive-label {
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  white-space: nowrap;
}

#adaptive-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  border-radius: 20px;
  border: 2px solid;
  font-family: 'Orbitron', monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s, color 0.25s, box-shadow 0.25s;
  flex-shrink: 0;
}

#adaptive-toggle.adaptive-on {
  background: rgba(0,221,136,0.12);
  border-color: #00dd88;
  color: #00dd88;
  box-shadow: 0 0 10px rgba(0,221,136,0.2);
}
#adaptive-toggle.adaptive-on:hover {
  background: rgba(0,221,136,0.22);
}

#adaptive-toggle.adaptive-off {
  background: rgba(255,51,85,0.1);
  border-color: #ff3355;
  color: #ff3355;
  box-shadow: 0 0 10px rgba(255,51,85,0.15);
}
#adaptive-toggle.adaptive-off:hover {
  background: rgba(255,51,85,0.2);
}

#adaptive-toggle-pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

#adaptive-status {
  font-family: 'Rajdhani', sans-serif;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── GAME AREA ──────────────────────────────────────────────── */
#game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 8px 12px;
  overflow: hidden;
  min-height: 0;
}

#board-wrap {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
}

/* ── EMOJI LIST ─────────────────────────────────────────────── */
#emoji-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-start;
  flex-shrink: 0;
}

.el-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 13px;
  color: var(--text-muted);
  transition: opacity 0.3s, color 0.3s;
  white-space: nowrap;
}

.el-emoji {
  font-size: 20px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.3s;
}

.el-check {
  font-size: 11px;
  width: 14px;
  color: var(--green);
  opacity: 0;
  transition: opacity 0.3s;
  flex-shrink: 0;
}

.el-item.el-done {
  opacity: 0.35;
}

.el-item.el-done .el-check {
  opacity: 1;
}

.el-item.el-done .el-emoji {
  filter: grayscale(1);
}

/* ── CARD GRID ──────────────────────────────────────────────── */
#card-grid {
  display: grid;
  gap: clamp(8px, 1.5vw, 14px);
  justify-content: center;
  align-content: center;
}

#card-grid.level-1 { grid-template-columns: repeat(4, 1fr); }
#card-grid.level-2 { grid-template-columns: repeat(4, 1fr); }
#card-grid.level-3 { grid-template-columns: repeat(4, 1fr); }
#card-grid.level-4 { grid-template-columns: repeat(5, 1fr); gap: clamp(5px, 1vw, 10px); }

/* ── CARDS ──────────────────────────────────────────────────── */
.card {
  width:  clamp(68px, 9.5vw, 104px);
  height: clamp(68px, 9.5vw, 104px);
  perspective: 800px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Smaller cards on 5-col grid so they all fit */
#card-grid.level-4 .card {
  width:  clamp(52px, 7.5vw, 84px);
  height: clamp(52px, 7.5vw, 84px);
}
#card-grid.level-4 .card-emoji {
  font-size: clamp(22px, 3.2vw, 36px);
}

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  will-change: transform;
}

.card-front,
.card-back {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Card back — visible by default (rotationY = 0) */
.card-back {
  background: var(--surface);
  background-image: repeating-linear-gradient(
    45deg,
    rgba(0,245,255,0.04) 0px, rgba(0,245,255,0.04) 1px,
    transparent 1px, transparent 8px
  );
  border: 1px solid var(--card-border);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

/* Card front — rotated 180deg so it shows when inner is rotated */
.card-front {
  transform: rotateY(180deg);
  background: radial-gradient(circle at 50% 38%, #2a2a4a, #1a1a2e);
  border: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-emoji {
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  overflow: hidden;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.55));
}

/* Matched state */
.card.matched .card-front {
  background: radial-gradient(circle at 50% 38%, #1a3a2a, #0d1a14);
  border-color: var(--green);
}

/* Wrong flash */
.card.wrong-flash .card-front {
  background: radial-gradient(circle at 50% 38%, rgba(255,51,85,0.18), #1a1a2e) !important;
}

/* Match glow */
@keyframes match-glow-pulse {
  0%   { box-shadow: 0 0 6px  rgba(0,221,136,0.3); }
  50%  { box-shadow: 0 0 22px rgba(0,221,136,0.7); }
  100% { box-shadow: 0 0 10px rgba(0,221,136,0.4); }
}

.card.match-glow .card-front {
  animation: match-glow-pulse 1.2s ease-in-out forwards;
}

/* Carried-over pairs (headstart) — cyan tint to distinguish from fresh matches */
.card.carryover .card-front {
  background: radial-gradient(circle at 50% 38%, #0d2a3a, #0a1520);
  border-color: var(--cyan);
  opacity: 0.7;
}
@keyframes carryover-pulse {
  0%   { box-shadow: 0 0 6px  rgba(0,245,255,0.2); }
  50%  { box-shadow: 0 0 18px rgba(0,245,255,0.5); }
  100% { box-shadow: 0 0 8px  rgba(0,245,255,0.25); }
}
.card.carryover.match-glow .card-front {
  animation: carryover-pulse 1.8s ease-in-out infinite;
}

/* ── STREAK COUNTER ──────────────────────────────────────────── */
#streak-counter {
  margin-top: 14px;
  font-family: 'Orbitron', monospace;
  font-size: clamp(16px, 2.5vw, 22px);
  font-weight: 700;
  color: var(--gold-flat);
  letter-spacing: 0.06em;
  min-height: 28px;
  text-align: center;
  text-shadow: 0 0 14px rgba(255,204,0,0.45);
  opacity: 0;
  transition: opacity 0.3s;
}

/* ── PRESENTER BUTTON & HINT PANEL ──────────────────────────── */
#presenter-btn {
  position: absolute;
  bottom: 14px;
  right: 130px;
  background: rgba(18, 18, 43, 0.75);
  border: 1px solid rgba(255,255,255,0.14);
  color: var(--text-muted);
  font-size: 16px;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  z-index: 10;
  transition: border-color 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
#presenter-btn:hover  { border-color: var(--cyan); color: var(--text); }
#presenter-btn.active { border-color: var(--cyan); color: var(--cyan); }

#presenter-hint {
  position: absolute;
  bottom: 58px;
  right: 14px;
  background: rgba(10, 10, 24, 0.97);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  z-index: 20;
  min-width: 280px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
#presenter-hint.hidden { display: none; }

.ph-title {
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--cyan);
  margin-bottom: 10px;
}

.ph-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 13px;
  color: var(--text-muted);
}
.ph-row:last-child { margin-bottom: 0; }

.ph-row kbd {
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
  min-width: 28px;
  text-align: center;
}

.ph-row span { color: var(--text-muted); }

/* ── ACTIONS PANEL ───────────────────────────────────────────── */
#actions-panel {
  display: flex;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(10, 10, 22, 0.6);
  border-bottom: 1px solid rgba(0, 245, 255, 0.08);
  flex-wrap: nowrap;
  overflow-x: auto;
}

.ap-action {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  padding: 3px 7px;
  flex: 1;
  min-width: 0;
  transition: border-color 0.3s, background 0.3s;
  cursor: default;
}

.ap-action.ap-active {
  background: rgba(0, 221, 136, 0.08);
  border-color: var(--green);
  box-shadow: 0 0 6px rgba(0, 221, 136, 0.15);
}

.ap-icon { font-size: 13px; flex-shrink: 0; }

.ap-text { flex: 1; min-width: 0; }

.ap-name {
  font-family: 'Orbitron', monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ap-desc {
  font-family: 'Rajdhani', sans-serif;
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ap-fired {
  font-family: 'Orbitron', monospace;
  font-size: 8px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

/* ── NEAR-WIN OFFER MODAL ────────────────────────────────────── */
#near-win-offer {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(13, 13, 26, 0.88);
  z-index: 9000;
  text-align: center;
  backdrop-filter: blur(3px);
}
#near-win-offer.hidden { display: none; }

#nwo-icon { font-size: 48px; margin-bottom: 10px; }

#nwo-title {
  font-family: 'Orbitron', monospace;
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--gold-flat);
  text-shadow: 0 0 20px rgba(255, 204, 0, 0.4);
  margin-bottom: 12px;
}

#nwo-body {
  font-family: 'Rajdhani', sans-serif;
  font-size: clamp(15px, 2.5vw, 18px);
  color: var(--text-muted);
  max-width: 340px;
  line-height: 1.5;
  margin-bottom: 24px;
  padding: 0 20px;
}

#nwo-buttons {
  display: flex;
  gap: 14px;
}

#nwo-accept, #nwo-decline {
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 10px 24px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

#nwo-accept {
  color: #fff;
  background: rgba(0, 221, 136, 0.12);
  border: 2px solid var(--green);
}
#nwo-accept:hover  { background: rgba(0, 221, 136, 0.22); }
#nwo-accept:active { transform: scale(0.96); }

#nwo-decline {
  color: var(--text-muted);
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.15);
}
#nwo-decline:hover  { border-color: rgba(255,255,255,0.3); color: var(--text); }
#nwo-decline:active { transform: scale(0.96); }

/* ── RESET BUTTON ────────────────────────────────────────────── */
#reset-btn {
  position: absolute;
  bottom: 14px;
  right: 14px;
  background: rgba(18, 18, 43, 0.75);
  border: 1px solid rgba(255,255,255,0.14);
  color: var(--text-muted);
  font-family: 'Rajdhani', sans-serif;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  z-index: 10;
  transition: border-color 0.2s, color 0.2s;
}

#reset-btn:hover {
  border-color: var(--cyan);
  color: var(--text);
}

/* ── ACTION BANNER ───────────────────────────────────────────── */
#action-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: min(520px, 92vw);
  margin: 0 auto;
  background: rgba(10, 10, 22, 0.96);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 14px 14px;
  padding: 14px 20px 16px;
  z-index: 9500;
  box-shadow: 0 6px 28px rgba(0,245,255,0.12);
}

#action-title {
  font-family: 'Orbitron', monospace;
  font-size: clamp(14px, 2vw, 17px);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
  margin-bottom: 5px;
}

#action-subtitle {
  font-family: 'Rajdhani', sans-serif;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

#action-effect {
  font-family: 'Rajdhani', sans-serif;
  font-size: 14px;
  color: var(--green);
  font-weight: 700;
}

/* ── LEVEL COMPLETE ──────────────────────────────────────────── */
#level-complete {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(13, 13, 26, 0.82);
  z-index: 8000;
  text-align: center;
  pointer-events: none;
  backdrop-filter: blur(2px);
}

#lc-title {
  font-family: 'Orbitron', monospace;
  font-size: clamp(22px, 4vw, 32px);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
  margin-bottom: 10px;
  text-shadow: 0 0 24px rgba(0,245,255,0.3);
}

#lc-score {
  font-family: 'Orbitron', monospace;
  font-size: clamp(36px, 7vw, 52px);
  font-weight: 700;
  color: var(--gold-flat);
  text-shadow: 0 0 24px rgba(255,204,0,0.5);
  margin-bottom: 14px;
}

#lc-dda {
  font-family: 'Rajdhani', sans-serif;
  font-size: clamp(14px, 2vw, 17px);
  color: var(--cyan);
  display: none;
  max-width: 400px;
  line-height: 1.6;
  padding: 0 20px;
}

#lc-continue {
  pointer-events: auto;
  margin-top: 24px;
  padding: 10px 32px;
  font-family: 'Orbitron', monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #ffffff;
  background: transparent;
  border: 2px solid #00dd88;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
#lc-continue:hover  { background: rgba(255,255,255,0.08); }
#lc-continue:active { transform: scale(0.96); }
#lc-continue.hidden { display: none; }

/* ── RESPONSIVE: MOBILE ─────────────────────────────────────── */
@media (max-width: 768px) {
  #game-wrapper { flex-direction: column-reverse; }

  #hud {
    min-height: auto;
    border-bottom: none;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
  }

  .hud-panel { padding: 6px 8px; flex: 1; min-width: 80px; }
  .hud-center { flex: 3 3 160px; }
  .hud-value { font-size: 15px; }

  #flow-gauge-row { display: none; }

  /* Signals: 2-col grid on mobile */
  #churn-signals {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
  }

  /* Emoji list: horizontal strip above grid instead of sidebar */
  #board-wrap { flex-direction: column; align-items: center; gap: 8px; }

  #emoji-list {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 8px;
    max-width: 100%;
  }

  .el-emoji { font-size: 16px; width: 22px; height: 22px; }
  .el-check { font-size: 9px; width: 10px; }
  .el-item { gap: 3px; font-size: 11px; }

  /* Actions panel: 2×2 wrap on mobile */
  #actions-panel { flex-wrap: wrap; }
  .ap-action { min-width: calc(50% - 4px); flex: 1 1 calc(50% - 4px); }
  .ap-desc { display: none; }

  /* Presenter & reset buttons */
  #reset-btn { bottom: auto; top: 8px; right: 8px; font-size: 11px; padding: 4px 8px; }
  #presenter-btn { bottom: auto; top: 8px; right: 100px; width: 30px; height: 30px; font-size: 14px; }
  #presenter-hint { bottom: auto; top: 46px; right: 8px; min-width: 240px; }
}

@media (max-height: 560px) {
  .hud-value { font-size: 14px; }
  #flow-gauge-row { display: none; }
}

/* ── DEMO MODE INDICATOR ─────────────────────────────────────── */
body.demo-mode::before {
  content: '?demo=true';
  position: fixed;
  bottom: 14px;
  left: 14px;
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  color: rgba(0,245,255,0.4);
  letter-spacing: 0.08em;
  pointer-events: none;
  z-index: 9990;
}
