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

body {
  font-family: Arial, sans-serif;
  background: #1a1a2e url("images/background.jpg") no-repeat center center fixed;
  background-size: cover;
  color: #e0e0e0;
  min-height: 100vh;
}

/* ============================================
   SCREENS
============================================ */
.screen {
  display: none;
  min-height: 100vh;
  padding: 30px 20px;
}

.screen.active {
  display: block;
}

/* ============================================
   HOME PAGE
============================================ */
#home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#home h1 {
  font-size: 22px;
  margin-bottom: 20px;
  color: #a34539;
  text-align: center;
  letter-spacing: 3px;
  text-transform: uppercase;
  border-bottom: 1px solid #a34539;
  padding-bottom: 16px;
}

/* ============================================
   PANEL (content container)
============================================ */
.panel {
  background: rgba(22, 21, 16, 0.92);
  border: 1px solid #3a3a30;
  border-radius: 10px;
  padding: 30px;
  width: 100%;
  max-width: 500px;
}

.panel h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #888;
  margin-bottom: 12px;
}

/* ============================================
   LEVEL AND MODE BUTTONS
============================================ */
.button-group {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.btn-level,
.btn-mode {
  flex: 1;
  min-width: 100px;
  background: rgba(28, 26, 20, 0.88);
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 12px 8px;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 14px;
  text-align: center;
  line-height: 1.4;
}

.btn-level:hover,
.btn-mode:hover {
  border-color: #888;
}

.btn-level.active,
.btn-mode.active {
  border-color: #a34539;
  background: rgba(80, 35, 28, 0.60);
  color: #a34539;
}

.btn-level small,
.btn-mode small {
  font-size: 11px;
  color: #aaa;
  display: block;
  margin-top: 4px;
}

.btn-level.active small,
.btn-mode.active small {
  color: #8a2e28;
}

/* ============================================
   GENERAL BUTTONS
============================================ */
button {
  background: rgba(28, 26, 20, 0.88);
  border: 1px solid #3a3a30;
  border-radius: 6px;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 14px;
  padding: 10px 18px;
}

button:hover {
  background: rgba(50, 38, 28, 0.92);
  border-color: #a34539;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.actions button {
  flex: 1;
}

/* ============================================
   GAME HEADER
============================================ */
#game-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  background: rgba(22, 21, 16, 0.92);
  border: 1px solid #3a3a30;
  border-radius: 8px;
  padding: 12px 16px;
}

#game-header span {
  font-size: 14px;
  font-weight: bold;
}

#info-time {
  color: #a34539;
}

#info-time.urgent {
  color: #e05050;
}

/* ============================================
   CARD GRID
============================================ */
#card-grid {
  display: grid;
  gap: 10px;
  max-width: 720px;
  margin: 0 auto;
}

/* ============================================
   CARD
============================================ */
.card {
  aspect-ratio: 3 / 4;
  cursor: pointer;
  perspective: 600px;
  border-radius: 8px;
}

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.4s;
  border-radius: 8px;
}

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

.card-front,
.card-back {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #3a3a30;
}

/* Card back */
.card-back {
  background: #22231c;
  font-size: 22px;
  font-weight: bold;
  color: rgba(163, 69, 57, 0.35);
  letter-spacing: 1px;
}

/* Card front — symbol image */
.card-front {
  transform: rotateY(180deg);
  background: #2c2e25;
  font-size: clamp(20px, 4vw, 40px);
  color: #e0e0e0;
  user-select: none;
}

.card-front img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 6px;
  display: block;
  pointer-events: none;
  user-select: none;
}

/* Hover on face-down cards */
.card:not(.flipped):not(.matched):hover .card-back {
  background: #3a3c30;
  border-color: #a34539;
}

/* Matched card — green border */
.card.matched .card-front {
  border-color: #50c050;
  background: #0d2a1a;
}

/* Wrong pair — red border */
.card.wrong .card-front {
  border-color: #e05050;
}

