/* ===== CUBE TAG - Warm Muted Light Theme ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;900&family=JetBrains+Mono:wght@400;700&display=swap');

:root {
  --bg: #e8e4de;
  --surface: rgba(255,255,255,0.62);
  --surface-solid: #f0ece6;
  --border: rgba(0,0,0,0.07);
  --text: #4a4540;
  --dim: #8a847e;
  --accent: #6c8cff;
  --soft-red: #d46a6a;
  --soft-blue: #5898c4;
  --soft-purple: #9070c0;
  --soft-yellow: #c4a84e;
  --soft-green: #5da06a;
  --mono: 'JetBrains Mono', monospace;
  --sans: 'Inter', -apple-system, sans-serif;
  --blur: 14px;
  --gui-scale: 1;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#game-canvas {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
}

/* ---- HUD top center ---- */
#hud {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 10;
  padding: 14px 20px;
  display: flex; justify-content: center; align-items: flex-start;
  gap: 6px; pointer-events: none;
  transform: scale(var(--gui-scale));
  transform-origin: top center;
}

.hud-pill {
  background: var(--surface);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 20px;
  display: flex; align-items: center; gap: 7px;
  pointer-events: auto;
  font-family: var(--mono); font-size: 17px;
  color: var(--text);
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}

.hud-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.hud-dot.red { background: var(--soft-red); }
.hud-dot.blue { background: var(--soft-blue); }
.hud-num { font-weight: 700; font-size: 20px; }
.hud-sep { color: rgba(0,0,0,0.12); font-weight: 300; }
.hud-timer { font-size: 25px; font-weight: 900; letter-spacing: -0.5px; }
.hud-tiny { font-size: 14px; color: var(--dim); }

/* ---- Agent Score Panel ---- */
#score-panel {
  position: fixed; top: 44px; left: 14px;
  z-index: 12; display: flex; flex-direction: column; gap: 4px;
  pointer-events: none;
  transform: scale(var(--gui-scale));
  transform-origin: top left;
}
.score-agent {
  background: var(--surface);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 17px;
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 14px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.03);
}
.score-agent.red { border-left: 3px solid var(--soft-red); }
.score-agent.blue { border-left: 3px solid var(--soft-blue); }
.score-label {
  font-weight: 700; color: var(--text); min-width: 42px;
}
.score-wins {
  font-weight: 700; font-size: 15px; min-width: 36px;
  color: var(--soft-yellow);
}
.score-round {
  font-weight: 600; min-width: 50px;
}
.score-total {
  color: var(--dim); font-size: 13px;
  min-width: 40px;
}
.score-total::before { content: 'tot '; color: rgba(0,0,0,0.2); }
.score-punish {
  font-size: 13px; font-weight: 700;
  color: var(--soft-red);
  opacity: 0;
  transition: opacity 0.3s;
  letter-spacing: 0.5px;
}

/* ---- Top-right controls ---- */
#top-right {
  position: fixed; top: 10px; right: 14px;
  z-index: 15;
  display: flex; gap: 4px; align-items: flex-start;
  flex-wrap: wrap; justify-content: flex-end;
  max-width: 280px;
  pointer-events: auto;
  transform: scale(var(--gui-scale));
  transform-origin: top right;
}

.ctrl-btn {
  padding: 7px 15px;
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  color: var(--dim); font-family: var(--mono);
  font-size: 14px; font-weight: 600;
  border-radius: 14px; cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 6px rgba(0,0,0,0.03);
  white-space: nowrap;
}
.ctrl-btn:hover { color: var(--text); border-color: rgba(0,0,0,0.14); }
.ctrl-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---- Bottom bar ---- */
#bottom-bar {
  position: fixed; bottom: 10px; left: 50%; transform: translateX(-50%) scale(var(--gui-scale)); transform-origin: bottom center;
  z-index: 15; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: auto;
}

.hud-group {
  display: flex; gap: 5px; align-items: center;
  background: rgba(255,255,255,0.4);
  padding: 6px 11px; border-radius: 20px;
  backdrop-filter: blur(10px);
}

.group-label {
  font-family: var(--mono); font-size: 13px; color: var(--dim);
  text-transform: uppercase; margin-right: 4px; opacity: 0.7;
}

.bottom-pill {
  background: var(--surface);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: 14px; padding: 7px 17px;
  font-family: var(--mono); font-size: 14px;
  color: var(--dim); cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 6px rgba(0,0,0,0.03);
}
.bottom-pill:hover { color: var(--text); }
.bottom-pill.active { color: var(--accent); border-color: rgba(108,140,255,0.3); }

/* ---- Mode indicator ---- */
#mode-indicator {
  position: fixed; top: 44px; left: 50%; transform: translateX(-50%) scale(var(--gui-scale)); transform-origin: top center;
  z-index: 12;
  font-family: var(--mono); font-size: 15px;
  color: var(--dim);
  background: var(--surface);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 17px;
  pointer-events: none;
  opacity: 0; transition: opacity 0.3s;
}
#mode-indicator.show { opacity: 1; }

