:root {
  --primary-color: #8b4513;
  --primary-light: #a0522d;
  --primary-dark: #6b3410;
  --bg-color: #f3e5d8;
  --surface-color: #fff9e6;
  --text-primary: #2c1810;
  --text-secondary: #5c4033;
  --border-color: #8b4513;
  --shadow-sm: 0 2px 4px rgba(139, 69, 19, 0.15);
  --shadow-md: 0 4px 8px rgba(139, 69, 19, 0.2);
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
}

body {
  text-align: center;
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: 'Crimson Text', 'Bookman Old Style', Georgia, serif;
  margin: 0;
  padding: 1.5rem;
  background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAUVBMVEWFhYWDg4N3d3dtbW17e3t1dXWBgYGHh4d5eXlzc3OLi4ubm5uVlZWPj4+NjY19fX2JiYl/f39ra2uRkZGZmZlpaWmXl5dvb29xcXGTk5NnZ2c8TV1mAAAAG3RSTlNAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEAvEOwtAAAFVklEQVR4XpWWB67c2BUFb3g557T/hRo9/WUMZHlgr4Bg8Z4qQgQJlHI4A8SzFVrapvmTF9O7dmYRFZ60YiBhJRCgh1FYhiLAmdvX0CzTOpNE77ME0Zty/nWWzchDtiqrmQDeuv3powQ5ta2eN0FY0InkqDD73lT9c9lEzwUNqgFHs9VQce3TVClFCQrSTfOiYkVJQBmpbq2L6iZavPnAPcoU0dSw0SUTqz/GtrGuXfbyyBniKykOWQWGqwwMA7QiYAxi+IlPdqo+hYHnUt5ZPfnsHJyNiDtnpJyayNBkF6cWoYGAMY92U2hXHF/C1M8uP/ZtYdiuj26UdAdQQSXQErwSOMzt/XWRWAz5GuSBIkwG1H3FabJ2OsUOUhGC6tK4EMtJO0ttC6IBD3kM0ve0tJwMdSfjZo+EEISaeTr9P3wYrGjXqyC1krcKdhMpxEnt5JetoulscpyzhXN5FRpuPHvbeQaKxFAEB6EN+cYN6xD7RYGpX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WNNWTa5Z5kPZw5+LbVT99wqTdx29lMUH4OIG/D86ruKEauBjvH5xy6um/Sfj7ei6UUVk4AIl3MyD4MSSTOFgSwsH/QJWaQ5as7ZcmgBZkzjjU1UrQ74ci1gWBCSGHtuV1H2mhSnO3Wp/3fEV5a+4wz//6qy8JxjZsmxxy5+4w9CDNJY09T072iKG0EnOS0arEYgXqYnXcYHwjTtUNAcMelOd4xpkoqiTYICWFq0JSiPfPDQdnt+4/wuqcXY47QILbgAAAABJRU5ErkJggg==');
}

h1 {
  color: var(--text-primary);
  font-weight: 700;
  margin-bottom: 2rem;
  font-family: 'MedievalSharp', 'Luminari', 'Fantasy', cursive;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-shadow: 2px 2px 4px rgba(139, 69, 19, 0.2);
}

#mainContainer {
  display: grid;
  grid-template-columns: 70% 30%;
  gap: 1.5rem;
  height: calc(100vh - 100px);
  max-width: 1600px;
  margin: 0 auto;
}

#gridSection {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  height: fit-content;
}

#grid {
  background-color: #fff9f0;
  padding: 0;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  height: fit-content;
  width: fit-content;
  border: 3px solid #d32f2f;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
  background-image: 
    linear-gradient(90deg, #d9d1c7 1px, transparent 1px),
    linear-gradient(#d9d1c7 1px, transparent 1px);
  background-size: 40px 40px;
}

/* Non-placeable area border */
#grid::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to right,
    #d32f2f 0px,
    #d32f2f 2rem,
    transparent 2rem,
    transparent calc(100% - 2rem),
    #d32f2f calc(100% - 2rem),
    #d32f2f 100%
  ),
  linear-gradient(to bottom,
    #d32f2f 0px,
    #d32f2f 2rem,
    transparent 2rem,
    transparent calc(100% - 2rem),
    #d32f2f calc(100% - 2rem),
    #d32f2f 100%
  );
  opacity: 0.2;
  pointer-events: none;
  z-index: 1;
}

#grid .row {
  display: flex;
  gap: 0;
  justify-content: flex-start;
  height: 40px;
  position: relative;
  z-index: 2;
}

#grid .cell {
  width: 40px;
  height: 40px;
  border: none;
  cursor: pointer;
  position: relative;
  box-sizing: border-box;
  transition: all 0.2s ease;
  background-color: transparent;
}

