:root {
  --blue: #00A2FF;
  --green: #00FF66;
  --purple: #FF44CC;
  --red: #FF4500;
  --orange: #FFAA33;
  --linkColor:rgb(255, 167, 38);
}

*{
  box-sizing: border-box;
}

.blue{
  color:var(--blue);
}

.green{
  color:var(--green);
}

.purple{
  color:var(--purple);
}

.red{
  color:var(--red);
}

.orange{
  color:var(--orange);
}

.secondary-font{
  font-family:sans-serif;
}

body {
  background-image: url('../assets/images/backgroundImage.png');
  background-size: cover;
  background-position:center;
  background-attachment: fixed;
  margin: 0;
  padding:0;
  font-family: 'Orbitron', sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100svh; /* small viewport = when address bar is visible; avoids overflow on iOS Chrome */
}

main{
  width: 100vw;
  height: 100vh;
  height: 100svh; /* small viewport = when address bar is visible */
  max-width: 100vw;
  max-height: 100vh;
  max-height: 100svh;
  overflow: hidden;
  padding: 15px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  color: #c8c8c8;
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

#landingPage {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
}

#landingPage .landing-title {
  padding: 15px 40px;
}

#landingButtons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

#landingButtons button {
  min-width: 200px;
}

#startGameButton {
  min-width: 220px;
  padding: 16px 32px;
  font-size: 20px;
}

#gameView {
  flex: 1 1 0;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  /* Prevent selection/highlight on mobile while playing */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

p,label,select,li{
  font-size: 20px;
  color:#c8c8c8;
  font-weight: 700;
}

select{
  background-color:black;
  border-radius: 10px;
  cursor:pointer;
}

header div.bright-glow, #landingPage .landing-title{
  justify-self:center;
  text-align: center;
  border-radius: 15px;
  backdrop-filter: blur(64px);
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0.4) 100%);
  padding:5px 20px 0;
  margin:0 20px;
  box-shadow: 
    0 0 20px rgba(255,255,200,0.6),
    0 4px 15px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

button {
  min-width: 130px;
  border-radius: 12px;
  padding: 12px 24px;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.7), rgba(20, 20, 20, 0.8));
  color: #fff;
  border: 2px solid rgba(255, 167, 38, 0.4);
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  font-family: Orbitron;
  box-shadow:
    0 4px 15px rgba(0, 0, 0, 0.3),
    0 0 10px rgba(255, 167, 38, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  text-transform: uppercase;
  letter-spacing: 1px;
}

button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 167, 38, 0.2), transparent);
  transition: left 0.5s ease;
}

button:hover::before {
  left: 100%;
}

button:hover {
  background: linear-gradient(135deg, rgba(30, 30, 30, 0.9), rgba(50, 50, 50, 0.9));
  border-color: rgba(255, 167, 38, 0.8);
  transform: translateY(-2px) scale(1.02);
  color: var(--linkColor);
  text-shadow: 
    0 0 10px rgba(255, 167, 38, 0.8),
    0 0 20px rgba(255, 167, 38, 0.4);
  box-shadow: 
    0 8px 25px rgba(0, 0, 0, 0.4),
    0 0 20px rgba(255, 167, 38, 0.6),
    0 0 40px rgba(255, 167, 38, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

button:active {
  transform: translateY(0) scale(0.98);
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.3),
    0 0 15px rgba(255, 167, 38, 0.5),
    inset 0 2px 5px rgba(0, 0, 0, 0.5);
}

header div h1 {
  margin-top: 0em;
  margin-bottom: 0em;
  background: linear-gradient(
    90deg, 
    #00A2FF 0%, #00A2FF 12%,   /* Extend blue */
    #00FF66 22%, #00FF66 34%,   /* Extend green */
    #FFAA33 44%, #FFAA33 56%,   /* Extend orange */
    #FF44CC 66%, #FF44CC 78%,   /* Extend purple */
    #FF4500 88%, #FF4500 100%   /* Extend red */
  );
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: bold;
}

#gameSection{
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  width: 100%;
  display: flex;
  gap: 15px;
  align-items: stretch;
  justify-content: center;
}

