@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@300;400;600;700&display=swap');

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

:root {
  --bg:        #040810;
  --panel:     #050c1e;
  --panel2:    #071020;
  --border:    #0c2044;
  --border2:   #112255;
  --p1:        #00aaff;
  --p1-glow:   rgba(0, 170, 255, 0.35);
  --p2:        #ff6622;
  --p2-glow:   rgba(255, 102, 34, 0.35);
  --flip:      #00ffb4;
  --flip-glow: rgba(0, 255, 180, 0.3);
  --text:      #7fb0d8;
  --text-dim:  #2a4060;
  --text-hi:   #c4dcf0;
  --warn:      #ffcc22;
  --panel-w:   268px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Rajdhani', sans-serif;
}

/* ── Layout ────────────────────────────────────────────────── */

#app {
  display: flex;
  height: 100vh;
  position: relative;
}

#canvas-container {
  flex: 1;
  min-width: 0;
  position: relative;
  background: var(--bg);
}

#canvas-container canvas {
  display: block;
}

/* ── Panel ─────────────────────────────────────────────────── */

#ui-panel {
  width: var(--panel-w);
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 20px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  position: relative;
  z-index: 10;
}

/* Subtle scanline overlay on panel */
#ui-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.08) 3px,
    rgba(0,0,0,0.08) 4px
  );
  pointer-events: none;
  z-index: 0;
}

#ui-panel > * { position: relative; z-index: 1; }

/* ── Title ─────────────────────────────────────────────────── */

.panel-title {
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--p1);
  text-shadow: 0 0 20px var(--p1-glow), 0 0 40px rgba(0,170,255,0.15);
  text-transform: uppercase;
  text-align: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border2);
}

.panel-title span {
  display: block;
  font-size: 9px;
  letter-spacing: 0.3em;
  color: var(--text-dim);
  margin-top: 4px;
  text-shadow: none;
  font-weight: 400;
}

/* ── Player badges ─────────────────────────────────────────── */

#player-display {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-badge {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  transition: all 0.25s ease;
  background: rgba(0,0,0,0.3);
}

#p1-badge.active {
  color: var(--p1);
  border-color: rgba(0,170,255,0.5);
  background: rgba(0,170,255,0.07);
  box-shadow: 0 0 14px rgba(0,170,255,0.1), inset 0 0 8px rgba(0,170,255,0.04);
}

#p2-badge.active {
  color: var(--p2);
  border-color: rgba(255,102,34,0.5);
  background: rgba(255,102,34,0.07);
  box-shadow: 0 0 14px rgba(255,102,34,0.1), inset 0 0 8px rgba(255,102,34,0.04);
}

.vs-label {
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* ── Dots ──────────────────────────────────────────────────── */

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-p1 {
  background: var(--p1);
  box-shadow: 0 0 8px var(--p1);
}

.dot-p2 {
  background: var(--p2);
  box-shadow: 0 0 8px var(--p2);
}

.dot-flip {
  background: var(--flip);
  box-shadow: 0 0 6px var(--flip);
}

/* ── Turn indicator ────────────────────────────────────────── */

.turn-indicator {
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--p1);
  padding: 11px 14px;
  border: 1px solid rgba(0,170,255,0.25);
  border-radius: 7px;
  background: rgba(0,170,255,0.04);
  text-align: center;
  text-shadow: 0 0 12px rgba(0,170,255,0.5);
  transition: all 0.3s ease;
}

.turn-indicator.game-over {
  color: var(--warn);
  border-color: rgba(255,204,34,0.35);
  background: rgba(255,204,34,0.05);
  text-shadow: 0 0 14px rgba(255,204,34,0.5);
  font-size: 11px;
}

/* ── Status message ────────────────────────────────────────── */

#status-message {
  font-size: 13px;
  font-weight: 600;
  color: var(--warn);
  padding: 9px 12px;
  border: 1px solid rgba(255,204,34,0.25);
  border-radius: 6px;
  background: rgba(255,204,34,0.05);
  text-align: center;
  display: none;
  letter-spacing: 0.02em;
}

#status-message.visible {
  display: block;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Section separator ─────────────────────────────────────── */