#grid .cell.occupied {
  background-color: rgba(139, 69, 19, 0.15);
  border: 2px solid var(--primary-color);
  margin: 2px;
  width: 36px;
  height: 36px;
  border-radius: 4px;
}

#grid .cell:hover:not(.occupied) {
  background-color: rgba(139, 69, 19, 0.05);
}

#grid .cell.selected {
  background-color: rgba(139, 69, 19, 0.2);
  border: 2px solid var(--primary-color);
  margin: 2px;
  width: 36px;
  height: 36px;
  border-radius: 4px;
}

#grid::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAUVBMVEWFhYWDg4N3d3dtbW17e3t1dXWBgYGHh4d5eXlzc3OLi4ubm5uVlZWPj4+NjY19fX2JiYl/f39ra2uRkZGZmZlpaWmXl5dvb29xcXGTk5NnZ2c8TV1mAAAAG3RSTlNAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEAvEOwtAAAFVklEQVR4XpWWB67c2BUFb3g557T/hRo9/WUMZHlgr4Bg8Z4qQgQJlHI4A8SzFVrapvmTF9O7dmYRFZ60YiBhJRCgh1FYhiLAmdvX0CzTOpNE77ME0Zty/nWWzchDtiqrmQDeuv3powQ5ta2eN0FY0InkqDD73lT9c9lEzwUNqgFHs9VQce3TVClFCQrSTfOiYkVJQBmpbq2L6iZavPnAPcoU0dSw0SUTqz/GtrGuXfbyyBniKykOWQWGqwwMA7QiYAxi+IlPdqo+hYHnUt5ZPfnsHJyNiDtnpJyayNBkF6cWoYGAMY92U2hXHF/C1M8uP/ZtYdiuj26UdAdQQSXQErwSOMzt/XWRW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XtUHrVBFT/DnA3ctNPoGbs4hRIjTok8i+algT1lTHi4SxFvONKNrgQFAq2/gFnWMXgwffgYMJpiKYkmW3tTg3ZQ9Jq+f8XN+A5eeUKHWvJWJ2sgJ1Sop+wwhqFVijqWaJhwtD8MNlSBeWNNWTa5Z5kPZw5+LbVT99wqTdx29lMUH4OIG/D86ruKEauBjvH5xy6um/Sfj7ei6UUVk4AIl3MyD4MSSTOFgSwsH/QJWaQ5as7ZcmgBZkzjjU1UrQ74ci1gWBCSGHtuV1H2mhSnO3Wp/3fEV5a+4wz//6qy8JxjZsmxxy5+4w9CDNJY09T072iKG0EnOS0arEYgXqYnXcYHwjTtUNAcMelOd4xpkoqiTYICWFq0JSiPfPDQdnt+4/wuqcXY47QILbgAAAABJRU5ErkJggg==');
  opacity: 0.05;
  pointer-events: none;
  border-radius: var(--radius-md);
  z-index: 0;
}

#grid .cell.highlight {
  background-color: rgba(139, 69, 19, 0.1);
  border: 2px dashed var(--primary-color);
  margin: 2px;
  width: 36px;
  height: 36px;
  border-radius: 4px;
}

#grid .cell.invalid {
  background-color: rgba(220, 38, 38, 0.1);
  border: 2px solid #dc2626;
  margin: 2px;
  width: 36px;
  height: 36px;
  border-radius: 4px;
}