#controlsSection {
  flex-shrink: 0;
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0;
  padding: 20px 25px;
  backdrop-filter: blur(20px);
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.4), rgba(20, 20, 20, 0.5));
  border-radius: 20px;
  border: 2px solid rgba(255, 167, 38, 0.2);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 0 20px rgba(255, 167, 38, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

#controlsSection:hover {
  border-color: rgba(255, 167, 38, 0.3);
  box-shadow: 
    0 12px 40px rgba(0, 0, 0, 0.5),
    0 0 30px rgba(255, 167, 38, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.p1Color{
  color: var(--green);
}

.p2Color{
  color: var(--orange);
}

#canvasColumn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  align-self: stretch;
}

#healthRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 500px;
  padding: 0 2px;
  min-height: 28px;
}

#healthRow #player1Hearts {
  justify-content: flex-start;
}

#healthRow #player2Hearts {
  justify-content: flex-end;
}

#winStatusRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 500px;
  padding: 0 2px;
  min-height: 28px;
}

#winStatusRow #winStatus1 {
  margin: 0;
  justify-self: flex-start;
  text-align: left;
}

#winStatusRow #winStatus2 {
  margin: 0;
  justify-self: flex-end;
  text-align: right;
}

.hearts-container {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  min-height: 24px;
}

.heart {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid currentColor;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.4), currentColor);
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 0 10px currentColor;
  position: relative;
}

.heart::before {
  content: '';
  position: absolute;
  top: 30%;
  left: 30%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
}

.heart.empty {
  background: transparent;
  opacity: 0.25;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.2);
}

.heart.empty::before {
  display: none;
}

.winStatus{
  font-size: 18px;
  margin: 0;
  line-height: 1.2;
  min-height: 22px;
}

/* Only takes the remaining height after health row and win status row (flex share, not 100%) */
#canvasWrapper {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}

/* Always square: side = min(wrapper width, wrapper height); never stretch to a rectangle */
#canvasDiv{
  width: min(100cqw, 100cqh);
  height: min(100cqw, 100cqh);
  flex-shrink: 0;
  position: relative;
  display: block;
}

/* Fills the square div; div is always square so canvas is never stretched to a rectangle */
#gameCanvas{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 3px solid rgba(255, 167, 38, 0.6);
  border-radius: 15px;
  background-color: transparent;
  display: block;
  box-shadow: 
    0 0 20px rgba(255, 167, 38, 0.4),
    0 0 40px rgba(255, 167, 38, 0.2),
    inset 0 0 30px rgba(0, 0, 0, 0.5);
}

#blur{
  position:fixed;
  display:none;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100svh;
  backdrop-filter: blur(64px);
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 999;
}

#blur.show{
  opacity: 1;
  display:block;
}

#aboutContent, #howToPlayContent, #privacyContent {
  opacity: 0;
  clip-path: circle(0% at 50% 50%);
  transition: opacity 0.5s, clip-path 0.3s;
  position: fixed;
  left:50%;
  top: 50%;
  transform:translate(-50%, -50%);
  color: #f9f9f9;
  backdrop-filter: blur(64px);
  background-color: rgba(0, 0, 0, 0.8);
  box-shadow: 0 0 30px rgb(188,182,166);
  width: 625px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: 8px;
  padding: 20px;
  z-index: 1000;
}

#aboutContent.show, #howToPlayContent.show, #settingsContent.show, #privacyContent.show {
  opacity: 1;
  clip-path: circle(100% at 50% 50%);
}

#settingsContent {
  opacity: 0;
  clip-path: circle(0% at 50% 50%);
  transition: opacity 0.5s, clip-path 0.3s;
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: #f9f9f9;
  backdrop-filter: blur(64px);
  background-color: rgba(0, 0, 0, 0.8);
  box-shadow: 0 0 30px rgb(188, 182, 166);
  width: 400px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: 8px;
  padding: 20px;
  z-index: 1000;
}

#settingsContent h2 {
  margin-top: 0;
  color: var(--linkColor);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
}

.settings-row label {
  margin: 0;
  font-size: 16px;
}

.settings-row select {
  font-size: 14px;
  padding: 6px 10px;
}

.close-button {
  position: absolute;
  top: 15px;
  right: 15px;
  background: transparent;
  border: none;
  color: #f9f9f9;
  font-size: 32px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 35px;
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
  z-index: 1001;
  min-width: auto;
  box-shadow: none;
}

.close-button:hover {
  background-color: rgba(255, 255, 255, 0.2);
  color: var(--linkColor);
  transform: scale(1.1);
  text-shadow: 0 0 8px rgba(255, 167, 38, 0.8);
}

.close-button:active {
  transform: scale(0.9);
  background-color: rgba(255, 255, 255, 0.3);
}

#howToPlayContent h2,
#privacyContent h2 {
  margin-top: 0;
  color: var(--green);
}

