* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #006bb3 0%, #003b70 60%, #002c54 100%);
  color: #ffffff;
}

.app {
  position: relative;
  min-width: 100vw;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.canvas {
  --cw: 900px;
  --ch: 1600px;
  position: relative;
  width: var(--cw);
  height: var(--ch);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

#app {
  width: 100vw;
  height: 100vh;
  position: relative;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
}

.screen.active {
  display: flex;
}

.logo {
  width: 50%;
  max-width: 420px;
}

.title {
  text-align: center;
  font-size: clamp(28px, 5vh, 60px);
  font-weight: 600;
  margin: 15vh 0;
}
#screen-countdown .title{
    margin: 10vh 0;
}
.btn {
  border: none;
  border-radius: 32px;
  padding: 1.8vh 4.5vw;
  font-size: clamp(22px, 3vh, 40px);
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  width: 80%;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.2s ease;
}
#btn-name-confirm{
  width: 50%;
  
}

.btn.primary {
  background: #ffffff;
  color: #0072c6;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.35);
}

.btn.primary:active {
  transform: translateY(1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
}

.input {
  width: 80%;
  
  text-transform: uppercase;
  padding: 1.6vh 2.4vw;
  border-radius: 32px;
  border: none;
  text-align: center;
  font-size: clamp(20px, 2.8vh, 32px);
  margin-bottom: 5vh;
  color: #0072c6;
}

.input:focus {
  outline: 2px solid #00b0ff;
}

.input.input-error {
  outline: 2px solid #ff5252;
  box-shadow: 0 0 0 2px rgba(255, 82, 82, 0.5);
}

.countdown-circle {
  width: 30%;
  max-width: 260px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: #00b0ff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

#countdown-value {
  font-size: clamp(40px, 7vh, 80px);
  font-weight: 700;
}

/* Game screen */

 
.game-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(10vh, 1fr);
  gap: 1.2vh;
  width: 80%;
  max-width: 720px;
  justify-items: center;
}

.card {
  position: relative;
  width: 100%;
  padding-top: 130%; /* slightly flatter ratio so all rows fit */
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.1);
  cursor: pointer;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.35);
  transform-style: preserve-3d;
  transition: transform 0.25s ease;
}

.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.25s ease;
}

.card.flipped .card-inner,
.card.matched .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
}

.card-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-face.front {
  transform: rotateY(180deg);
}

.card.disabled {
  cursor: default;
}

/* Center the last row (2 cards) in the middle columns */
.game-grid .card:nth-last-child(2) {
  grid-column: 2;
}

.game-grid .card:nth-last-child(1) {
  grid-column: 3;
}

.game-timer {
  margin-top: 4vh;
  font-size: clamp(30px, 4.5vh, 56px);
  font-weight: 700;
}

/* Result screen */

#screen-result .title {
  margin-bottom: 32px;
}

.result-time {
  font-size: clamp(34px, 5.5vh, 72px);
  font-weight: 700;
  margin-bottom: 4vh;
}

/* Leaderboard */

.leaderboard {
  width: 80%;
  max-width: 640px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 24px;
  padding: 2vh 2vw;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  margin-top: 4vh;
}

.leaderboard-title {
  font-size: clamp(22px, 3vh, 32px);
  font-weight: 600;
  text-align: center;
  margin-bottom: 1.5vh;
}

.leaderboard-body {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 18px;
  overflow: hidden;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 0.8fr 2.2fr 1.2fr;
  align-items: center;
  padding: 0.9vh 1.4vw;
  font-size: clamp(16px, 2.3vh, 22px);
}

.leaderboard-header {
  background: rgba(255, 255, 255, 0.06);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.leaderboard-rows .leaderboard-row:nth-child(odd) {
  background: rgba(0, 0, 0, 0.2);
}

.leaderboard-rows .leaderboard-row:nth-child(even) {
  background: rgba(0, 0, 0, 0.35);
}

.leaderboard-col-rank {
  text-align: left;
  opacity: 0.9;
}

.leaderboard-col-name {
  text-align: left;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-col-time {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.leaderboard-row.me {
  background: rgba(0, 176, 255, 0.25) !important;
  box-shadow: inset 0 0 0 1px rgba(0, 176, 255, 0.8);
}

.btn-fullscreen {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.4);
  cursor: pointer;
  z-index: 10;
}

.btn-fullscreen::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 2px solid #ffffff;
  border-radius: 6px;
}

@media (max-width: 480px) {
  .logo {
    width: 96px;
    margin-bottom: 48px;
  }

  .title {
    font-size: 24px;
    margin-bottom: 40px;
  }

  .btn {
    padding: 14px 40px;
    font-size: 18px;
  }
}