/* Add a subtle paper texture overlay to the grid */
#grid::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAUVBMVEWFhYWDg4N3d3dtbW17e3t1dXWBgYGHh4d5eXlzc3OLi4ubm5uVlZWPj4+NjY19fX2JiYl/f39ra2uRkZGZmZlpaWmXl5dvb29xcXGTk5NnZ2c8TV1mAAAAG3RSTlNAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEAvEOwtAAAFVklEQVR4XpWWB67c2BUFb3g557T/hRo9/WUMZHlgr4Bg8Z4qQgQJlHI4A8SzFVrapvmTF9O7dmYRFZ60YiBhJRCgh1F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vpskfncCfx8pOhJzd76bJWeYFnFciwcYfubRc12Ip/ppIhA1/mSZ/RxjFDrJC5xifFjJpY2Xl5zXdguFqYyTR1zSp1Y9p+tktDYYSNflcxI0iyO4TPBdlRcpeqjK/piF5bklq77VSEaA+z8qmJTFzIWiitbnzR794USKBUaT0NTEsVjZqLaFVqJoPN9ODG70IPbfBHKK+/q/AWR0tJzYHRULOa4MP+W/HfGadZUbfw177G7j/OGbIs8TahLyynl4X4RinF793Oz+BU0saXtUHrVBFT/DnA3ctNPoGbs4hRIjTok8i+algT1lTHi4SxFvONKNrgQFAq2/gFnWMXgwffgYMJpiKYkmW3tTg3ZQ9Jq+f8XN+A5eeUKHWvJWJ2sgJ1Sop+wwhqFVijqWaJhwtD8MNlSBeWNNWTa5Z5kPZw5+LbVT99wqTdx29lMUH4OIG/D86ruKEauBjvH5xy6um/Sfj7ei6UUVk4AIl3MyD4MSSTOFgSwsH/QJWaQ5as7ZcmgBZkzjjU1UrQ74ci1gWBCSGHtuV1H2mhSnO3Wp/3fEV5a+4wz//6qy8JxjZsmxxy5+4w9CDNJY09T072iKG0EnOS0arEYgXqYnXcYHwjTtUNAcMelOd4xpkoqiTYICWFq0JSiPfPDQdnt+4/wuqcXY47QILbgAAAABJRU5ErkJggg==');
  opacity: 0.02;
  mix-blend-mode: multiply;
  pointer-events: none;
}

#editorPanel {
  background-color: var(--surface-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  text-align: left;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.mode-toggle {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

.mode-toggle:hover {
  background-color: var(--primary-dark);
}

.mode-toggle.view-mode {
  background-color: var(--text-secondary);
}

.mode-toggle.view-mode:hover {
  background-color: var(--text-primary);
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.save-button,
.cancel-button,
.place-button {
  flex: 1;
  padding: 0.75rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

.save-button {
  background-color: var(--primary-color);
  color: white;
}

.save-button:hover {
  background-color: var(--primary-dark);
  transform: translateY(-1px);
}

.cancel-button {
  background-color: var(--text-secondary);
  color: white;
}

.cancel-button:hover {
  background-color: var(--text-primary);
  transform: translateY(-1px);
}

.place-button {
  background-color: var(--primary-light);
  color: white;
}

.place-button:hover {
  background-color: var(--primary-color);
  transform: translateY(-1px);
}

#itemForm {
  display: grid;
  gap: 1rem;
}

#itemForm h3 {
  margin-top: 0;
  color: var(--text-primary);
}

.form-group {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
  gap: 1rem;
}

#itemForm label {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.875rem;
}

#itemForm input,
#itemForm select,
#itemForm textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  transition: border-color 0.2s ease;
  background-color: var(--surface-color);
}

#itemForm textarea {
  grid-column: 1 / -1;
  min-height: 80px;
  resize: vertical;
}

#itemForm input:focus,
#itemForm select:focus,
#itemForm textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#itemForm input[type="submit"] {
  grid-column: 1 / -1;
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  margin-top: 0.5rem;
}

#itemForm input[type="submit"]:hover {
  background-color: var(--primary-dark);
  transform: translateY(-1px);
}

#itemForm input[type="submit"]:active {
  transform: translateY(0);
}

#infoContainer {
  display: grid;
  grid-template-rows: auto auto 1fr 1fr;
  gap: 1.5rem;
  height: 100%;
  background-color: transparent;
  padding: 0;
  box-shadow: none;
  border-radius: 0;
}

#characterPanel {
  background-color: var(--surface-color);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.character-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.character-name-group {
  grid-column: 1 / -1;
  margin-bottom: 1.5rem;
}

#characterPanel .form-group {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}

#characterPanel label {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.875rem;
  text-align: left;
}

#characterPanel input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  transition: border-color 0.2s ease;
  background-color: var(--surface-color);
  text-align: left;
}

#characterPanel input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
}

.strength-input-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.strength-input-group input {
  width: 3rem !important;
  padding: 0.5rem;
  text-align: center;
}

.current-strength {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

#currentItemPanel {
  background-color: var(--surface-color);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 1rem;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#currentItemPanel .placement-info {
  font-size: 0.875rem;
  color: var(--text-secondary);
  background-color: var(--bg-color);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
}

/* On-screen placement controls (tap to rotate/cancel on mobile). */
.placement-rotation {
  font-weight: 600;
  color: var(--text-primary);
}

.placement-buttons {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.placement-buttons .place-button,
.placement-buttons .cancel-button {
  flex: 1;
  padding: 0.75rem;
  font-size: 0.95rem;
}

.placement-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

#currentItemPanel .item-details {
  text-align: left;
}

#currentItemPanel .item-details h3 {
  margin: 0 0 0.75rem 0;
  color: var(--text-primary);
  font-size: 1.125rem;
}

