h1 {
  margin: 20px 0 10px;
  font-size: clamp(1.6rem, 3.5vw + 1rem, 3rem);
  color: #0b5285;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

html.dark-mode h1 {
  color: #bada55 !important;
}

@media (max-width: 500px) {
  h1 {
    font-size: 2rem; 
    margin: 10px 0;
  }
}

.game-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-grow: 1;
  padding: 0 20px 20px 20px;
}

.game-container {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 35px;
  padding: 10px;
  margin: 10px auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 650px;
  box-shadow: 8px 8px 0 #0b74bf;
  border: 2.5px solid #0b74bf;
  min-height: 100dvh;
  box-sizing: border-box;
  backdrop-filter: blur(10px);
}

html.dark-mode .game-container {
  background: linear-gradient(225deg, #1f3b57 0%, #284c76 60%, #181f29 100%) !important;
}

/* ── Stacked layout (mobile default) ── */
.game-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 95%;
  gap: 8px;
}

.game-sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 6px;
}

canvas {
  aspect-ratio: 1 / 1;
  width: 100%;
  max-width: 600px;
  display: block;
  margin: 0 auto;
  min-width: 0;       
  touch-action: none;
  border: 3px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.95);
  border-radius: 10px;
  border-color: #0b74bf;
  cursor: crosshair;
  box-shadow: 0 0 10px #0b74bf;
}

html.dark-mode canvas {
  background: rgba(40, 50, 70, 0.95) !important;
  border-color: #4ecdc4 !important;
  box-shadow: 0 0 10px #4ecdc4 !important;
}

.win-count {
    font-size: 0.78em;
    opacity: 0.65;
    font-weight: normal;
}

/* ── Large screen: canvas left, sidebar right ── */
@media (min-width: 900px) {
  .game-container {
    max-width: 920px;
    min-height: auto;
  }

  .game-body {
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 5px;
  }

  canvas {
    flex-shrink: 0;
    max-width: min(60vmin, 500px);
  }

  .game-sidebar {
    width: 260px;
    min-width: 200px;
    flex-shrink: 0;
    align-items: center;
    padding-top: 4px;
  }

  .score-display {
    width: 100%;
    flex-direction: row;
  }

  #status {
    text-align: left;
    width: 100%;
  }

  .settings-section,
  .controls {
    justify-content: flex-start;
  }

  .instructions {
    text-align: left;
  }
}

.intro.sm { 
  max-width: 40ch; 
  margin: 0.25rem auto 0.75rem; 
  font-size: 0.95rem; 
}

#status {
  margin: 15px 0;
  font-size: 18px;
  text-align: center;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
  min-height: 28px;
}

html.dark-mode #status {
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5) !important;
}

.controls {
  display: flex;
  gap: 8px;
  margin: 10px 0;
  flex-wrap: wrap;
  justify-content: center;
}

button {
  padding: 10px 15px;
  font-size: 14px;
  margin: 0px;
  border: none;
  border-radius: 25px;
  background: linear-gradient(135deg, #0b17c7, #5474f4);
  color: white;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

button:active {
  transform: translateY(0);
}

html.dark-mode button {
  box-shadow: 0 4px 15px rgba(0,0,0,0.4) !important;
}

html.dark-mode button:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.6) !important;
}

