:root {
  --primary-color: #4a4a4a;
  --accent-color: #50c878;
  --bg-color: #1a1a1a;
  --text-color: #ffffff;
  --grid-color: #2a2a2a;
  --modal-bg: rgba(0, 0, 0, 0.8);
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg-color);
  font-family: 'Press Start 2P', cursive;
  color: var(--text-color);
  overscroll-behavior: none;
}

.game-wrapper {
  display: flex;
  gap: 20px;
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.game-container {
  padding: 20px;
  background: var(--primary-color);
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: fadeIn 0.5s ease-in;
}

.game-header {
  text-align: center;
}

.lang-switcher {
  margin: 0 auto 10px;
}

.lang-switcher select {
  background: var(--bg-color);
  color: var(--text-color);
  border: 2px solid var(--accent-color);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: 'Press Start 2P', cursive;
  font-size: 10px;
}

h1 {
  font-size: 2em;
  margin-bottom: 20px;
  color: var(--accent-color);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.score-container {
  font-size: 1.2em;
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 10px;
}

.score-value {
  color: var(--accent-color);
}

.canvas-container {
  padding: 10px;
  background: var(--grid-color);
  border-radius: 5px;
  border: 4px solid var(--accent-color);
}

canvas {
  display: block;
  background: #000;
  border-radius: 2px;
  touch-action: none;
  user-select: none;
}

.controls {
  text-align: center;
}

.control-info {
  font-size: 0.8em;
  margin-bottom: 15px;
}

button {
  padding: 10px 20px;
  font-family: 'Press Start 2P', cursive;
  background: var(--accent-color);
  border: none;
  border-radius: 5px;
  color: var(--text-color);
  cursor: pointer;
  transition: transform 0.2s, background-color 0.2s;
}

button:hover {
  transform: scale(1.05);
  background-color: #60d888;
}

/* Floating score text */
.floating-score {
  font-family: 'Press Start 2P', cursive;
  font-size: 12px;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  pointer-events: none;
}

/* Pause overlay */
.pause-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.35);
}
.pause-overlay .pause-text {
  font-family: 'Press Start 2P', cursive;
  color: var(--accent-color);
  font-size: 18px;
  letter-spacing: 2px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.7);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--modal-bg);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal {
  background: var(--primary-color);
  padding: 20px;
  border-radius: 10px;
  min-width: 300px;
  max-width: 500px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.modal h2 {
  color: var(--accent-color);
  margin-bottom: 20px;
  text-align: center;
  font-size: 1.2em;
}

/* Login form */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.login-form input {
  padding: 10px;
  font-family: inherit;
  background: var(--bg-color);
  border: 2px solid var(--accent-color);
  color: var(--text-color);
  border-radius: 5px;
  font-size: 0.8em;
}

/* Leaderboard table */
.leaderboard {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.leaderboard th,
.leaderboard td {
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid var(--grid-color);
  font-size: 0.7em;
}

.leaderboard th {
  color: var(--accent-color);
  font-weight: normal;
}

.leaderboard tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.05);
}

.leaderboard tr.current-player {
  background: rgba(80, 200, 120, 0.2);
}

/* Top-10 sidebar */
.top-players-sidebar {
  background: var(--primary-color);
  border-radius: 10px;
  padding: 20px;
  min-width: 300px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent-color);
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7em;
  color: #50c878;
}

.pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #50c878;
  animation: pulse 2s infinite;
}

.top-players-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.player-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 5px;
  transition: transform 0.2s;
}

.player-card:hover {
  transform: translateX(5px);
  background: rgba(255, 255, 255, 0.1);
}

.player-card.current-player {
  background: rgba(80, 200, 120, 0.2);
  border-left: 3px solid var(--accent-color);
}

.player-rank {
  font-size: 1.2em;
  color: var(--accent-color);
  min-width: 30px;
}

.player-info {
  flex-grow: 1;
  padding: 0 10px;
}

.player-name {
  font-size: 0.8em;
  margin-bottom: 4px;
}

.flag-emoji {
  margin-right: 6px;
  filter: saturate(1.1);
}