#currentItemPanel .item-details p {
  margin: 0.5rem 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.4;
}

#currentItemPanel .item-details strong {
  color: var(--text-primary);
  font-weight: 500;
}

#carriedItemsPanel {
  background-color: var(--surface-color);
  padding: 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: 400px;
  min-width: 200px;
}

#carriedItemsPanel h3 {
  margin: 0;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1rem;
  padding-bottom: 0.5rem;
}

.carried-item {
  padding: 0.375rem 0.75rem;
  margin: 0;
  background-color: var(--surface-color);
  border: none;
  border-bottom: 1px solid var(--border-color);
  transition: all 0.2s ease;
  font-size: 0.875rem;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  text-align: left;
  height: 32px;
  box-sizing: border-box;
}

.carried-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.carried-items-list {
  margin: 0;
  padding: 0;
  background-color: transparent;
  border-radius: var(--radius-sm);
  height: 320px;
  overflow-y: auto;
  text-align: left;
}

.item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove-item {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  transition: all 0.15s ease;
  flex-shrink: 0;
  opacity: 0;
}

.carried-item:hover .remove-item {
  opacity: 1;
}

.remove-item:hover {
  color: #ef4444;
  background-color: #fee2e2;
}

.carried-item:nth-child(7n + 1) { border-left-color: red; }
.carried-item:nth-child(7n + 2) { border-left-color: blue; }
.carried-item:nth-child(7n + 3) { border-left-color: green; }
.carried-item:nth-child(7n + 4) { border-left-color: purple; }
.carried-item:nth-child(7n + 5) { border-left-color: orange; }
.carried-item:nth-child(7n + 6) { border-left-color: yellow; }
.carried-item:nth-child(7n + 7) { border-left-color: pink; }

.carried-item.selected {
  border-left-width: 3px;
  background-color: rgba(99, 102, 241, 0.1);
}

#ownedItemsPanel {
  background-color: var(--surface-color);
  padding: 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: 400px;
  min-width: 200px;
}

#ownedItemsPanel h3 {
  margin: 0;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1rem;
  padding-bottom: 0.5rem;
}

.owned-items-list {
  margin: 0;
  padding: 0;
  background-color: transparent;
  border-radius: 0;
  height: 320px;
  overflow-y: auto;
  text-align: left;
}

.owned-item {
  padding: 0.375rem 0.75rem;
  margin: 0;
  background-color: transparent !important;
  border: none;
  border-bottom: 1px solid var(--border-color);
  transition: all 0.2s ease;
  font-size: 0.875rem;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  text-align: left;
  height: 32px;
  box-sizing: border-box;
  border-radius: 0;
  box-shadow: none;
}

.owned-item:hover:not(.disabled) {
  background-color: rgba(99, 102, 241, 0.1);
}

.owned-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: transparent !important;
}

#itemForm input:disabled,
#itemForm select:disabled,
#itemForm textarea:disabled {
  background-color: var(--bg-color);
  cursor: not-allowed;
  color: var(--text-secondary);
}

.strength-section {
  margin-top: 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.strength-section label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.875rem;
}

.strength-section input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
}

.strength-section p {
  margin: 0.5rem 0 0 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.placeable:hover {
  background-color: rgba(99, 102, 241, 0.1);
}

.placeable:hover::before {
  content: '+';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--primary-color);
  font-weight: bold;
}

.shadow {
  background-color: rgba(99, 102, 241, 0.2) !important;
  outline: 2px dashed var(--primary-color) !important;
  outline-offset: -2px;
  z-index: 1;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-color);
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb {
  background: var(--text-secondary);
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-primary);
}

.edit-icon {
  opacity: 0;
  transition: all 0.2s ease;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  pointer-events: auto;
}

.edit-icon i {
  font-size: 12px;
}

.edit-icon:hover {
  color: var(--primary-color);
  background-color: rgba(99, 102, 241, 0.1);
}

.owned-item:hover .edit-icon {
  opacity: 1;
}

