/* Scoundrel — Game Styles */

/* 1. Reset and base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; background: #1a1a2e; color: #e0e0e0; min-height: 100vh; }

/* 2. Layout — single column, cards take center stage */
.game-layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "header"
    "main"
    "sidebar"
    "log"
    "instructions";
  gap: 16px;
  max-width: 780px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
}
.game-header { grid-area: header; text-align: center; padding: 8px 0; }
.game-header h1 { font-size: 1.5rem; color: #f0c040; letter-spacing: 2px; }
.game-main { grid-area: main; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.sidebar {
  grid-area: sidebar;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.log { grid-area: log; max-height: 200px; overflow-y: auto; }

/* 3. Card component */
.card {
  width: 155px;
  height: 217px;
  border: 2px solid #555;
  border-radius: 10px;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px;
  cursor: pointer;
  user-select: none;
  position: relative;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  color: #1a1a1a;
}
.card:hover { transform: translateY(-6px); box-shadow: 0 10px 20px rgba(0,0,0,0.5); }
.card--selected {
  outline: 3px solid #f39c12;
  transform: translateY(-12px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.5);
}
.card--selected:hover { transform: translateY(-12px); }
.card--monster { border-color: #555; }
.card--weapon { border-color: #3498db; }
.card--potion { border-color: #2ecc71; }
.card__rank { font-size: 26px; font-weight: bold; line-height: 1; }
.card__suit { font-size: 52px; text-align: center; flex: 1; display: flex; align-items: center; justify-content: center; }
.card__rank--bottom { align-self: flex-end; transform: rotate(180deg); }
.card--hearts .card__rank, .card--hearts .card__suit,
.card--diamonds .card__rank, .card--diamonds .card__suit { color: #c0392b; }
.card--clubs .card__rank, .card--clubs .card__suit,
.card--spades .card__rank, .card--spades .card__suit { color: #1a1a1a; }

/* 4. Room row */
.room { display: flex; gap: 16px; justify-content: center; align-items: flex-end; min-height: 230px; }

/* 5. Buttons */
.btn {
  min-height: 44px;
  min-width: 44px;
  padding: 10px 16px;
  font-size: 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.15s;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn--danger { background: #e74c3c; color: #fff; }
.btn--weapon { background: #3498db; color: #fff; }
.btn--heal { background: #2ecc71; color: #fff; }
.btn--cancel { background: #7f8c8d; color: #fff; }
.btn--run { background: #e67e22; color: #fff; }

/* 6. Action bar */
.action-bar { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.hidden { display: none !important; }

/* 7. Stats */
.stat-section { background: #16213e; padding: 12px; border-radius: 8px; }
.stat-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; color: #888; margin-bottom: 4px; }
.hp-bar { background: #333; border-radius: 4px; height: 20px; overflow: hidden; }
.hp-bar__fill { background: #2ecc71; height: 100%; transition: width 0.3s ease; min-width: 4px; }
.hp-text { text-align: center; font-size: 0.9rem; margin-top: 4px; }
.weapon-display { font-size: 1rem; }
.counters div { display: flex; justify-content: space-between; padding: 2px 0; }

/* 8. Log */
.log { background: #16213e; padding: 12px; border-radius: 8px; }
#log-entries { font-size: 0.85rem; line-height: 1.6; }
.log-entry { padding: 2px 0; border-bottom: 1px solid #222; }
.log-entry--damage { color: #e74c3c; }
.log-entry--heal { color: #2ecc71; }
.log-entry--equip { color: #3498db; }
.log-entry--run { color: #e67e22; }
.log-entry--info { color: #aaa; }

/* 9. Instructions */
.instructions {
  grid-area: instructions;
  background: #16213e;
  border-radius: 8px;
  overflow: hidden;
}
.instructions summary {
  padding: 10px 14px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #888;
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.instructions summary::-webkit-details-marker { display: none; }
.instructions summary::before { content: '▶'; font-size: 0.6rem; transition: transform 0.15s; }
.instructions[open] summary::before { transform: rotate(90deg); }
.instructions summary:hover { color: #aaa; }
.instructions__body {
  padding: 0 14px 14px;
  font-size: 0.82rem;
  line-height: 1.6;
  color: #ccc;
}
.instructions__body h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #888;
  margin: 10px 0 4px;
}
.instructions__body h3:first-child { margin-top: 0; }
.instructions__body p { margin-bottom: 6px; }
.instructions__body .binding-note {
  background: #1e2d4e;
  border-left: 3px solid #f0c040;
  padding: 6px 10px;
  border-radius: 0 4px 4px 0;
  color: #e0d090;
  margin: 6px 0;
}

/* 10. Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.overlay__content {
  background: #16213e;
  padding: 32px;
  border-radius: 12px;
  text-align: center;
  max-width: 400px;
  width: 90%;
}
.overlay__content h2 { font-size: 1.5rem; margin-bottom: 12px; color: #f0c040; }
.overlay__content p { margin-bottom: 20px; line-height: 1.5; }
.overlay__content .btn { margin: 4px; }

/* 11. Touch targets: minimum 44px */
.card { min-width: 44px; min-height: 44px; }

/* 12. Prevent iOS zoom on input focus */
button, input, select, textarea { font-size: 16px; }

/* 13. Prevent overscroll behind fixed action bar */
body { overscroll-behavior: none; }

/* 14. Mobile action bar — fixed at bottom for thumb reach */
@media (max-width: 600px) {
  .action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1a1a2e;
    padding: 12px;
    border-top: 2px solid #333;
    z-index: 50;
    justify-content: center;
  }
  .game-layout { padding-bottom: 80px; }
}

/* 15. Tablet breakpoint — cards shrink, stats stay horizontal */
@media (max-width: 768px) {
  .game-layout { padding: 12px; gap: 12px; }
  .card {
    width: 100px;
    height: 140px;
  }
  .card__rank { font-size: 18px; }
  .card__suit { font-size: 34px; }
  .room { gap: 10px; min-height: 150px; }
  .sidebar { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .stat-section { padding: 8px 10px; }
}

/* 16. Mobile breakpoint */
@media (max-width: 480px) {
  .game-header h1 { font-size: 1.2rem; }
  .card {
    width: 76px;
    height: 110px;
    padding: 6px;
  }
  .card__rank { font-size: 16px; }
  .card__suit { font-size: 26px; }
  .room { gap: 8px; min-height: 120px; }
  .sidebar {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .stat-section { padding: 6px 8px; }
  .stat-label { font-size: 0.65rem; }
  .hp-text { font-size: 0.8rem; }
  .weapon-display { font-size: 0.85rem; }
  .counters div { font-size: 0.8rem; }
  #resolved-count { font-size: 0.8rem; }
}

/* 17. Small mobile breakpoint (iPhone SE 375px) */
@media (max-width: 375px) {
  .game-layout { padding: 8px; gap: 8px; }
  .card {
    width: 72px;
    height: 104px;
    padding: 4px;
  }
  .card__rank { font-size: 15px; }
  .card__suit { font-size: 24px; }
  .room { gap: 6px; }
  .btn { padding: 8px 12px; font-size: 14px; }
  .stat-section { padding: 5px 6px; }
  .stat-label { font-size: 0.6rem; }
  .hp-text { font-size: 0.75rem; }
  .weapon-display { font-size: 0.8rem; }
  .counters div { font-size: 0.75rem; }
  #resolved-count { font-size: 0.75rem; }
}
