@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* Base styles for mobile-first responsive layout */
body {
  margin: 0;
  background: #000;
  color: #0ff;
  font-family: 'Press Start 2P', cursive;
  font-size: 12px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0 70px 0;
  box-sizing: border-box;
}

#game-header, #game-footer {
  width: 100vw;
  text-align: center;
  color: #0ff;
  font-family: inherit;
  text-shadow: 0 0 12px #0ff, 0 0 2px #fff;
  position: fixed;
  left: 0;
  z-index: 100;
  background: #000;
}
#game-header {
  top: 0;
  font-size: 1.2em;
  padding: 12px 0 8px 0;
  letter-spacing: 1px;
}
#game-footer {
  bottom: 0;
  font-size: 0.9em;
  padding: 10px 0 8px 0;
  letter-spacing: 1px;
}
#game-footer a { color: #0ff; text-decoration: underline; }


.time{
  line-height:1.92rem;
}

#game-container {
  display: flex;
  flex-direction: column;
  width: 98vw;
  max-width: 480px;
  min-width: 0;
  border: 2px solid #0ff;
  box-shadow: 0 0 10px #0ff;
  background: #000;
  margin: 0 auto;
  border-radius: 8px;
  box-sizing: border-box;
  overflow: hidden;
}

#color-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: #111;
  border-bottom: 2px solid #0ff;
  padding: 8px 0;
  gap: 10px;
}

.button-row {
  min-width: 50%;
  width: 90vw;
  max-width: 50vw;
  max-height:45vw;
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: stretch;
  width: 100%;
  margin-top: 8px;
}

#restart,
#record-rate {
  flex: 1 1 0;
  min-width: 0;
  border-radius: 6px;
  padding: 10px 0;
  font-family: inherit;
  font-size: 1em;
  /*margin: 0;*/
  box-shadow: 0 0 6px #0ff;
  cursor: pointer;
  transition: background 0.2s;
  height: 42px; /* Ensures equal height */
  /* Remove width: 50% from #restart in your CSS to allow flex to control width */
}

/* Specific styles for each button */
#restart {
  background: #0ff;
  color: #000;
  border: none;
}

#restart:hover {
  background: #0cc;
}

#record-rate {
  background: none;
  color: #0ff;
  border: none;
  box-shadow: none;
  text-decoration: none;
  border: solid 1px #0ff;
}

#record-rate a {
  background: none;
  color: #0ff;
  border: none;
  box-shadow: none;
  text-decoration: none;
}

#record-rate:hover {
  text-decoration: none;
  background-color: #0ff;
  color: black;
}

#record-rate:hover a {
  text-decoration: none;
  color: black;
}

#record-rate.greyed,
#record-rate:disabled {
  /*background: #ccc;*/
  color: #414d4d;
  cursor: not-allowed;
  border: #414d4d 1px solid;
  opacity: 0.6;
}

#record-rate.greyed:hover,
#record-rate:disabled:hover {
  /*background: #ccc;*/
  background: #232626;
}

#restart, .retro-btn, #play-now-btn {
  background: #0ff;
  color: #000;
  border: none;
  border-radius: 6px;
  padding: 10px 0;
  font-family: inherit;
  font-size: 1em;
  margin: 6px 0 0 0;
  box-shadow: 0 0 6px #0ff;
  cursor: pointer;
  transition: background 0.2s;
}

#restart:hover, .retro-btn:hover, #play-now-btn:hover {
  background: #0cc;
  color: #000;
}

#restart:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(60%);
  pointer-events: none;
}

#spinner {
  width: 36px;
  height: 36px;
  border: 4px solid #0ff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 10px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

#target-hex {
  font-size: 2rem;
  margin: 10px 0;
  text-shadow: 0 0 10px #0ff;
  word-break: break-all;
  text-align: center;
}

.feedback-message{
  margin-top:5px;
  margin-bottom:5px;
  font-weight:bold;
  font-size:1em;
  text-align: center;
}

#color-map {
  flex: 1;
  min-width: 50%;
  width: 90vw;
  max-width: 50vw;
  max-height:45vw;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
}


canvas {
  width: 100%;
  height: 100%;
  display: block;
  border: none;
}

#score-legend-bar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  font-size: 10px;
  padding: 0 2vw;
  background: #000;
}