#howToPlayContent p strong,
#privacyContent p strong {
  color: var(--linkColor);
}

#aboutContent a {
  color:var(--linkColor);
  padding: 5px 16px;
  display: block;
}

#aboutContent a:hover {
  color:yellow;
  background-color: gray;
}

#license a {
  display:inline;
}

#license p{
  font-size: 14px;
}

#license li{
  font-size: 11px;
}

/* Specific button styles for controlsSection */
#playPauseButton {
  background: linear-gradient(135deg, rgba(0, 162, 255, 0.3), rgba(0, 255, 102, 0.3));
  border-color: rgba(0, 255, 102, 0.5);
}

#playPauseButton:hover {
  background: linear-gradient(135deg, rgba(0, 162, 255, 0.5), rgba(0, 255, 102, 0.5));
  border-color: rgba(0, 255, 102, 0.8);
  box-shadow: 
    0 8px 25px rgba(0, 0, 0, 0.4),
    0 0 20px rgba(0, 255, 102, 0.6),
    0 0 40px rgba(0, 255, 102, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  color: var(--green);
  text-shadow: 
    0 0 10px rgba(0, 255, 102, 0.8),
    0 0 20px rgba(0, 255, 102, 0.4);
}

#backButton {
  background: linear-gradient(135deg, rgba(255, 69, 0, 0.3), rgba(255, 170, 51, 0.3));
  border-color: rgba(255, 69, 0, 0.5);
}

#backButton:hover {
  background: linear-gradient(135deg, rgba(255, 69, 0, 0.5), rgba(255, 170, 51, 0.5));
  border-color: rgba(255, 69, 0, 0.8);
  box-shadow: 
    0 8px 25px rgba(0, 0, 0, 0.4),
    0 0 20px rgba(255, 69, 0, 0.6),
    0 0 40px rgba(255, 69, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  color: var(--red);
  text-shadow: 
    0 0 10px rgba(255, 69, 0, 0.8),
    0 0 20px rgba(255, 69, 0, 0.4);
}

#muteButton {
  background: linear-gradient(135deg, rgba(0, 162, 255, 0.3), rgba(255, 68, 204, 0.3));
  border-color: rgba(0, 162, 255, 0.5);
}

#muteButton:hover {
  background: linear-gradient(135deg, rgba(0, 162, 255, 0.5), rgba(255, 68, 204, 0.5));
  border-color: rgba(0, 162, 255, 0.8);
  box-shadow: 
    0 8px 25px rgba(0, 0, 0, 0.4),
    0 0 20px rgba(0, 162, 255, 0.6),
    0 0 40px rgba(0, 162, 255, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  color: var(--blue);
  text-shadow: 
    0 0 10px rgba(0, 162, 255, 0.8),
    0 0 20px rgba(0, 162, 255, 0.4);
}


/* Touch controls - visible only when JS detects a touch device */
.touch-controls {
  display: none;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

body.touch-device .touch-controls {
  display: flex;
}

.touch-controls .touch-btn {
  min-width: 56px;
  min-height: 56px;
  padding: 12px 20px;
  font-size: 24px;
  line-height: 1;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  color: inherit;
  border-color: color-mix(in srgb, currentColor 50%, transparent);
}

.touch-controls .touch-btn:active {
  background: color-mix(in srgb, currentColor 30%, transparent);
}

/* Touch controls: shrink on small screens to give more space to canvas */
@media (max-width: 600px) {
  .touch-controls {
    gap: 8px;
  }
  .touch-controls .touch-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 14px;
    font-size: 20px;
  }
}

@media (max-width: 400px) {
  .touch-controls {
    gap: 6px;
  }
  .touch-controls .touch-btn {
    min-width: 36px;
    min-height: 36px;
    padding: 6px 10px;
    font-size: 18px;
  }
}

/* Short viewport (e.g. landscape on touch devices): reduce controls below canvas for more vertical space */
@media (max-height: 500px) {
  #controlsSection {
    padding: 10px 16px;
    gap: 12px;
    border-radius: 12px;
  }
  #controlsSection button {
    padding: 8px 16px;
    font-size: 14px;
    min-width: 90px;
    border-radius: 10px;
  }
}

@media (max-height: 400px) {
  #controlsSection {
    padding: 6px 12px;
    gap: 8px;
    border-radius: 10px;
  }
  #controlsSection button {
    padding: 6px 12px;
    font-size: 12px;
    min-width: 70px;
    border-radius: 8px;
  }
}
