/* =========================================
   GENERAL
   ========================================= */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  background: #111;
  color: white;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}


/* ============================= */
/* GAME CODE SCREEN */
/* ============================= */

.game-code-screen {
  position: fixed;
  inset: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  background: #111;

  z-index: 1000;
}

.game-code-screen.hidden {
  display: none;
}

.game-code-box {
  width: min(400px, 90%);

  text-align: center;

  background: #181818;

  border: 1px solid #444;
  border-radius: 15px;

  padding: 35px;
}

.game-code-box h1 {
  margin-top: 0;
  letter-spacing: 0.1em;
}

.game-code-box p {
  color: #aaa;
  margin-bottom: 25px;
}

#gameCodeInput {
  width: 100%;

  padding: 15px;

  background: #222;
  color: white;

  border: 1px solid #555;
  border-radius: 8px;

  text-align: center;

  font-size: 1.5rem;
  font-weight: bold;

  letter-spacing: 0.2em;

  text-transform: uppercase;
}

#joinGameButton {
  width: 100%;

  margin-top: 12px;

  padding: 14px;

  border: 0;
  border-radius: 8px;

  background: white;
  color: black;

  font-weight: bold;
  font-size: 1rem;

  cursor: pointer;
}

#joinGameButton:hover {
  background: #ddd;
}

#gameCodeError {
  color: #ff7777;
  margin-top: 15px;
  min-height: 20px;
}

/* =========================================
   SCOREBOARD
   ========================================= */

#app {
  width: 100%;
  height: 100%;
}

#scoreboard {
  width: 100%;
  min-height: 100%;
  padding: 2vh 3vw;
  display: flex;
  flex-direction: column;
}

.game-header {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  min-height: 70px;
}

.game-header h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  letter-spacing: 0.12em;
}

.game-header .small-button {
  position: absolute;
  right: 0;
}

.game-timer {
  text-align: center;
  font-size: 3rem;
  font-weight: bold;
  margin: 10px 0 15px;
}

/* =========================================
   TEAM GRID
   ========================================= */

.teams {
  flex: 1;

  display: grid;

  /*
    JavaScript changes the number of columns
    depending on the number of teams.
  */
  grid-template-columns: repeat(2, 1fr);

  gap: 2vw;

  align-content: center;

  padding: 2vh 0;
}

.team-card {
  min-height: 130px;

  border: 3px solid #444;
  border-radius: 20px;

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  background: #181818;

  transition:
    transform 0.25s ease,
    border-color 0.25s ease,
    background 0.25s ease;
}

.team-card.highlight {
  transform: scale(1.05);
  border-color: white;
  background: #292929;
}

.team-animal {
  font-size: clamp(2rem, 6vw, 5rem);
  line-height: 1;
}

.team-name {
  margin-top: 8px;
  font-size: clamp(1rem, 2.5vw, 2rem);
  font-weight: bold;
  letter-spacing: 0.05em;
}

.team-score {
  margin-top: 5px;
  font-size: clamp(1.5rem, 4vw, 3.5rem);
  font-weight: bold;
}


/* =========================================
   CURRENT VALUE
   ========================================= */

.current-value-area {
  text-align: center;
  padding: 2vh 0 3vh;
}

.value-label {
  font-size: clamp(0.7rem, 1.5vw, 1.1rem);
  letter-spacing: 0.2em;
  color: #aaa;
}

.current-value {
  font-size: clamp(4rem, 12vw, 9rem);
  line-height: 1;
  font-weight: bold;
}


/* =========================================
   BUTTONS
   ========================================= */

.small-button {
  background: #222;
  border: 1px solid #555;
  color: white;
  border-radius: 8px;
  padding: 8px 12px;
}

.small-button:hover {
  background: #333;
}

.primary-button,
.secondary-button,
.danger-button {
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 14px 18px;
  margin-top: 10px;
  font-weight: bold;
}

.primary-button {
  background: white;
  color: black;
}

.primary-button:hover {
  background: #ddd;
}

.primary-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.secondary-button {
  background: #333;
  color: white;
  border: 1px solid #555;
}

.secondary-button:hover {
  background: #444;
}

.danger-button {
  background: #702020;
  color: white;
}

.danger-button:hover {
  background: #902020;
}


/* =========================================
   CONTROL PANEL
   ========================================= */

.control-panel {
  position: fixed;

  top: 0;
  right: 0;

  width: min(420px, 100vw);
  height: 100vh;

  background: #171717;

  border-left: 1px solid #444;

  padding: 20px;

  overflow-y: auto;

  z-index: 100;

  transform: translateX(100%);

  transition: transform 0.25s ease;
}

.control-panel.open {
  transform: translateX(0);
}

.control-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.control-header h2 {
  margin: 0;
}

.control-section {
  margin-top: 25px;
}

.control-section h3 {
  margin-bottom: 8px;
}

.instruction {
  color: #aaa;
  font-size: 0.9rem;
  line-height: 1.4;
}


/* =========================================
   ALPHABET
   ========================================= */

.alphabet {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 15px;
}

.letter-button {
  aspect-ratio: 1;
  border-radius: 7px;
  border: 1px solid #555;
  background: #242424;
  color: white;
  font-weight: bold;
}

.letter-button:hover {
  background: #333;
}

.letter-button.selected {
  background: white;
  color: black;
  border-color: white;
}

.selected-info {
  margin-top: 15px;
  color: #aaa;
}

.selected-letters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.selected-letter {
  background: #333;
  border-radius: 5px;
  padding: 5px 9px;
  font-weight: bold;
}


/* =========================================
   TEACHER VALUE
   ========================================= */