.player-score {
  font-size: 1em;
  color: var(--accent-color);
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(80, 200, 120, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 10px rgba(80, 200, 120, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(80, 200, 120, 0);
  }
}

/* Responsive layout */
@media (max-width: 1024px) {
  .game-wrapper {
    flex-direction: column;
    align-items: center;
    padding: 10px;
  }

  .game-container {
    width: 100%;
    max-width: 600px;
    margin-bottom: 20px;
  }

  .top-players-sidebar {
    width: 100%;
    max-width: 600px;
    margin-top: 20px;
  }

  canvas {
    width: 100% !important;
    height: auto !important;
    max-width: 600px;
  }
}

@media (max-width: 768px) {
  .game-container {
    padding: 10px;
  }

  h1 {
    font-size: 1.2em;
  }

  .score-container {
    font-size: 0.9em;
  }

  .game-header {
    flex-direction: column;
    gap: 10px;
  }

  .modal {
    width: 90%;
    max-width: 400px;
    padding: 15px;
  }

  .leaderboard {
    font-size: 0.9em;
  }

  .leaderboard td, .leaderboard th {
    padding: 6px;
  }

  .player-card {
    padding: 8px;
  }

  .controls {
    flex-direction: column;
    gap: 10px;
  }

  .control-info p {
    font-size: 0.8em;
  }

  .restart-btn, .leaderboard-btn {
    width: 100%;
    margin: 5px 0;
    padding: 10px;
  }

  .canvas-container {
    margin-bottom: 10px;
  }

  .mobile-controls {
    margin-top: 15px;
  }

  .control-btn {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }

  .game-wrapper {
    flex-direction: column;
  }

  .online-players-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    transform: translateX(-100%);
    z-index: 1000;
    background: rgba(42, 42, 42, 0.95);
  }

  .online-players-sidebar.visible {
    transform: translateX(0);
  }

  .mobile-indicator {
    display: flex;
  }

  .game-container {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .game-container {
    padding: 5px;
  }

  h1 {
    font-size: 1em;
  }

  .score-container {
    font-size: 0.8em;
  }

  .players-online {
    font-size: 0.7em;
  }

  .modal {
    width: 95%;
    padding: 10px;
  }

  .leaderboard td, .leaderboard th {
    padding: 4px;
    font-size: 0.8em;
  }

  .player-card {
    padding: 6px;
  }

  .player-name {
    font-size: 0.7em;
  }

  .player-score {
    font-size: 0.8em;
  }

  .player-date {
    font-size: 0.6em;
  }

  .control-btn {
    width: 45px;
    height: 45px;
    font-size: 18px;
  }

  .player-card {
    padding: 8px;
  }

  .player-name {
    font-size: 0.7em;
  }

  .player-score {
    font-size: 0.8em;
  }

  .player-date {
    font-size: 0.6em;
  }

  .control-btn {
    width: 45px;
    height: 45px;
    font-size: 18px;
  }

  .mobile-controls-row {
    gap: 15px;
  }
}

/* Touch devices */
@media (hover: none) {
  .player-card:hover {
    transform: none;
  }

  .restart-btn:hover, .leaderboard-btn:hover {
    transform: none;
  }

  .button:active {
    transform: scale(0.95);
  }
}

/* Players counter */
.players-online {
  font-size: 0.8em;
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 10px;
  color: var(--text-color);
}

.players-count {
  color: var(--accent-color);
  font-weight: bold;
  animation: pulse 2s infinite;
}

/* Player card date */
.player-date {
  font-size: 0.6em;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 4px;
}

/* Leaderboard date column */
.leaderboard td:last-child {
  font-size: 0.6em;
  color: rgba(255, 255, 255, 0.8);
}

/* Players counter animation */
@keyframes countChange {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
    color: #60d888;
  }
  100% {
    transform: scale(1);
  }
}

.players-count.changed {
  animation: countChange 0.3s ease-out;
}

/* Mobile controls */
.mobile-controls {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
}

.mobile-controls-row {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.control-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent-color);
  color: var(--text-color);
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s, background-color 0.2s;
}

.control-btn:active {
  transform: scale(0.95);
  background-color: #60d888;
}

/* Show mobile controls only on touch devices */
@media (hover: none) and (pointer: coarse) {
  .mobile-controls {
    display: flex;
  }
}

/* Left-handed layout helper */
body.lefty .mobile-controls {
  align-items: flex-start;
}
body.lefty .mobile-controls-row {
  justify-content: flex-start;
}

/* Options under controls */
.options {
  margin-top: 10px;
  display: flex;
  gap: 16px;
  font-size: 10px;
  justify-content: center;
}
.options input { vertical-align: middle; }
.options label { cursor: pointer; user-select: none; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Online players sidebar */
.online-players-sidebar {
  width: 200px;
  background: rgba(42, 42, 42, 0.95);
  border-radius: 10px;
  padding: 15px;
  color: #fff;
  position: relative;
  flex-shrink: 0;
  will-change: transform;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.online-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 10px;
}

.online-header h3 {
  margin: 0;
  font-size: 1.2em;
  color: #50c878;
}

.toggle-sidebar {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 1.2em;
  padding: 5px;
  transition: transform 0.3s;
}

.toggle-sidebar.collapsed {
  transform: rotate(180deg);
}

.online-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  will-change: contents;
}

.online-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 5px;
  will-change: transform, opacity;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.online-player.playing {
  background: rgba(80, 200, 120, 0.1);
}

.online-player.current {
  border: 1px solid #50c878;
}

.player-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #50c878;
  flex-shrink: 0;
}

.player-status.idle {
  background: #ffd700;
}

.player-name {
  font-size: 0.9em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-grow: 1;
}

.mobile-indicator {
  display: none;
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  background: #50c878;
  padding: 10px;
  border-radius: 0 5px 5px 0;
  cursor: pointer;
  z-index: 1000;
}

.player-count {
  color: white;
  font-weight: bold;
}

/* Media queries */
@media (max-width: 768px) {
  .game-wrapper {
    flex-direction: column;
  }

  .online-players-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    z-index: 1000;
    border-radius: 0 10px 10px 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
  }

  .online-players-sidebar.visible {
    transform: translateX(0);
  }

  .mobile-indicator {
    display: flex;
  }

  .game-container {
    width: 100%;
  }
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.online-player {
  animation: fadeIn 0.3s ease;
} 
