/* General body styling */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  margin: 0;
  padding: 10px;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  color: #ffffff;
  position: relative;
  overflow-x: hidden;
}

/* Background pattern */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.02) 25%,
      transparent 25%
    ),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.02) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.02) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.02) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  z-index: -1;
}

/* Main container for the game */
.game-container {
  max-width: 100%;
  margin: 0 auto;
  padding: 10px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

/* Game title */
#title {
  text-align: center;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 700;
  margin-bottom: 20px;
  color: #ffffff;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
  letter-spacing: 2px;
}

/* Control buttons container */
.controls {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

.control-btn {
  width: clamp(35px, 8vw, 50px);
  height: clamp(35px, 8vw, 50px);
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  color: white;
}

.control-btn.refresh {
  background: linear-gradient(135deg, #3498db, #2980b9);
}

.control-btn.home {
  background: linear-gradient(135deg, #34495e, #2c3e50);
}

.control-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.control-btn svg {
  width: clamp(16px, 4vw, 24px);
  height: clamp(16px, 4vw, 24px);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* Game stats (move counter and timer) */
.game-stats {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

.stat-item {
  background: rgba(233, 175, 81, 0.1);
  border: 2px solid #e9af51;
  border-radius: 8px;
  padding: clamp(6px, 2vw, 12px) clamp(8px, 2.5vw, 16px);
  text-align: center;
  backdrop-filter: blur(10px);
  box-shadow: 0 0 20px rgba(233, 175, 81, 0.3);
  min-width: clamp(50px, 15vw, 80px);
}

.stat-label {
  font-size: clamp(0.7rem, 2.5vw, 0.9rem);
  font-weight: 600;
  color: #e9af51;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: clamp(1rem, 3.5vw, 1.4rem);
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 0 10px rgba(233, 175, 81, 0.5);
}

/* Final stats in game over modal */
.final-stats {
  margin-top: 15px;
  padding: 12px;
  background: rgba(233, 175, 81, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(233, 175, 81, 0.3);
}

.final-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 6px 0;
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
}

.final-stat-label {
  color: #e9af51;
  font-weight: 600;
}

.final-stat-value {
  color: #ffffff;
  font-weight: 700;
}

/* Game board styling */
.board {
  position: relative;
  width: clamp(280px, 80vw, 500px);
  height: clamp(280px, 80vw, 500px);
  margin: 0 auto;
  background: rgba(44, 62, 80, 0.3);
  border-radius: clamp(12px, 3vw, 20px);
  border: 2px solid rgba(52, 152, 219, 0.3);
  box-shadow: 0 0 30px rgba(52, 152, 219, 0.2),
    inset 0 0 30px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  padding: clamp(10px, 3vw, 20px);
}

/* Turn indicator in board left top corner */
.board-turn-indicator {
  position: absolute;
  top: clamp(8px, 2vw, 20px);
  left: clamp(8px, 2vw, 20px);
  width: clamp(35px, 10vw, 60px);
  height: clamp(35px, 10vw, 60px);
  background: rgba(233, 175, 81, 0.1);
  border: 2px solid #e9af51;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(10px);
  box-shadow: 0 0 20px rgba(233, 175, 81, 0.3);
}

/* Turn indicator in board right top corner for thief */
.board-turn-indicator.thief-turn {
  left: auto;
  right: clamp(8px, 2vw, 20px);
  background: rgba(155, 89, 182, 0.1);
  border: 2px solid #9b59b6;
  box-shadow: 0 0 20px rgba(155, 89, 182, 0.3);
}

.turn-icon-board {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.turn-icon-text {
  font-size: clamp(14px, 4vw, 24px);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

/* Unified node styling */
.node {
  width: clamp(35px, 10vw, 60px);
  height: clamp(35px, 10vw, 60px);
  border-radius: 50%;
  position: absolute;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4),
    inset 0 2px 4px rgba(255, 255, 255, 0.1);
  background: linear-gradient(145deg, #34495e, #2c3e50);
  border: 3px solid #5e7a96;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: clamp(16px, 4.5vw, 30px);
  z-index: 2;
}

.node:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5),
    inset 0 2px 4px rgba(255, 255, 255, 0.2);
}

/* Styling for nodes that are valid moves */
.node.valid-move {
  background: linear-gradient(145deg, #27ae60, #2ecc71);
  border-color: #58d68d;
  box-shadow: 0 0 20px rgba(46, 204, 113, 0.5), 0 4px 15px rgba(0, 0, 0, 0.4);
}

/* Styling for the selected police unit */
.node.selected {
  border-color: #3498db;
  box-shadow: 0 0 25px rgba(52, 152, 219, 0.8), 0 4px 15px rgba(0, 0, 0, 0.4),
    inset 0 2px 4px rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

/* SVG icons for players */
.node svg {
  width: 60%;
  height: 60%;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5));
}

/* Line styling for connections */
.line {
  position: absolute;
  background: linear-gradient(90deg, #7f8c8d, #95a5a6);
  height: clamp(2px, 0.8vw, 4px);
  transform-origin: 0 50%;
  z-index: 1;
  border-radius: 2px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Message area styling */
#message {
  font-size: clamp(1rem, 3vw, 1.5rem);
  margin-bottom: 15px;
  height: 30px;
  text-align: center;
  color: #ffffff;
  font-weight: 600;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
  padding: 10px;
}

.modal-content {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 2px solid #e9af51;
  border-radius: clamp(12px, 3vw, 20px);
  padding: 0;
  max-width: clamp(300px, 90vw, 800px);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 0 50px rgba(233, 175, 81, 0.3);
  backdrop-filter: blur(10px);
}

/* Game over modal should be narrower */
#game-over-modal .modal-content {
  max-width: clamp(280px, 80vw, 400px);
}

.modal-header {
  background: linear-gradient(135deg, #e9af51, #f39c12);
  color: #1a1a2e;
  padding: clamp(12px, 3vw, 20px);
  border-radius: clamp(10px, 2.5vw, 18px) clamp(10px, 2.5vw, 18px) 0 0;
  text-align: center;
}

.modal-header h2 {
  margin: 0;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  font-weight: 700;
}

.modal-body {
  padding: clamp(15px, 4vw, 30px);
  color: #ffffff;
}

.game-rules h3 {
  color: #e9af51;
  margin-top: 15px;
  margin-bottom: 8px;
  font-size: clamp(1rem, 2.5vw, 1.2rem);
}

.rules-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(10px, 3vw, 20px);
  margin-top: 15px;
}

.rule-section {
  background: rgba(233, 175, 81, 0.05);
  border: 1px solid rgba(233, 175, 81, 0.2);
  border-radius: clamp(8px, 2vw, 12px);
  padding: clamp(10px, 3vw, 15px);
  backdrop-filter: blur(5px);
}

.rule-section h3 {
  color: #e9af51;
  margin-top: 0;
  margin-bottom: 8px;
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  text-align: left;
}

.rule-section p {
  margin: 0;
  line-height: 1.4;
  font-size: clamp(0.8rem, 2.2vw, 0.95rem);
}

.rule-section ul {
  margin: 8px 0;
  padding-left: 18px;
}

.rule-section li {
  margin: 4px 0;
  line-height: 1.4;
  font-size: clamp(0.75rem, 2vw, 0.9rem);
}

.game-rules ul {
  margin: 8px 0;
  padding-left: 18px;
}

.game-rules li {
  margin: 6px 0;
  line-height: 1.5;
  font-size: clamp(0.8rem, 2.2vw, 1rem);
}

.game-result {
  text-align: center;
  padding: 15px 0;
}

.result-icon {
  font-size: clamp(2rem, 8vw, 4rem);
  margin-bottom: 15px;
}

.game-result p {
  font-size: clamp(1rem, 3vw, 1.3rem);
  font-weight: 600;
  margin: 0;
}

.modal-footer {
  padding: clamp(12px, 3vw, 20px);
  display: flex;
  gap: clamp(8px, 2vw, 15px);
  justify-content: center;
  border-top: 1px solid rgba(233, 175, 81, 0.3);
  flex-wrap: wrap;
}

.btn-primary,
.btn-secondary {
  padding: clamp(8px, 2.5vw, 12px) clamp(16px, 4vw, 24px);
  border: none;
  border-radius: clamp(6px, 1.5vw, 10px);
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: clamp(80px, 25vw, 120px);
}

.btn-primary {
  background: linear-gradient(135deg, #e9af51, #f39c12);
  color: #1a1a2e;
  box-shadow: 0 4px 15px rgba(233, 175, 81, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(233, 175, 81, 0.4);
}

.btn-secondary {
  background: linear-gradient(135deg, #34495e, #2c3e50);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

/* Bottom accent line */
.bottom-accent {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, #e9af51, #f39c12, #e9af51);
  z-index: 100;
}

/* Styling for boat nodes */
.node.boat-node {
  background: linear-gradient(145deg, #2980b9, #3498db);
  border-color: #5dade2;
  box-shadow: 0 0 20px rgba(52, 152, 219, 0.6), 0 4px 15px rgba(0, 0, 0, 0.4);
  animation: boatFloat 3s ease-in-out infinite;
}

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

/* When thief is on boat, make it more prominent */
.node.boat-node.thief-on-boat {
  background: linear-gradient(145deg, #e74c3c, #c0392b);
  border-color: #e74c3c;
  box-shadow: 0 0 30px rgba(231, 76, 60, 0.8), 0 4px 15px rgba(0, 0, 0, 0.4);
  animation: boatFloat 1s ease-in-out infinite;
}

/* Mobile-first centering for game container */
@media (max-width: 767px) {
  .game-container {
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 10px;
  }
}

/* Responsive design for different screen sizes */
@media (min-width: 768px) {
  body {
    padding: 20px;
  }

  .game-container {
    padding: 20px;
  }

  .controls {
    top: 20px;
    left: 20px;
    gap: 10px;
  }

  .game-stats {
    top: 20px;
    right: 20px;
    gap: 15px;
  }

  .board {
    padding: 20px;
  }

  .board-turn-indicator {
    top: 20px;
    left: 20px;
  }

  .board-turn-indicator.thief-turn {
    right: 20px;
  }

  .rules-grid {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
  }

  .modal-footer {
    flex-wrap: nowrap;
  }
}

@media (min-width: 1024px) {
  .game-container {
    max-width: 1200px;
  }

  .board {
    width: 500px;
    height: 500px;
  }

  .node {
    width: 60px;
    height: 60px;
    font-size: 30px;
  }

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

  .control-btn svg {
    width: 24px;
    height: 24px;
  }

  .board-turn-indicator {
    width: 60px;
    height: 60px;
  }

  .turn-icon-text {
    font-size: 24px;
  }

  .line {
    height: 4px;
  }

  .stat-item {
    padding: 12px 16px;
    min-width: 80px;
  }

  .stat-label {
    font-size: 0.9rem;
  }

  .stat-value {
    font-size: 1.4rem;
  }
}

@media (max-width: 480px) {
  body {
    padding: 5px;
  }

  .game-container {
    padding: 5px;
    justify-content: center;
    min-height: 100vh;
  }

  .controls {
    top: 5px;
    left: 5px;
    gap: 5px;
  }

  .game-stats {
    top: 5px;
    right: 5px;
    gap: 5px;
  }

  .board {
    padding: 8px;
  }

  .board-turn-indicator {
    top: 8px;
    left: 8px;
  }

  .board-turn-indicator.thief-turn {
    right: 8px;
  }

  .modal-body {
    padding: 15px;
  }

  .modal-footer {
    flex-direction: column;
    align-items: center;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
    max-width: 200px;
  }
}

/* Landscape orientation for mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .game-container {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 20px;
  }

  .board {
    width: clamp(200px, 40vh, 300px);
    height: clamp(200px, 40vh, 300px);
  }

  .controls {
    position: relative;
    top: auto;
    left: auto;
    flex-direction: row;
  }

  .game-stats {
    position: relative;
    top: auto;
    right: auto;
    flex-direction: row;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .node {
    border-width: 2px;
  }

  .line {
    height: 2px;
  }
}

/* Touch devices */
@media (hover: none) and (pointer: coarse) {
  .node:hover {
    transform: none;
  }

  .btn-primary:hover,
  .btn-secondary:hover {
    transform: none;
  }

  .control-btn:hover {
    transform: none;
  }

  .node {
    min-width: 44px;
    min-height: 44px;
  }

  .control-btn {
    min-width: 44px;
    min-height: 44px;
  }
}
