* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
  font-family: 'Arial', sans-serif;
  background-color: #f4f1e8;
  color: #2c2416;
}

body {
  padding: 20px;
}

h1 {
  font-size: 1.5em;
  color: #5a4a3a;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 20px;
}

/* ── Traveller Layout ── */

.section-1 {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.stat-table {
  flex-shrink: 0;
}

.skill-list {
  flex-grow: 1;
  max-width: 300px;
}

/* ── Tables: shared base ── */

#skillListTable,
#statsTable,
#worldBackgroundTable,
#educationTable {
  border-collapse: collapse;
}

#skillListTable {
  width: 100%;
}

#skillListTable th,
#skillListTable td {
  border: 1px solid #8b7355;
  padding: 8px 12px;
  text-align: center;
  word-wrap: break-word;
  white-space: normal;
  overflow-wrap: break-word;
}

#skillListTable th {
  background-color: #5a4a3a;
  color: white;
  font-weight: bold;
}

#skillListBody {
  display: block;
  max-height: 400px;
  overflow-y: auto;
  width: 100%;
}

#skillListBody tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}

#skillListBody td {
  cursor: pointer;
  user-select: none;
}

#skillListBody td:hover {
  background-color: #f4f1e8;
}

#statsTable {
  width: auto;
  table-layout: auto;
}

#statsTable th,
#statsTable td {
  border: 1px solid #8b7355;
  padding: 8px 12px;
  text-align: center;
  word-wrap: break-word;
  width: auto;
}

#statsTable th {
  background-color: #5a4a3a;
  color: white;
  font-weight: bold;
}

#statsTable input[type="number"] {
  width: 60px;
  padding: 4px;
  text-align: center;
  border: 1px solid #8b7355;
  border-radius: 3px;
}

.totals-row td,
.mods-row td {
  font-weight: bold;
  background-color: #fafaf8;
}

.mods-row td {
  background-color: #f4f1e8;
}

/* ── Beginner Skills ── */

.beginner-skills {
  margin-top: 20px;
  margin-bottom: 10px;
}

.beginner-skills label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-weight: bold;
  color: #5a4a3a;
}

.skills-container {
  margin-top: 10px;
}

/* ── World Background / Education ── */

.world-background-section,
.education-section {
  margin-bottom: 10px;
}

#worldBackgroundTable,
#educationTable {
  width: auto;
  table-layout: auto;
}

#worldBackgroundTable th,
#worldBackgroundTable td,
#educationTable th,
#educationTable td {
  border: 1px solid #8b7355;
  padding: 4px 12px;
  text-align: center;
  word-wrap: break-word;
  white-space: normal;
  overflow-wrap: break-word;
}

#worldBackgroundTable th,
#educationTable th {
  background-color: #5a4a3a;
  color: white;
  font-weight: bold;
}

#worldBackgroundTable label,
#educationTable label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
}

.skill-check {
  cursor: pointer;
}

/* ── Career Toggle ── */

.career-toggle {
  margin-top: 20px;
  margin-bottom: 10px;
}

.career-toggle label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-weight: bold;
  color: #5a4a3a;
}

/* ── Career Section ── */

.career-section {
  margin-top: 10px;
  padding: 10px;
  border: 2px solid #8b7355;
  border-radius: 5px;
  background-color: #fafaf8;
}

.career-section h2 {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 0.975em;
  color: #5a4a3a;
  text-transform: uppercase;
  letter-spacing: 0.75px;
  border-bottom: 2px solid #8b7355;
  padding-bottom: 4px;
}

.career-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.career-controls label {
  font-weight: bold;
  color: #5a4a3a;
}

.career-controls select {
  padding: 5px 10px;
  border: 1px solid #8b7355;
  border-radius: 3px;
  min-width: 200px;
  background-color: #fff;
  color: #2c2416;
}

.career-info {
  display: flex;
  gap: 20px;
  margin-bottom: 10px;
  padding: 5px 10px;
  background-color: #f4f1e8;
  border-radius: 3px;
  border: 1px solid #d4c4a8;
}

.career-stat {
  font-size: 16px;
  color: #5a4a3a;
}

.career-rolls {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.roll-section {
  flex: 1;
  min-width: 200px;
  padding: 8px;
  border: 1px solid #d4c4a8;
  border-radius: 5px;
  background-color: #fafaf8;
}

.roll-section h3 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 0.9em;
  color: #5a4a3a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.roll-info {
  margin-bottom: 10px;
  font-weight: bold;
  color: #5a4a3a;
}

.roll-section button {
  width: 100%;
  padding: 8px;
  background-color: #5a4a3a;
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.3s;
}

.roll-section button:hover:not(:disabled) {
  background-color: #3a2a1a;
}

.roll-section button:disabled {
  background-color: #c0b49a;
  cursor: not-allowed;
}

.roll-result {
  margin-top: 10px;
  padding: 8px;
  border-radius: 3px;
  font-weight: bold;
  min-height: 40px;
}

.roll-result.success {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.roll-result.failure {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.roll-result.neutral {
  background-color: #f4f1e8;
  color: #5a4a3a;
  border: 1px solid #d4c4a8;
}

/* ── Skill Acquisition ── */

.skill-acquisition {
  margin-bottom: 10px;
  padding: 10px;
  border: 2px solid #8b7355;
  border-radius: 5px;
  background-color: #f4f1e8;
}

.skill-acquisition h3 {
  margin-top: 0;
  margin-bottom: 8px;
  color: #5a4a3a;
  font-size: 0.9em;
  text-transform: uppercase;
}

.skill-tables-display {
  margin-bottom: 10px;
}

.skill-options-table {
  width: 100%;
  border-collapse: collapse;
}

.skill-options-table th {
  background-color: #5a4a3a;
  color: white;
  padding: 8px;
  border: 1px solid #8b7355;
  text-align: center;
  font-weight: bold;
}

.skill-options-table td {
  border: 1px solid #d4c4a8;
  padding: 8px;
  vertical-align: top;
}

.skill-option-item {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 5px;
}

.skill-option-item button {
  background-color: #5a4a3a;
  color: white;
  border: none;
  border-radius: 3px;
  padding: 2px 8px;
  cursor: pointer;
  font-weight: bold;
  font-size: 14px;
  transition: background-color 0.3s;
}

.skill-option-item button:hover {
  background-color: #3a2a1a;
}

.skill-option-item button:disabled {
  background-color: #c0b49a;
  cursor: not-allowed;
}

.skill-option-item span {
  font-size: 14px;
  color: #2c2416;
}

/* ── Career Actions ── */

.career-actions {
  display: flex;
  gap: 15px;
}

.career-actions button {
  padding: 10px 20px;
  font-size: 16px;
  font-weight: bold;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 0.3s;
}

#start-term-btn {
  background-color: #5a4a3a;
  color: white;
}

#start-term-btn:hover:not(:disabled) {
  background-color: #3a2a1a;
}

#start-term-btn:disabled {
  background-color: #c0b49a;
  cursor: not-allowed;
}

#muster-out-btn {
  background-color: #8b4513;
  color: white;
}

#muster-out-btn:hover:not(:disabled) {
  background-color: #6b3410;
}

#muster-out-btn:disabled {
  background-color: #c0b49a;
  cursor: not-allowed;
}
