* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  width: 100%;
}

body {
  font-family: Arial, sans-serif;
  background-color: #f5f5f5;
  padding: 20px;
  min-height: 100vh;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  margin-bottom: 8px;
}

.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 2px solid #3498db;
  padding-bottom: 10px;
  justify-content: center;
}

.tab-button {
  padding: 12px 30px;
  background: #f8f9fa;
  color: #333;
  border: 2px solid #ddd;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  font-weight: bold;
  font-size: 16px;
  transition: all 0.3s;
}

.tab-button:hover {
  background: #e9ecef;
  border-color: #3498db;
}

.tab-button.active {
  background: #3498db;
  color: white;
  border-color: #3498db;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

h1 {
  text-align: center;
  color: #333;
  margin-bottom: 8px;
  font-size: 2em;
}

.party-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.character-card {
  background: white;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.character-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  border-bottom: 2px solid #3498db;
  padding-bottom: 6px;
}

.character-card h2 {
  color: #2c3e50;
  margin: 0;
  font-size: 1.1em;
}

.turn-done {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  color: #555;
  cursor: pointer;
  user-select: none;
}

.turn-done input[type="checkbox"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
}

.form-row {
  display: flex;
  gap: 6px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}

.form-group {
  margin-bottom: 5px;
}

.form-group.inline {
  flex: 1;
  min-width: 100px;
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-weight: bold;
  margin-bottom: 3px;
  color: #555;
  font-size: 11px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
  width: 100%;
  padding: 4px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
}

.form-group.inline input[type="number"] {
  width: 52px;
}

.form-group.inline .char-health {
  width: 38px;
}

.form-group.inline .char-level {
  width: 52px;
}

.form-group.inline .char-gold {
  width: 60px;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 5px;
}

.stats-table td {
  border: none;
  padding: 1px 3px 1px 0;
  vertical-align: top;
}

.stats-table label {
  display: block;
  font-weight: bold;
  margin-bottom: 2px;
  color: #555;
  font-size: 11px;
  white-space: nowrap;
}

.stats-table input[type="number"] {
  width: 52px;
  padding: 4px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
}

.stats-table .char-health {
  width: 38px;
}

.stats-table .char-gold {
  width: 60px;
}

.gold-btn {
  padding: 2px 6px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-weight: bold;
  font-size: 10px;
  margin-left: 3px;
  transition: all 0.3s;
}

.give-btn {
  background: #d9534f;
  color: white;
}

.give-btn:hover {
  background: #c9302c;
}

.take-btn {
  background: #5cb85c;
  color: white;
}

.take-btn:hover {
  background: #4cae4c;
}

.use-btn {
  background: #f0ad4e;
  color: white;
}

.use-btn:hover {
  background: #ec971f;
}

.possessions-section {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid #eee;
}

.possessions-section h3 {
  color: #2c3e50;
  font-size: 0.8em;
  margin-bottom: 3px;
}

.possessions-list {
  width: 100%;
  padding: 4px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 11px;
  background: #f8f9fa;
  font-family: monospace;
}

.possessions-list option {
  padding: 2px;
  cursor: pointer;
}

.max-health {
  margin-left: 10px;
  color: #666;
  font-weight: bold;
}

.abilities-section,
.equipment-section,
.summary-section,
.notes-section {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid #eee;
}

.notes-area {
  width: 100%;
  min-height: 60px;
  padding: 3px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  font-family: Arial, sans-serif;
  line-height: 1.6;
  resize: vertical;
  background: #f8f9fa;
}

.notes-area:focus {
  outline: none;
  border-color: #3498db;
  background: white;
}

.abilities-section h3,
.equipment-section h3,
.summary-section h3 {
  color: #2c3e50;
  font-size: 0.8em;
  margin-bottom: 2px;
}

.abilities-display,
.summary-display {
  background: #f8f9fa;
  padding: 1px;
  border-radius: 4px;
  min-height: 40px;
  font-size: 11px;
  line-height: 1.4;
}

.equipment-options {
  margin-bottom: 4px;
  font-size: 10px;
}

.equipment-options label {
  display: block;
  margin-bottom: 3px;
  font-weight: normal;
  font-size: 10px;
}

.equipment-options input[type="checkbox"],
.equipment-options input[type="radio"] {
  margin-right: 5px;
  font-size: 10px;
}

.collapsible-sections {
  display: none;
}

.collapsible-sections.hidden {
  display: none;
}

.abilities-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.abilities-header input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.stat-line {
  margin: 3px 0;
  padding: 3px;
  background: #e8f4f8;
  border-left: 2px solid #3498db;
  padding-left: 6px;
  font-size: 11px;
}

.special-ability {
  margin: 3px 0;
  padding: 2px;
  background: #fff3cd;
  border-left: 2px solid #ffc107;
  padding-left: 6px;
  font-size: 10px;
}

.spell-list {
  margin: 3px 0;
  padding: 2px;
  background: #e8d5ff;
  border-left: 2px solid #9c27b0;
  padding-left: 6px;
  font-size: 10px;
}

.warning {
  color: #d9534f;
  font-weight: bold;
}

.success {
  color: #5cb85c;
  font-weight: bold;
}

.holdings-section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #eee;
}