/* Difficulty buttons */
.difficulty-btn {
  background: linear-gradient(135deg, #667eea, #4099f7);
  font-size: 13px;
  padding: 8px 12px;
}

.difficulty-btn.active {
  background: linear-gradient(135deg, #c7f72b, #bada55);
  color: #0b17c7;
  box-shadow: 0 0 20px rgba(6, 182, 41, 0.6);
}

html.dark-mode .difficulty-btn.active {
  color: #0b17c7 !important;
  box-shadow: 0 0 20px rgba(172, 235, 46, 0.8) !important;
}

.score-display {
  display: flex;
  justify-content: space-between;
  width: 300px;
  margin: 10px 0;
  gap: 10px;
}

.score-item {
  background: rgba(255, 255, 255, 0.2);
  padding: 10px 5px;
  border-radius: 15px;
  font-weight: bold;
  transition: transform 0.2s;
  flex: 1;
  text-align: center;
}

html.dark-mode .score-item {
  background: rgba(255, 255, 255, 0.1) !important;
}

.player-score {
  color: #4ecdc4;
}

.computer-score {
  color: #ff6b6b;
}

html.dark-mode .player-score {
  color: #5eeee5 !important;
}

html.dark-mode .computer-score {
  color: #ff8b8b !important;
}

.instructions {
  max-width: 500px;
  text-align: center;
  margin: 10px 0;
  font-size: 14px;
  opacity: 0.8;
}

html.dark-mode .instructions {
  opacity: 0.7 !important;
}

/* Settings section for difficulty controls */
.settings-section {
  margin: 10px 0;
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
}

.settings-label {
  font-size: 14px;
  font-weight: bold;
  margin-right: 5px;
}

html.dark-mode .settings-label {
  color: #bada55 !important;
}

/* Session Best Ribbon */
.ribbon { 
  position: fixed; 
  top: 12px; 
  right: 12px; 
  background: linear-gradient(135deg, rgba(34, 88, 170, 0.925), rgba(4, 39, 194, 0.87));
  color: #fff; 
  padding: 10px 16px; 
  border-radius: 10px; 
  font-weight: 700; 
  box-shadow: 0 6px 14px rgba(0,0,0,.25); 
  z-index: 9999; 
}

html.dark-mode .ribbon {
  background: linear-gradient(135deg, rgba(1, 25, 131, 0.918), rgba(41, 2, 184, 0.897)) !important;
  box-shadow: 0 6px 14px rgba(0,0,0,.5) !important;
}

.pulse { 
  animation: pulse .8s ease-in-out 2; 
}

@keyframes pulse { 
  0% { transform: scale(1); } 
  50% { transform: scale(1.08); } 
  100% { transform: scale(1); } 
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

html.dark-mode .modal {
  background-color: rgba(0, 0, 0, 0.9) !important;
}

.modal-content {
  background: linear-gradient(135deg, #0b74bf 0%, #1e2feb 100%);
  margin: auto;                      
  padding: clamp(20px, 4vw, 40px);
  border: none;
  border-radius: 20px;
  width: 90%;
  max-width: 500px;
  max-height: 90dvh;              
  overflow-y: auto;                
  text-align: center;
  color: white;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modalSlideIn 0.5s ease-out;
}

html.dark-mode .modal-content {
  background: linear-gradient(135deg, #1f3b57 0%, #2a4d7f 100%) !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8) !important;
  border: 2px solid rgba(78, 205, 196, 0.3) !important;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-50px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal h2 {
  font-size: 2.5em;
  color: #fff;
  margin: 0 0 20px 0;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

html.dark-mode .modal h2 {
  color: #bada55 !important;
  text-shadow: 2px 2px 8px rgba(0,0,0,0.6) !important;
}

.modal .final-score {
  font-size: 1.5em;
  margin: 20px 0;
  background: rgba(255, 255, 255, 0.2);
  padding: 15px;
  border-radius: 15px;
}

html.dark-mode .modal .final-score {
  background: rgba(255, 255, 255, 0.1) !important;
}

.modal button {
  font-size: 18px;
  padding: 15px 30px;
  margin: 10px;
  background: linear-gradient(135deg, #4ecdc4, #44a08d);
}

html.dark-mode .modal button {
  background: linear-gradient(135deg, #5eeee5, #54b09d) !important;
}

.close {
  color: rgba(255, 255, 255, 0.7);
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.3s;
}

.close:hover,
.close:focus {
  color: white;
}

html.dark-mode .close {
  color: rgba(186, 218, 85, 0.7) !important;
}

html.dark-mode .close:hover,
html.dark-mode .close:focus {
  color: #bada55 !important;
}

/* Hover effects for click areas */
.hover-area {
  stroke: rgba(0, 0, 0, 0.2);
  stroke-width: 8;
  opacity: 0;
  transition: opacity 0.2s;
}

.hover-area:hover {
  opacity: 0.5;
}