#score-display, #legend {
  background: rgba(0,0,0,0.8);
  border: 2px solid #0ff;
  box-shadow: 0 0 8px #0ff4;
  padding: 6px 4px;
  margin: 0;
  width: 50%;
  box-sizing: border-box;
  font-size: 10px;
  line-height: 1.3;
  word-break: break-word;
}

#leaderboard {
  background: rgba(0,0,0,0.8);
  border: 2px solid #0ff;
  box-shadow: 0 0 8px #0ff4;
  padding: 6px 4px;
  margin: 10px 0;
  width:50%;
  box-sizing: border-box;
  font-size: 10px;
  line-height: 1.3;
  word-break: break-word;
}

#leaderboard h2 {
  color: #0ff;
  font-size: 1em;
  margin-bottom: 8px;
}
#top-rates {
  list-style: none;
  padding: 0;
  margin: 0;
}
#top-rates li {
  margin: 4px 0;
  color: #0ff;
  font-size: 0.75em;
}

#legend {
  white-space: nowrap;
  padding: 3px;
  font-size: 8px;
}

#howto-popup {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0; top: 0;
  width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.85);
  align-items: center;
  justify-content: center;
  overflow: auto;
}
#howto-popup-content {
  background: #111;
  border: 2px solid #0ff;
  box-shadow: 0 0 10px #0ff;
  padding: 10px 2vw;
  max-width: 70vw;
  width: 70vw;
  max-height: 90vh;
  overflow-y: auto;
  color: #0ff;
  font-family: 'Courier New';
  font-size: 1.2rem;
  line-height: 1.65rem;
  box-sizing: border-box;
  margin: 30px auto;
  border-radius: 8px;
  position: relative;
}

.tip{
  margin-top:14px;
  font-size:1.1rem;
  color:#fff;
}

#close-howto {
  display: none;
}

/* UNIFIED BUTTON STYLING */
#share-x, 
#share-farcaster, 
#howto-btn,
#rules-btn {
  /* Visual Design */
  display: inline;
  padding: 12px 24px;
  margin: 10px 2px;
  background: #38E4F1;
  color: #000;
  border: 2px solid #0ff;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
  
  /* Positioning */
  position: relative;
  /*transform: translateX(-50%);
  left: 50%;*/
}

/* Hover Effects */
#share-x:hover, 
#share-farcaster:hover, 
#howto-btn:hover,
#rules-btn:hover {
  background: #0ff;
  box-shadow: 0 0 15px rgba(56, 228, 241, 0.5);
}


#player-info {
  color: #0ff;
  background:none;
  border: none;
  padding: 10px 0;
  font-family: inherit;
  font-size: 0.75em;
  margin-top: 10px;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 24px; /* Add space below the button */
  position: relative;
}


#login-btn, #logout-btn {
  color: #0ff;
  background:none;
  border: none;
  padding: 10px 0;
  font-family: inherit;
  font-size: 0.75em;
  margin-top: 10px;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 24px; /* Add space below the button */
}

#login-btn:hover, #logout-btn:hover {
  background: #0cc;
  padding: 10px;
  color: #000;
}

#logout-btn {
  position: relative;
}


/* Utility classes */
.text-center { text-align: center; }
.hidden { display: none !important; }
.visible { display: block !important; }

/* Responsive Styles */
@media (max-width: 1200px) {
  #restart, .retro-btn, #play-now-btn, #score-display, #legend, #leaderboard, #howto-popup-content {
    width: 90%;
  }
  #color-map, .button-row {
    width: 90vw;
    max-width: 90vw;
  }
  #logout-btn{
    width: auto;
  }

  #howto-popup-content{
    font-size:0.7rem;
  }

  #target-hex{
    font-size: 1.7rem;
  }

  .tip{
  font-size:0.7rem;
  }

  #howto-popup-content{
    line-height: 1.15;
  }
  #game-footer{
    font-size: 0.5rem;
  }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  #share-x, 
  #share-farcaster, 
  #howto-btn,
  #rules-btn {
    display: inline;
    font-size:0.75rem;
    padding:2px;
    /*width: 50%;*/
    /*margin: 5px auto;*/
    /*transform: none;
    left: auto;*/
  }
}