* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Press Start 2P", system-ui, sans-serif;
  }

body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #1f1f1f;
  user-select: none;
    }

.screen {
  width: min(92vmin, 620px);
  height: min(92vmin, 820px);
  background: #fff;
  border: 6px solid #333;
  padding: 18px;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
      }
.screen.active {
  display: flex;
}

#coverPage {
  cursor: pointer;
  text-align: center;
  background: #f2f2f2;
}

#coverPage h1 {
  font-size: 1.35rem;
  margin-bottom: 10px;
}

#coverPage h2 {
  font-size: 0.95rem;
  margin-bottom: 26px;
}

.team-info {
  display: flex;
  gap: 22px;
  margin: 18px 0 34px;
  justify-content: center;
  flex-wrap: wrap;
}
.member {
  width: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.member p {
  font-size: 0.72rem;
  line-height: 1.3;
}

.tapToStart {
  position: absolute;
  bottom: 16px;
  font-size: 0.75rem;
  color: red;
  animation: blink 1.2s infinite;
}

@keyframes blink {
  0%,
  49% {
    opacity: 1;
}
  50%,
  100% {
  opacity: 0.25;
  }
}

#countdownScreen {
  background: #fff;
}
#countdownDisplay {
  font-size: clamp(4rem, 16vmin, 10rem);
  color: red;
  animation: pulse 0.9s ease-in-out infinite alternate;
}

@keyframes pulse {
  from {
    transform: scale(1);
    opacity: 0.8;
  }
  to {
    transform: scale(1.08);
    opacity: 1;
  }
}

#gameScreen {
  justify-content: flex-start;
  background: #fff;
}

.header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  text-align: center;
}

.score-box {
  flex: 1;
}

.label {
  display: block;
  font-size: 0.68rem;
  margin-bottom: 6px;
}

.value {
  font-size: clamp(1.6rem, 6vmin, 2.6rem);
  line-height: 1;
}

#highScoreValue {
  color: green;
}

#scoreValue {
  color: blue;
  }

#timeValue {
  color: red;
}

#gameBoard {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  border: 2px solid #cfcfcf;
  background: #fff;
}
.tile {
  border: 1px solid #cfcfcf;
  background: #fff;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.25s ease;
}

.tile.black {
  background: black;
}

.tile.newFade {
  opacity: 0;
  animation: fadeIn 0.5s ease-out forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.tile.hit {
  background: lightgreen !important;
}

.pointText {
  position: absolute;
  font-size: clamp(1.2rem, 5vmin, 2rem);
  color: #fff;
  pointer-events: none;
  animation: floatUp 1s ease-out forwards;
}

@keyframes floatUp {
  0% {
    transform: translateY(0);
    opacity: 1;
  }
  100% {
    transform: translateY(-46px);
    opacity: 0;
  }
}

.barWrap {
  width: 92%;
  height: 12px;
  background: #cfcfcf;
  border-radius: 999px;
  overflow: hidden;
}

.bar {
  width: 100%;
  height: 100%;
  background: blue;
  transition: width 0.1s linear;
}

#endOverlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.92);
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  z-index: 20;
  padding: 18px;
}

#endOverlay.show {
  display: flex;
}

#resultText {
  font-size: clamp(2.2rem, 9vmin, 4rem);
  color: red;
  line-height: 1.1;
  white-space: pre-line;
}

#restartMsg {
  margin-top: 20px;
  font-size: 0.95rem;
  color: goldenrod;
  animation: bounce 1.5s infinite;
}

@keyframes bounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

#gameMessage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  font-size: 1.2rem;
  color: darkgoldenrod;
  text-shadow: 2px 2px 0px #fff; 
  pointer-events: none; 
  opacity: 0;
  text-align: center;
  width: 80%;
}

.flash-message {
  animation: flashAndHide 1.5s ease-in-out forwards;
}

@keyframes flashAndHide {
  0% { opacity: 0; transform: translate(-50%, -40%); }
  20% { opacity: 1; transform: translate(-50%, -50%); }
  80% { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -60%); }
}

.footer {
  width: 100%;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}