/* ---------- RESET ---------- */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  color: #e5e7eb;
  background: url("background.webp") center / cover no-repeat fixed;
}

.hidden {
  display: none;
}

/* ---------- SCREENS ---------- */

.screen {
  display: none;
  min-height: 100vh;
  padding: 1rem;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* ---------- MENU ---------- */

#menu {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.menu-title {
  max-width: 320px;
  width: 90%;
  margin-bottom: 0.75rem;
  filter:
    drop-shadow(0 6px 16px rgba(0,0,0,0.8))
    drop-shadow(0 0 12px rgba(255,140,0,0.35));
}

.subtitle {
  opacity: 0.7;
  margin-bottom: 1rem;
}

#tutorial-text {
  max-width: 520px;
  background: rgba(0,0,0,0.5);
  padding: 0.75rem;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.4;
  margin-bottom: 1rem;
}

#tutorial-text h3 {
  margin-top: 0;
  font-size: 1rem;
}

#tutorial-text p {
  margin: 0.4rem 0;
}

#menu-stats {
  margin-top: 1rem;
  font-size: 0.9rem;
  opacity: 0.8;
}

/* ---------- STATS BAR ---------- */

#stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  background: rgba(0,0,0,0.45);
  padding: 0.6rem;
  border-radius: 12px;
}

.stat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

.stat img {
  width: 16px;
}

/* ---------- ROOM / GRID ---------- */

#room {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;

  /* Prevent cards collapsing or stretching on wide screens */
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- CARD ---------- */

.card {
  position: relative;

  /* True square (matches 1024x1024 assets) */
  aspect-ratio: 1 / 1;
  width: 100%;

  /* Prevent “dot” collapse */
  min-width: 140px;

  border-radius: 16px;
  cursor: pointer;

  background:
    linear-gradient(rgba(0,0,0,0.25), rgba(0,0,0,0.25)),
    var(--bg) center / cover no-repeat;

  border: 2px solid transparent;
  overflow: hidden;

  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.card.monster { border-color: #7f1d1d; }
.card.weapon  { border-color: #1e3a8a; }
.card.health  { border-color: #14532d; }

.card.selected {
  box-shadow: 0 0 0 3px #22c55e;
}

/* Tap feedback (mobile) */
.card:active {
  transform: scale(0.97);
}

/* Hover feedback (desktop only) */
@media (hover: hover) {
  .card:hover {
    box-shadow: 0 0 0 3px rgba(34,197,94,0.6);
  }
}

/* ---------- CARD LABELS ---------- */

.card-type {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  font-weight: 700;
  
}

.card-value {
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-size: 1.6rem;
  font-weight: 800;
}

/* ---------- LOG ---------- */

#log {
  margin-top: 0.75rem;
  padding: 0.6rem;
  background: rgba(0,0,0,0.5);
  border-radius: 12px;
  font-size: 0.85rem;
  min-height: 48px;
}

/* ---------- FOOTER ---------- */

#game-footer {
  margin-top: 0.75rem;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

#run-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0.4rem 0.6rem;
  border-radius: 10px;
  background: rgba(0,0,0,0.6);
}

#run-status {
  font-size: 0.7rem;
  opacity: 0.8;
}

#actions {
  display: flex;
  gap: 0.5rem;
}

#game-footer button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.45rem 0.7rem;
  border-radius: 10px;
  background: rgba(0,0,0,0.75);
  color: white;
  border: 1px solid #666;
}

#game-footer img {
  width: 16px;
}

/* ---------- DISABLED ---------- */

button.disabled {
  opacity: 0.45;
  border-color: #444;
  pointer-events: auto;
}

/* ---------- DESKTOP LAYOUT ---------- */

@media (min-width: 768px) {
  #room {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ---------- ACCESSIBILITY ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