.owned-item.disabled .edit-icon {
  opacity: 1;
  cursor: pointer;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.panel-actions {
  display: flex;
  gap: 0.5rem;
}

.mode-switch-button {
  background-color: var(--primary-color);
  color: #fff9e6;
  border: 2px solid #6b3410;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: 'MedievalSharp', 'Luminari', 'Fantasy', cursive;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.mode-switch-button:hover {
  background-color: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(107, 52, 16, 0.2);
}

.mode-switch-button i {
  font-size: 0.75rem;
}

.edit-button {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  transition: all 0.15s ease;
}

.edit-button:hover {
  color: var(--primary-color);
  background-color: rgba(99, 102, 241, 0.1);
}

.remove-button {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  transition: all 0.15s ease;
}

.remove-button:hover:not(:disabled) {
  color: #ef4444;
  background-color: #fee2e2;
}

.remove-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.item-actions {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

/* Character Selection Page Styles */
.character-select-container {
  max-width: 600px;
  margin: 2rem auto;
  padding: 2rem;
  background-color: var(--surface-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.character-form {
  margin: 2rem 0;
  padding: 2rem;
  background-color: var(--bg-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.create-button {
  width: 100%;
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 1rem;
}

.create-button:hover {
  background-color: var(--primary-dark);
  transform: translateY(-1px);
}

.recent-characters {
  margin-top: 2rem;
  text-align: left;
}

.recent-characters h2 {
  color: var(--text-primary);
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.characters-list {
  display: grid;
  gap: 0.75rem;
}

.character-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background-color: var(--bg-color);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  cursor: pointer;
}

.character-card:hover {
  background-color: var(--primary-light);
  color: white;
  transform: translateX(4px);
}

.character-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.character-name {
  font-weight: 600;
  font-size: 1rem;
}

.player-name {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.character-card:hover .player-name {
  color: rgba(255, 255, 255, 0.8);
}

.form-actions-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.create-button, .load-button {
  width: 100%;
  padding: 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 1rem;
  border: none;
  color: white;
}

.create-button {
  background-color: var(--primary-color);
}

.create-button:hover {
  background-color: var(--primary-dark);
  transform: translateY(-1px);
}

.load-button {
  background-color: var(--text-secondary);
}

.load-button:hover {
  background-color: var(--text-primary);
  transform: translateY(-1px);
}

.error-message {
  color: #ef4444;
  font-size: 0.875rem;
  margin-top: 0.5rem;
  display: none;
}

.error-message.visible {
  display: block;
}

.player-info {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  margin-bottom: 1rem;
}

.player-info input[readonly] {
  background-color: var(--bg-color);
  color: var(--text-secondary);
  cursor: default;
}

input[readonly] {
  background-color: var(--bg-color);
  color: var(--text-secondary);
  cursor: default;
}

.switch-characters-button {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.switch-characters-button:hover {
  background-color: var(--primary-dark);
  transform: translateY(-1px);
}

.switch-characters-button i {
  font-size: 0.875rem;
}

/* ===========================================================================
   Mobile / responsive layout
   The desktop layout is a fixed two-column grid; on small screens we collapse
   everything to a single column, let the inventory grid scroll horizontally,
   and reveal controls that are otherwise hover-only (no hover on touch).
   =========================================================================== */
@media (max-width: 768px) {
  body {
    padding: 0.75rem;
  }

  h1 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
  }

  /* Inputs/buttons shouldn't overflow their (now narrower) columns. */
  input,
  select,
  textarea,
  button {
    box-sizing: border-box;
  }

  /* Whole page: single column, natural height instead of a fixed viewport. */
  #mainContainer {
    grid-template-columns: 1fr;
    height: auto;
    gap: 1rem;
  }

  /* Stack the inventory grid above the carried-items panel. */
  #gridSection {
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
  }

  /* Grid/flex children default to min-width:auto, which would force the column
     to grow to the inventory grid's full width (overflowing the page). Allow
     them to shrink so #grid's own horizontal scroll takes over instead. */
  #mainContainer > *,
  #gridAndEditorContainer,
  #gridSection,
  #grid,
  #infoContainer,
  #infoContainer > * {
    min-width: 0;
  }

  /* Let a wide inventory grid scroll sideways rather than overflow the page. */
  #grid {
    max-width: 100%;
    overflow: auto;
  }

  #editorPanel,
  #characterPanel,
  #currentItemPanel {
    padding: 1rem;
  }

  /* Form rows: label above the field. */
  .form-group {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  /* Character info: one field per row. */
  .character-info-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Right-hand info column: flow naturally instead of fixed-height rows. */
  #infoContainer {
    grid-template-rows: none;
    height: auto;
  }

  /* List panels size to content (capped) instead of a fixed 400px. */
  #carriedItemsPanel,
  #ownedItemsPanel {
    height: auto;
  }

  .carried-items-list,
  .owned-items-list {
    height: auto;
    max-height: 260px;
  }

  /* No hover on touch: keep row actions visible. */
  .remove-item,
  .edit-icon {
    opacity: 1;
  }

  /* Selection / create pages: tighter spacing on small screens. */
  .character-select-container {
    margin: 1rem auto;
    padding: 1.25rem;
  }

  .character-form {
    margin: 1rem 0;
    padding: 1.25rem;
  }
}