.holdings-section:first-child {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

.holdings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.holdings-header h3 {
  margin: 0;
  font-size: 0.88em;
}

.holdings-list {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  background: #f8f9fa;
}

.remove-btn {
  padding: 4px 8px;
  background: #d9534f;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: background 0.3s;
}

.remove-btn:hover {
  background: #c9302c;
}

.remove-btn:active {
  background: #ac2925;
  transform: scale(0.95);
}

.shop-section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #eee;
}

.shop-section h3 {
  color: #2c3e50;
  font-size: 0.88em;
  margin-bottom: 6px;
}

.shop-list {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  background: #fff8e1;
  cursor: pointer;
}

.shop-list option {
  padding: 5px;
  cursor: pointer;
}

.shop-list option:hover {
  background: #ffe082;
}

.map-display-section {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 2px solid #3498db;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.map-north-section {
  height: 30%;
  min-height: 150px;
}

.map-north-section h3 {
  color: #2c3e50;
  font-size: 0.88em;
  margin-bottom: 10px;
}

.map-piece-container {
  width: 100%;
  height: calc(100% - 30px);
  min-height: 120px;
  background: #f8f9fa;
  border: 2px solid #ddd;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.map-south-section {
  display: flex;
  gap: 10px;
  height: 70%;
}

.room-resolution-container {
  max-width: 1400px;
  margin: 30px auto;
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.room-resolution-container h2 {
  color: #2c3e50;
  margin-bottom: 8px;
  text-align: center;
  border-bottom: 2px solid #3498db;
  padding-bottom: 10px;
}

.resolution-content {
  display: flex;
  gap: 10px;
  min-height: 400px;
}

.dice-container {
  width: 15%;
  min-width: 70px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-south-section .dice-container {
  width: 30%;
  min-width: 70px;
}

.map-south-section .action-container {
  width: 70%;
  min-width: 230px;
  max-width: 400px;
  max-height: 460px;
  display: grid;
  grid-template-columns: repeat(2, minmax(80px, 160px));
  gap: 8px;
  overflow-y: auto;
}

.dice-btn {
  padding: 10px;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  font-size: 14px;
  transition: background 0.3s;
}

.dice-btn:hover {
  background: #2980b9;
}

.dice-btn:active {
  background: #1f6ca5;
  transform: scale(0.95);
}

.event-log-container {
  width: 70%;
  background: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
}

.event-log {
  height: 400px;
  overflow-y: auto;
  padding: 15px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.6;
}

.log-entry {
  margin-bottom: 4px;
  padding: 4px;
  background: white;
  border-left: 3px solid #3498db;
  border-radius: 3px;
}

.log-entry.dice-roll {
  border-left-color: #9c27b0;
  background: #f3e5f5;
}

.log-entry.treasure {
  border-left-color: #ffc107;
  background: #fff8e1;
}

.log-entry.monster {
  border-left-color: #d9534f;
  background: #ffebee;
}

.log-entry.room {
  border-left-color: #5cb85c;
  background: #e8f5e9;
}

.log-entry.quest {
  border-left-color: #ff9800;
  background: #fff3e0;
}

/* 
.action-container {
  width: 20%;
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 260px;
  max-height: 430px;
} */

.action-container {
  width: 75%;
  min-width: 200px;
  max-height: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-btn {
  padding: 10px 8px;
  background: #5cb85c;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  font-size: 12px;
  transition: background 0.3s;
  text-align: center;
  width: 100%;
}

.action-btn:hover {
  background: #4cae4c;
}

.action-btn:active {
  background: #3d8b3d;
  transform: scale(0.95);
}

#encounter-table td,
#encounter-table th {
  font-size: 11px;
}

.color-swatch {
  width: 40px;
  height: 40px;
  border: 3px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
}

.color-swatch:hover {
  border-color: #333;
  transform: scale(1.1);
}

.color-swatch.selected {
  border-color: #000;
  border-width: 4px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

#map-grid {
  user-select: none;
}

#map-grid td {
  width: 30px;
  height: 30px;
  border: 1px solid #999;
  background-color: #d3d3d3;
  text-align: center;
  vertical-align: middle;
  font-size: 11px;
  font-weight: bold;
  color: #333;
  cursor: pointer;
  position: relative;
}

#map-grid td:hover {
  border-color: #333;
  border-width: 2px;
}

.dungeon-map-holder {
  display: flex;
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.dungeon-map-holder .room-resolution-container {
  width: 60%;
  /* Adjusted to 50% for side-by-side layout */
}


.dungeon-map-holder .map-display-section {
  width: 40%;
  /* Adjusted to 50% for side-by-side layout */
}


@media (max-width: 768px) {
  .party-container {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 1.5em;
  }

  .resolution-content {
    flex-direction: column;
  }

  .dice-container,
  .event-log-container,
  .action-container {
    width: 100%;
  }

  .dice-container,
  .action-container {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .event-log {
    height: 300px;
  }

  .dungeon-map-holder {
    flex-direction: column;
  }

  .dungeon-map-holder .room-resolution-container,
  .dungeon-map-holder .map-display-section {
    width: 100%;
  }

  .map-display-section {
    flex-direction: column;
    /* Stacked on small screens */
    gap: 10px;
  }

  .map-display-section .dice-container,
  .map-display-section .action-container {
    width: 100%;
    flex-direction: row;
    /* Keep side-by-side within the stacked section */
    justify-content: center;
    /* Center items */
  }
}