:root {
  --white : rgb(255, 252, 248);
  --light : rgb(228, 224, 249);
  --dark : rgb(44, 44, 44);
  --highlight : rgb(240, 100, 64);
  --primary : rgb(158, 195, 240);
  --secondary : rgb(52, 75, 109);
}

body {
  font-family: "Gill Sans", "Arial", sans-serif;   
  margin:0;
  background-color: var(--light);
  font-size:18px;
  color:var(--dark);
}

body.no-scroll {
overflow: hidden;
}
strong {
font-weight:600;
}

h1,h2,h3 {
  font-weight: 600;
  margin:0;
  padding:0;
}

p { margin:0;padding:0;}

.text-sm {
font-size:1rem;
}
.container {
display: grid;
grid-template-areas:
  "header"
  "content";
grid-template-columns: 1fr;
gap: 2rem;
padding: 1rem;
max-width:95vw;
width:1200px;
margin:0 auto;
}


.header {
grid-area: header;
display: flex;
justify-content: space-between;
align-items: flex-start; /* or center, depending on vertical alignment you want */
gap: 1rem;
padding:20px;
background: var(--white);
border-radius: 15px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.header > header {
flex:1;
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100%;
}

.controls {
display:flex;
flex-direction: column;
gap:10px;
margin-top:auto;
}

.content {
display: grid;
grid-template-areas: "rules game";
grid-template-columns: 1fr auto; /* auto allows game to size based on content */
gap: 2rem;
grid-area: content;
}

.game-container {
grid-area: game;
width: fit-content;
height: fit-content;
padding:20px;
text-align: center;
background: var(--white);
border-radius: 15px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

  .game-board {
    position: relative;
    width: 100%;
    height: 100%;
  }

  .game-grid {
    display: grid;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    grid-template-columns: repeat(var(--grid-size,10), 1fr);
    grid-template-rows: repeat(var(--grid-size,10), 1fr);
    grid-column-gap: 2px;
    grid-row-gap: 2px;
    z-index: 1;
    position: relative;
  }

  .game-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .island {
    background: var(--primary);
    color: var(--dark);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    margin:5px;
    font-weight: bold;
    justify-self: center;
    align-self: center;
    cursor: pointer;
    opacity: 1;
  }

  .bridge-lines {
    position: absolute;
    top: 0;
    left: 0;
    /* pointer-events: none; */
    z-index: 0;
    width: 100%;
    height: 100%;
  }

  .bridge {
      stroke-width:0;
      fill:var(--highlight);
      cursor: pointer;
  }

  .bridgeSecondary {
    fill:var(--secondary);      
  }
  .bridgeHighlight {
    fill:var(--highlight);
  }
  .bridge.inactive {
    fill:transparent;
  }
  .selected {
      background: var(--secondary)!important;
      color:var(--light);
  }

  .has-bridge {
    background: var(--highlight);
    color:var(--light);
  }

.rules {
grid-area: rules;  
padding:20px;
background: var(--white);
border-radius: 15px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

button {
background-color: var(--primary);
color:var(--dark);
border:0;
border-radius: 10px;
padding:7px 25px;
cursor: pointer;
}

button:hover {
background-color: var(--dark);
color:var(--light);
}


button:disabled {
background-color:#ccc;
color:#999;
 pointer-events: none;}

@media (max-width: 1024px) {
.content {
  grid-template-areas:
    "game"
    "rules";
  grid-template-columns: 1fr;
}
}

hr {
border:0;
height:1px;
background-color: var(--dark);
}

.mt {margin-top:1rem;}
.mt-auto {margin-top:auto;}

.width-half {width:50%}
.width-90 {width:90%}
.width-75 {width:75%;}
.width-70 {width:70%;}

.horizontal-center {
margin-left:auto;
margin-right:auto;
}

#answerScreen {
position: absolute;
top:0;
left:0;
width:100vw;
height:100vh;
background:rgba(44, 44, 44,0.9);
z-index:10;
display: flex;
flex-direction: column;
align-items: center;      /* vertical centering */
justify-content: center;  /* horizontal centering */
text-align: center; 
opacity: 0;
visibility: hidden;
transition: opacity 0.3s ease, visibility 0.3s ease;
}

#answerScreen.visible {
opacity: 1;
visibility: visible;
}

.answerBox {
background-color: var(--light);
color: var(--dark);
padding: 75px 150px;
border-radius: 10px;
border:3px solid var(--highlight);
position: relative;
}

.answerBox h2 {
margin-top:25px;
font-size:2rem;
}
.answerBox button {margin-top:25px}
.answerBox .trophy {
font-size:3rem;
}

.close-button {
text-align: right;
font-size:3rem;
line-height: 2rem;
cursor: pointer;
color:var(--highlight);
position:absolute;
top:10px;
right:10px;
}


/* Mobile-first improvements */
@media (max-width: 768px) {
.container {
  padding: 0.5rem;
  gap: 1rem;
  max-width: 100vw;
}

.header {
  flex-direction: column;
  gap: 1rem;
  padding: 15px;
}

.controls {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
}

.controls button {
  flex: 1;
  min-width: 120px;
  padding: 10px 15px;
  font-size: 14px;
}

.game-container {
  padding: 10px;
  width: 100%;
  box-sizing: border-box;
}

.game-grid {
  max-width: 100vw;
  grid-column-gap: 1px;
  grid-row-gap: 1px;
}

.island {
  width: 35px;
  height: 35px;
  margin: 2px;
  font-size: 14px;
}

.rules {
  padding: 15px;
}

.rules h3 {
  text-align: center;
}

.rules ul {
  padding-left:15px;
  margin-left:0;
}
.answerBox {
  padding: 30px 20px;
  margin: 20px;
  max-width: calc(100vw - 40px);
  box-sizing: border-box;
}

.answerBox h2 {
  font-size: 1.5rem;
}

.answerBox .trophy {
  font-size: 2rem;
}
}

@media (max-width: 480px) {
body {
  font-size: 16px;
}

.header {
  padding: 10px;
  text-align: center;
}

.controls button {
  font-size: 12px;
  padding: 8px 12px;
}

.island {
  width: 30px;
  height: 30px;
  font-size: 12px;
}

.game-container {
  padding: 5px;
}

.rules {
  padding: 10px;
}

.rules h3 {
  font-size: 1.1rem;
}

.rules ul {
  font-size: 14px;
}

.sm-hidden {display:none;}
}

/* Landscape phone orientation */
@media (max-width: 768px) and (orientation: landscape) {
.content {
  grid-template-areas: "game rules";
  grid-template-columns: 1fr 1fr;
}

.game-container {
  max-height: 80vh;
}
}