.teacher-value {
  text-align: center;
  padding: 10px 0 20px;
}

.teacher-current-value {
  font-size: 4rem;
  font-weight: bold;
  margin-top: 5px;
}


/* =========================================
   TEAM BUTTONS
   ========================================= */

.team-buttons {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.team-select-button {
  display: flex;
  justify-content: space-between;
  align-items: center;

  width: 100%;

  padding: 12px;

  background: #242424;
  border: 1px solid #555;

  border-radius: 8px;

  color: white;
}

.team-select-button:hover {
  background: #333;
}

.team-select-button .button-score {
  color: #aaa;
}


/* =========================================
   MODAL
   ========================================= */

.modal {
  position: fixed;

  inset: 0;

  background: rgba(0, 0, 0, 0.75);

  display: flex;
  justify-content: center;
  align-items: center;

  z-index: 200;

  padding: 20px;
}

.modal-content {
  width: min(500px, 100%);
  max-height: 90vh;

  overflow-y: auto;

  background: #181818;

  border: 1px solid #444;
  border-radius: 15px;

  padding: 20px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
}

.score-editor {
  margin-top: 15px;
}

.score-editor label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
}

.score-editor-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.score-editor-animal {
  font-size: 2rem;
}

.score-editor input {
  flex: 1;

  background: #222;
  color: white;

  border: 1px solid #555;
  border-radius: 6px;

  padding: 10px;

  font-size: 1.2rem;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-actions button {
  margin-top: 0;
}


/* =========================================
   WINNER SCREEN
   ========================================= */

.winner-screen {
  position: fixed;
  inset: 0;

  background: rgba(0, 0, 0, 0.95);

  z-index: 300;

  display: flex;
  justify-content: center;
  align-items: center;

  text-align: center;
}

.winner-content {
  padding: 30px;
}

.winner-title {
  font-size: clamp(2rem, 6vw, 5rem);
  letter-spacing: 0.15em;
  font-weight: bold;
}

.winner-animal {
  font-size: clamp(5rem, 15vw, 10rem);
  margin: 20px;
}

.winner-name {
  font-size: clamp(2rem, 6vw, 5rem);
  font-weight: bold;
}

.winner-score {
  font-size: clamp(2rem, 5vw, 4rem);
  margin: 10px;
}


/* =========================================
   UTILITY
   ========================================= */

.hidden {
  display: none !important;
}


/* =========================================
   MOBILE
   ========================================= */

@media (max-width: 600px) {

  #scoreboard {
    padding: 10px;
  }

  .game-header {
    min-height: 55px;
  }

  .game-header h1 {
    font-size: 1.8rem;
  }

  .game-header .small-button {
    font-size: 0;
    padding: 8px;
  }

  .game-header .small-button::after {
    content: "⚙";
    font-size: 1.2rem;
  }

  .teams {
    gap: 8px;
  }

  .team-card {
    min-height: 100px;
    border-radius: 12px;
  }

  .team-animal {
    font-size: 2.5rem;
  }

  .team-name {
    font-size: 0.9rem;
  }

  .team-score {
    font-size: 1.5rem;
  }

  .current-value {
    font-size: 4.5rem;
  }

  .alphabet {
    grid-template-columns: repeat(7, 1fr);
  }
}


/* =========================================
   LARGE CLASSROOM DISPLAY
   ========================================= */

@media (min-width: 1000px) {

  .teams {
    gap: 2vw;
  }

  .team-card {
    min-height: 150px;
  }

}


/* =========================================
HEADER RIGHT
========================================= */

.header-right {
position: absolute;
right: 0;

display: flex;
align-items: center;
gap: 12px;
}

/* =========================================
GAME TIMER
========================================= */

/* =========================================
   GAME TIMER
   ========================================= */

.game-timer {
  width: 110px;
  height: 48px;

  margin: 8px auto 12px;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 1.6rem;
  font-weight: bold;

  font-variant-numeric: tabular-nums;

  text-align: center;

  padding: 0;

  border: 1px solid #555;
  border-radius: 8px;

  background: #222;

  overflow: hidden;
}

.game-timer.warning {
  animation: timerPulse 1s infinite;
}

@keyframes timerPulse {
  50% {
    opacity: 0.45;
  }
}

/* =========================================
TIMER SETUP
========================================= */

.timer-setup {
margin-top: 25px;
}

.optional {
color: #777;
font-size: 0.8em;
font-weight: normal;
}

.timer-input-row {
display: flex;
align-items: center;
gap: 8px;

margin-top: 10px;
}

.timer-input-row input {
width: 100px;

padding: 10px;

background: #222;
color: white;

border: 1px solid #555;
border-radius: 6px;

text-align: center;
}

.timer-input-row span {
font-weight: bold;
font-size: 1.4rem;
}

/* =========================================
TIMER CONTROL SECTION
========================================= */

.timer-control-section {
margin-bottom: 25px;
}

.timer-display-teacher {
font-size: 2rem;
font-weight: bold;

font-variant-numeric: tabular-nums;

text-align: center;

margin: 10px 0;
}

.timer-display-teacher.warning {
animation: timerPulse 1s infinite;
}

/* =========================================
FINISH GAME
========================================= */

.finish-button {
border-color: #777;
margin-top: 10px;
}

.finish-button:hover {
background: #555;
}

/* =========================================
MOBILE TIMER
========================================= */

@media (max-width: 600px) {

.header-right {
gap: 5px;
}

.game-timer {
font-size: 1rem;
min-width: 65px;
padding: 5px;
}

.timer-input-row input {
width: 80px;
}

}