/* ============================================
   LEADERBOARD
============================================ */
#scoreboard {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.tab-group {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.tab-mode,
.tab-level {
  background: rgba(28, 26, 20, 0.88);
  border: 1px solid #3a3a30;
  border-radius: 6px;
  color: #aaa;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}

.tab-mode:hover,
.tab-level:hover {
  border-color: #888;
  color: #e0e0e0;
}

.tab-mode.active,
.tab-level.active {
  border-color: #a34539;
  color: #a34539;
}

#score-list {
  margin-top: 16px;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(28, 26, 20, 0.88);
  border: 1px solid #3a3a30;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 14px;
}

.score-row:nth-child(1) { border-color: #a34539; }
.score-row:nth-child(2) { border-color: #aaa; }
.score-row:nth-child(3) { border-color: #c07820; }

.rank {
  font-size: 18px;
  width: 30px;
  text-align: center;
  font-weight: bold;
}

.player-name { flex: 1; font-weight: bold; }

.score-details {
  text-align: right;
  font-size: 12px;
  color: #aaa;
  line-height: 1.5;
}

.score-details .points {
  font-size: 15px;
  color: #4ecdc4;
  font-weight: bold;
  display: block;
}

.empty-board {
  text-align: center;
  color: #666;
  padding: 30px;
}

/* ============================================
   MODAL
============================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: rgba(22, 21, 16, 0.95);
  border: 1px solid #3a3a30;
  border-radius: 10px;
  padding: 30px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.modal h2 {
  font-size: 26px;
  color: #a34539;
  margin-bottom: 8px;
}

.modal p {
  color: #aaa;
  margin-bottom: 20px;
}

.modal table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 14px;
}

.modal td {
  padding: 6px 10px;
  border: 1px solid #3a3a30;
  text-align: center;
}

.modal td:first-child {
  color: #aaa;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.modal td:last-child {
  font-weight: bold;
  font-size: 18px;
  color: #a34539;
}

.modal label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #888;
  margin-bottom: 6px;
  text-align: left;
}

.modal input[type="text"] {
  width: 100%;
  background: rgba(28, 26, 20, 0.88);
  border: 1px solid #3a3a30;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 15px;
  padding: 10px 12px;
  margin-bottom: 6px;
  outline: none;
}

.modal input[type="text"]:focus {
  border-color: #a34539;
}

/* ============================================
   RESPONSIVE
============================================ */
@media (max-width: 480px) {
  #home h1 { font-size: 18px; }

  .panel { padding: 20px; }

  .btn-mode { min-width: 100%; }

  #game-header { gap: 10px; font-size: 13px; }
}

#btn-confirm-clear:hover {
  background: rgba(140, 35, 28, 0.4);
  border-color: #e05050;
  color: #e05050;
}

#btn-clear {
  border-color: #e05050;
  color: #e05050;
}
/* ============================================
   PAUSE BUTTON — bottom left
============================================ */
#btn-pause {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 50;
  background: rgba(22, 21, 16, 0.92);
  border: 1px solid #3a3a30;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 13px;
  font-weight: bold;
  padding: 10px 18px;
  cursor: pointer;
  letter-spacing: 1px;
  text-transform: uppercase;
  min-width: 110px;
  text-align: center;
}

#btn-pause:hover {
  background: rgba(50, 38, 28, 0.92);
  border-color: #a34539;
}

#start-actions {
  margin-top: 20px;
  display: flex;
  gap: 10px;
  justify-content: center;
}

#clear-actions {
  margin-top: 20px;
}
/* ============================================
   SOUND BUTTON — bottom right
============================================ */
#btn-sound {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 50;
  background: rgba(22, 21, 16, 0.92);
  border: 1px solid #3a3a30;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#btn-sound:hover {
  background: rgba(50, 38, 28, 0.92);
  border-color: #a34539;
}

/* ============================================
   PAUSE OVERLAY
============================================ */
#pause-overlay .modal h2 {
  font-size: 30px;
  letter-spacing: 3px;
  text-transform: uppercase;
}