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

html, body {
  font-family: 'Arial', sans-serif;
  background-color: #f4f1e8;
  color: #2c2416;
}

.character-sheet {
  max-width: 900px;
  margin: 10px auto;
  padding: 10px;
  background-color: #fff;
  box-shadow: 0 0 20px rgba(0,0,0,0.1);
  border: 2px solid #8b7355;
}

header {
  text-align: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 3px solid #8b7355;
}

header h1 {
  font-size: 1.5em;
  color: #5a4a3a;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

section {
  margin-bottom: 12px;
  padding: 7px;
  background-color: #fafaf8;
  border: 1px solid #d4c4a8;
  border-radius: 5px;
}

h2 {
  font-size: 0.975em;
  color: #5a4a3a;
  margin-bottom: 7px;
  padding-bottom: 4px;
  border-bottom: 2px solid #8b7355;
  text-transform: uppercase;
  letter-spacing: 0.75px;
}

.form-row {
  display: flex;
  gap: 7px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}

.form-group {
  flex: 1;
  min-width: 130px;
}

.form-row.cols-3 > .form-group {
  flex: 0 0 calc(33.333% - 5px);
  min-width: 0;
}

.form-row.cols-2 > .form-group {
  flex: 0 0 calc(50% - 4px);
  min-width: 0;
}

.form-group label {
  display: block;
  font-weight: bold;
  margin-bottom: 2px;
  color: #5a4a3a;
  font-size: 0.675em;
  text-transform: uppercase;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 4px;
  border: 1px solid #8b7355;
  border-radius: 3px;
  font-size: 0.75em;
  background-color: #fff;
  font-family: 'Arial', sans-serif;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #5a4a3a;
  box-shadow: 0 0 5px rgba(90,74,58,0.3);
}

.row-container {
  display: flex;
  gap: 7px;
  margin-bottom: 12px;
  align-items: flex-start;
}

.row-container .column {
  flex: 1;
  min-width: 0;
}

/* Abilities table */
.abilities-table {
  width: 100%;
  border-collapse: collapse;
  background-color: #fff;
}

.abilities-table thead tr {
  background-color: #5a4a3a;
  color: #fff;
}

.abilities-table th {
  padding: 5px 6px;
  text-align: left;
  font-size: 0.72em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.abilities-table tbody tr {
  border-bottom: 1px solid #d4c4a8;
}

.abilities-table td {
  padding: 4px 6px;
  vertical-align: middle;
  font-size: 0.75em;
}

.abilities-table td label {
  font-weight: bold;
  color: #5a4a3a;
  text-transform: uppercase;
  white-space: nowrap;
}

.abilities-table td input[type="number"] {
  width: 55px;
  padding: 3px;
  text-align: center;
  font-size: 1.4em;
  font-weight: bold;
  border: 1px solid #8b7355;
  border-radius: 3px;
}

.abilities-table td span {
  color: #8b4513;
  font-size: 0.9em;
}

/* Weapons table */
.weapons-table {
  width: 100%;
  border-collapse: collapse;
  background-color: #fff;
}

.weapons-table thead {
  background-color: #5a4a3a;
  color: #fff;
}

.weapons-table th {
  padding: 5px;
  text-align: left;
  font-size: 0.675em;
  text-transform: uppercase;
  border: 1px solid #8b7355;
}

.weapons-table td {
  padding: 4px;
  border: 1px solid #d4c4a8;
}

.weapons-table td input {
  width: 100%;
  padding: 3px;
  border: 1px solid #8b7355;
  border-radius: 3px;
  font-size: 0.75em;
  background-color: #fff;
}

/* Class abilities block */
.abilities-block {
  font-size: 0.8em;
  line-height: 1.6;
  color: #2c2416;
  white-space: pre-line;
}

/* Textareas */
textarea {
  width: 100%;
  padding: 5px;
  border: 1px solid #8b7355;
  border-radius: 3px;
  font-family: 'Arial', sans-serif;
  font-size: 0.75em;
  resize: vertical;
  background-color: #fff;
}

textarea:focus {
  outline: none;
  border-color: #5a4a3a;
  box-shadow: 0 0 5px rgba(90,74,58,0.3);
}

/* Buttons */
button {
  padding: 5px 12px;
  background-color: #5a4a3a;
  color: #fff;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.75em;
  font-weight: bold;
  transition: background-color 0.2s;
  margin-right: 4px;
}

button:hover { background-color: #3a2a1a; }

@media print {
  @page { margin: 0.5in; size: letter; }
  .character-sheet { box-shadow: none; border: none; max-width: 100%; }
  button { display: none; }
  section { page-break-inside: avoid; }
}

@media (max-width: 600px) {
  .form-row { flex-direction: column; }
  .form-row.cols-2 { flex-direction: row; }
  .form-row.cols-3 { flex-direction: row; }
  .form-row.cols-3 > .form-group { flex: 0 0 calc(50% - 4px); max-width: calc(50% - 4px); }
  .row-container { flex-direction: column; }
}
