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

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

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #0a0a1a;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app { width: 100%; height: 100%; position: relative; }
#game-canvas { width: 100%; height: 100%; display: block; }

#ui-overlay {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

#top-bar {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 14px 16px;
  pointer-events: auto; flex-wrap: wrap;
}

#turn-indicator {
  background: rgba(15, 15, 35, 0.75);
  backdrop-filter: blur(20px);
  color: #e0e0e0; padding: 10px 24px;
  border-radius: 28px; font-size: 15px;
  font-weight: 600; letter-spacing: 0.6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center; min-width: 170px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

#turn-indicator.red-turn {
  background: rgba(200, 50, 50, 0.25);
  color: #ff8888;
  border-color: rgba(255, 80, 80, 0.3);
  box-shadow: 0 4px 24px rgba(255, 50, 50, 0.15);
}

#turn-indicator.blue-turn {
  background: rgba(50, 50, 200, 0.25);
  color: #8888ff;
  border-color: rgba(80, 80, 255, 0.3);
  box-shadow: 0 4px 24px rgba(50, 50, 255, 0.15);
}

#turn-indicator.game-over {
  background: linear-gradient(135deg, rgba(255, 170, 50, 0.2), rgba(255, 80, 80, 0.2));
  border-color: rgba(255, 170, 50, 0.4);
  color: #ffd700; font-size: 17px;
  box-shadow: 0 4px 30px rgba(255, 170, 50, 0.2);
}

/* AI Controls */
#ai-controls {
  display: flex; align-items: center; gap: 8px;
  background: rgba(15, 15, 35, 0.7);
  backdrop-filter: blur(15px);
  padding: 6px 14px; border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.toggle-label {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
}

.toggle-label input { display: none; }

.toggle-slider {
  width: 32px; height: 18px; border-radius: 9px;
  background: rgba(255, 255, 255, 0.15);
  position: relative; transition: background 0.3s;
}

.toggle-slider::after {
  content: ''; position: absolute;
  width: 14px; height: 14px; border-radius: 50%;
  background: #888; top: 2px; left: 2px;
  transition: all 0.3s;
}

.toggle-label input:checked + .toggle-slider {
  background: rgba(80, 180, 120, 0.4);
}

.toggle-label input:checked + .toggle-slider::after {
  background: #50b478; transform: translateX(14px);
}

.toggle-text {
  color: #aaa; font-size: 12px; font-weight: 600;
  letter-spacing: 1px; text-transform: uppercase;
}

#ai-difficulty {
  background: rgba(255, 255, 255, 0.08);
  color: #ccc; border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px; padding: 4px 8px; font-size: 12px;
  font-family: inherit; cursor: pointer; outline: none;
}

#ai-difficulty option { background: #1a1a2e; color: #ccc; }

/* Button */
#btn-reset {
  background: rgba(15, 15, 35, 0.7);
  backdrop-filter: blur(15px);
  color: #ccc; border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%; width: 40px; height: 40px;
  font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s;
}

#btn-reset:hover {
  background: rgba(255, 100, 100, 0.15);
  border-color: rgba(255, 100, 100, 0.3);
  color: #ff6666;
}

/* Status */
#status-bar {
  text-align: center; color: #88ccaa;
  font-size: 14px; font-weight: 500;
  padding: 4px 16px; min-height: 24px;
  pointer-events: none;
}

/* AI Thinking */
#ai-thinking {
  position: absolute; bottom: 40px; left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 15, 35, 0.85);
  backdrop-filter: blur(15px);
  color: #88aaff; padding: 10px 24px;
  border-radius: 20px; font-size: 13px;
  font-weight: 500; letter-spacing: 0.5px;
  border: 1px solid rgba(100, 150, 255, 0.15);
  pointer-events: none;
  opacity: 0; transition: opacity 0.3s;
}

#ai-thinking.visible { opacity: 1; }

.dots::after {
  content: ''; animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

/* Language Selector */
.lang-select {
  background: rgba(15, 15, 35, 0.7);
  backdrop-filter: blur(15px);
  color: #ccc; border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px; padding: 6px 10px;
  font-size: 13px; font-family: inherit;
  cursor: pointer; outline: none;
}

.lang-select option { background: #1a1a2e; color: #ccc; }

/* Game Nav */
.game-nav {
  display: flex; gap: 8px;
}

.game-nav-link {
  color: #8888cc; text-decoration: none;
  font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: 12px;
  background: rgba(15, 15, 35, 0.5);
  border: 1px solid rgba(100, 100, 200, 0.15);
  transition: all 0.3s;
}

.game-nav-link:hover {
  color: #aaaaff;
  border-color: rgba(100, 100, 200, 0.4);
  background: rgba(30, 30, 60, 0.6);
}

/* Mobile */
@media (max-width: 600px) {
  #top-bar { padding: 8px; gap: 6px; }
  #turn-indicator { font-size: 13px; padding: 8px 16px; min-width: auto; }
  #ai-controls { padding: 4px 10px; }
  .game-nav-link { font-size: 10px; padding: 4px 8px; }
}

/* ── Enhanced Mobile ── */
@media (max-width: 480px) {
  #top-bar {
    gap: 5px;
    padding: 8px 8px;
  }
  #turn-indicator {
    font-size: 12px;
    padding: 6px 12px;
    min-width: auto;
    border-radius: 16px;
  }
  #ai-controls {
    padding: 3px 8px;
    gap: 4px;
    border-radius: 16px;
  }
  .toggle-text { font-size: 10px; }
  .toggle-slider { width: 28px; height: 16px; }
  .toggle-slider::after { width: 12px; height: 12px; }
  .toggle-label input:checked + .toggle-slider::after { transform: translateX(12px); }
  #ai-difficulty { font-size: 10px; padding: 3px 6px; }
  #btn-reset { width: 34px; height: 34px; font-size: 16px; }
  #status-bar { font-size: 12px; }
  .game-nav-link { font-size: 9px; padding: 3px 6px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  #top-bar { padding: 4px 8px; }
  #turn-indicator { padding: 4px 10px; font-size: 11px; }
  #btn-reset { width: 30px; height: 30px; font-size: 14px; }
}