.section-label {
  font-family: 'Orbitron', monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.25em;
  color: var(--text-dim);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Flip section ──────────────────────────────────────────── */

.flip-section {
  background: rgba(0,255,180,0.03);
  border: 1px solid rgba(0,255,180,0.1);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.03em;
}

.flip-header .dot { width: 7px; height: 7px; }

.flip-status-row {
  display: flex;
  gap: 6px;
}

.flip-status {
  flex: 1;
  text-align: center;
  font-size: 10px;
  font-family: 'Orbitron', monospace;
  padding: 5px 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  background: rgba(0,0,0,0.2);
}

.flip-status.available {
  border-color: rgba(0,255,180,0.3);
  color: var(--flip);
  background: rgba(0,255,180,0.05);
}

.flip-btn {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid rgba(0,255,180,0.4);
  border-radius: 6px;
  background: rgba(0,255,180,0.06);
  color: var(--flip);
  font-family: 'Rajdhani', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.05em;
  text-shadow: 0 0 10px rgba(0,255,180,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.flip-btn:hover:not(:disabled) {
  background: rgba(0,255,180,0.12);
  border-color: var(--flip);
  box-shadow: 0 0 16px rgba(0,255,180,0.2), 0 0 30px rgba(0,255,180,0.08);
}

.flip-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  text-shadow: none;
}

.flip-btn .icon {
  font-size: 16px;
  display: inline-block;
  transition: transform 0.3s ease;
}

.flip-btn:hover:not(:disabled) .icon {
  transform: rotate(180deg);
}

/* ── Controls help ─────────────────────────────────────────── */

.controls-block {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.help-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1;
}

.help-row .label {
  flex: 1;
  font-size: 11px;
}

kbd {
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  padding: 3px 7px;
  border: 1px solid var(--border2);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: rgba(255,255,255,0.04);
  color: var(--text);
  white-space: nowrap;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

/* ── Legend ────────────────────────────────────────────────── */

.legend {
  display: flex;
  justify-content: space-around;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}

/* ── Difficulty selector ───────────────────────────────────── */

.diff-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.diff-btn {
  padding: 9px 4px;
  border: 2px solid var(--border2);
  border-radius: 6px;
  background: rgba(255,255,255,0.02);
  color: #3a5070;
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.diff-btn:hover:not(:disabled):not(.active) {
  border-color: #2a4466;
  color: var(--text);
  background: rgba(255,255,255,0.04);
}

/* ── Active states: solid fill + strong glow ── */

.diff-btn.active[data-diff="easy"] {
  border-color: #00cc66;
  color: #fff;
  background: linear-gradient(135deg, rgba(0,180,80,0.55), rgba(0,140,60,0.4));
  box-shadow: 0 0 0 1px #00cc66,
              0 0 12px rgba(0,204,102,0.5),
              inset 0 1px 0 rgba(255,255,255,0.15);
  text-shadow: 0 0 8px rgba(0,255,120,0.8);
}

.diff-btn.active[data-diff="normal"] {
  border-color: var(--p1);
  color: #fff;
  background: linear-gradient(135deg, rgba(0,140,220,0.55), rgba(0,100,180,0.4));
  box-shadow: 0 0 0 1px var(--p1),
              0 0 12px rgba(0,170,255,0.5),
              inset 0 1px 0 rgba(255,255,255,0.15);
  text-shadow: 0 0 8px rgba(0,200,255,0.8);
}

.diff-btn.active[data-diff="hard"] {
  border-color: var(--warn);
  color: #fff;
  background: linear-gradient(135deg, rgba(200,160,0,0.55), rgba(160,120,0,0.4));
  box-shadow: 0 0 0 1px var(--warn),
              0 0 12px rgba(255,204,34,0.5),
              inset 0 1px 0 rgba(255,255,255,0.15);
  text-shadow: 0 0 8px rgba(255,220,80,0.8);
}

.diff-btn.active[data-diff="lunatic"] {
  border-color: #ff3366;
  color: #fff;
  background: linear-gradient(135deg, rgba(200,30,60,0.6), rgba(150,20,50,0.45));
  box-shadow: 0 0 0 1px #ff3366,
              0 0 14px rgba(255,51,102,0.6),
              inset 0 1px 0 rgba(255,255,255,0.15);
  text-shadow: 0 0 8px rgba(255,80,120,0.9);
  animation: lunatic-pulse 2s ease-in-out infinite;
}

@keyframes lunatic-pulse {
  0%, 100% { box-shadow: 0 0 0 1px #ff3366, 0 0 14px rgba(255,51,102,0.6), inset 0 1px 0 rgba(255,255,255,0.15); }
  50%       { box-shadow: 0 0 0 1px #ff3366, 0 0 22px rgba(255,51,102,0.85), inset 0 1px 0 rgba(255,255,255,0.15); }
}

.diff-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Thinking indicator ────────────────────────────────────── */

#status-message.thinking {
  color: #00ffb4;
  border-color: rgba(0, 255, 180, 0.3);
  background: rgba(0, 255, 180, 0.04);
  animation: pulse-thinking 1.2s ease-in-out infinite;
}

@keyframes pulse-thinking {
  0%, 100% { opacity: 0.85; }
  50%       { opacity: 1;    box-shadow: 0 0 16px rgba(0,255,180,0.2); }
}

/* ── Turn indicator cpu state ──────────────────────────────── */

.turn-indicator.cpu-thinking {
  color: var(--p2);
  border-color: rgba(255,102,34,0.3);
  background: rgba(255,102,34,0.04);
  text-shadow: 0 0 12px rgba(255,102,34,0.4);
}

/* ── Reset button ──────────────────────────────────────────── */

.reset-btn {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--border2);
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-family: 'Rajdhani', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all 0.2s ease;
}

.reset-btn:hover {
  border-color: var(--text);
  color: var(--text-hi);
  background: rgba(255,255,255,0.03);
}

/* ── Scrollbar ─────────────────────────────────────────────── */

#ui-panel::-webkit-scrollbar { width: 3px; }
#ui-panel::-webkit-scrollbar-track { background: transparent; }
#ui-panel::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