/* ---- Mobile Controls ---- */
#mobile-controls {
  display: none; position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 20; padding: 14px;
  pointer-events: none;
  transform: scale(var(--gui-scale));
  transform-origin: bottom left;
}
@media (hover: none) and (pointer: coarse), (max-width: 768px) {
  #mobile-controls { display: flex; justify-content: space-between; align-items: flex-end; }
  #bottom-bar { bottom: 80px; }
}

#joystick-zone { width: 120px; height: 120px; position: relative; pointer-events: auto; touch-action: none; }
#joystick-base {
  width: 100px; height: 100px; border-radius: 50%;
  background: rgba(0,0,0,0.04); border: 2px solid rgba(0,0,0,0.08);
  position: absolute; bottom: 0; left: 0;
}
#joystick-stick {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0,0,0,0.08); border: 2px solid rgba(0,0,0,0.12);
  position: absolute; bottom: 30px; left: 30px;
}
.action-buttons { display: flex; gap: 8px; pointer-events: auto; }
.action-btn {
  width: 48px; height: 48px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.08); background: rgba(255,255,255,0.45);
  color: var(--text); font-family: var(--mono); font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px); touch-action: manipulation;
}
.action-btn:active { background: rgba(0,0,0,0.06); transform: scale(0.92); }

/* ---- Start Overlay ---- */
#overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(232,228,222,0.92);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
}
#overlay.hidden { display: none; }
#overlay h1 {
  font-size: clamp(26px, 6vw, 50px); font-weight: 900;
  letter-spacing: 2px; color: var(--text);
  margin-bottom: 8px;
}
.subtitle {
  font-size: 16px; color: var(--dim);
  max-width: 400px; text-align: center;
  line-height: 1.5; margin-bottom: 30px;
  padding: 0 20px;
}
.overlay-modes { display: flex; gap: 12px; }
.btn-mode {
  padding: 14px 28px; border-radius: 16px;
  font-family: var(--mono); font-size: 15px; font-weight: 700;
  cursor: pointer; border: none; transition: all 0.2s;
}
.btn-mode.primary { background: var(--accent); color: #fff; }
.btn-mode.red { background: var(--soft-red); color: #fff; }
.btn-mode.blue { background: var(--soft-blue); color: #fff; }
.btn-mode:hover { transform: translateY(-2px); filter: brightness(1.05); }

/* ---- Evolution Banner ---- */
#evo-banner {
  position: fixed; top: 100px; left: 50%; transform: translateX(-50%) translateY(-20px);
  z-index: 100; background: var(--surface-solid);
  padding: 20px 40px; border-radius: 24px; border: 1px solid var(--accent);
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  text-align: center; pointer-events: none;
  opacity: 0; transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#evo-banner.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#evo-banner h2 { color: var(--accent); font-weight: 900; font-size: 24px; margin-bottom: 4px; }
#evo-banner p { color: var(--dim); font-family: var(--mono); font-size: 14px; }

/* ---- Log List ---- */
#event-log {
  position: fixed; bottom: 14px; left: 14px;
  z-index: 10; display: flex; flex-direction: column; gap: 4px;
}
.log-entry {
  background: var(--surface);
  backdrop-filter: blur(var(--blur));
  padding: 5px 14px; border-radius: 10px;
  font-family: var(--mono); font-size: 12px;
  color: var(--dim); border: 1px solid var(--border);
  animation: logSlide 0.3s ease-out;
}
@keyframes logSlide {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---- Mobile Specialized UI ---- */
#mobile-menu-btn {
  display: none;
  position: fixed; top: 10px; right: 10px;
  z-index: 100;
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-family: var(--mono);
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  cursor: pointer;
}

#mobile-window {
  display: none;
  position: fixed; inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  justify-content: center; align-items: center;
  padding: 20px;
}

.mobile-window-content {
  background: var(--surface-solid);
  width: 100%; max-width: 400px;
  max-height: 80vh;
  border-radius: 24px;
  padding: 24px;
  display: flex; flex-direction: column; gap: 16px;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}

.mobile-window-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}

.mobile-window-header h3 {
  font-family: var(--sans); font-weight: 900; color: var(--text);
}

#close-mobile-window {
  background: var(--border);
  border: none; padding: 8px 16px; border-radius: 10px;
  font-family: var(--mono); cursor: pointer;
}

.mobile-section {
  display: flex; flex-direction: column; gap: 8px;
}

.mobile-section h4 {
  font-size: 12px; text-transform: uppercase; color: var(--dim); letter-spacing: 1px;
}

.mobile-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}

body.mobile-mode #top-right { display: none !important; }
body.mobile-mode #mobile-menu-btn { display: block; }

body.no-gui #hud,
body.no-gui #score-panel,
body.no-gui #top-right,
body.no-gui #bottom-bar,
body.no-gui #event-log,
body.no-gui #mode-indicator,
body.no-gui #lang-select,
body.no-gui #back-btn,
body.no-gui #mobile-menu-btn {
  display: none !important;
}
