:root {
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  line-height: 1.35;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f5f7fb;
  color: #1f2937;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr 300px;
}

.sidebar,
.details {
  padding: 1rem;
  background: #ffffff;
  border-right: 1px solid #d6d9e0;
}

.details {
  border-right: none;
  border-left: 1px solid #d6d9e0;
}

.main-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.main-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #d6d9e0;
  background: #ffffff;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.board-controls {
  display: flex;
  gap: 0.45rem;
}

.board-controls button {
  min-width: 2.3rem;
  padding: 0.45rem 0.6rem;
}

.main-header h2,
.sidebar h1,
.details h3 {
  margin: 0;
}

.status,
.muted {
  color: #6b7280;
  font-size: 0.9rem;
}

.status {
  margin: 0;
  color: inherit;
}

.status-banner {
  margin-top: 0.65rem;
  border: 1px solid;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
}

.status-banner.status-info {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1e3a8a;
}

.status-banner.status-error {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #991b1b;
}

.row {
  display: flex;
  gap: 0.5rem;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 0.5rem 0.55rem;
  border-radius: 8px;
  border: 1px solid #c9ced9;
}

button {
  border: none;
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  background: #2563eb;
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: #1d4ed8;
}

.grid-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: grid;
  gap: 0.5rem;
}

.import-export-controls {
  display: grid;
  gap: 0.5rem;
}

.grid-tools-panel {
  margin-top: 1rem;
  padding: 0.75rem;
  border: 1px solid #d6d9e0;
  border-radius: 10px;
  background: #f8fafc;
}

.grid-tools-panel h3 {
  margin: 0;
  font-size: 0.98rem;
}

#selected-grid-tools-name {
  margin: 0.35rem 0 0.25rem;
  font-weight: 600;
  color: #374151;
}

.grid-tools-panel .muted {
  margin: 0.25rem 0;
}

.import-export-controls {
  margin-top: 0.6rem;
}

.raw-import-label {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.88rem;
  color: #374151;
}

.raw-import-input {
  margin-top: 0.35rem;
  width: 100%;
  resize: vertical;
  min-height: 120px;
  padding: 0.55rem;
  border: 1px solid #c9ced9;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.4;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 40;
}

.modal-backdrop[hidden] {
  display: none;
}

.toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 60;
  display: grid;
  gap: 0.55rem;
  width: min(360px, calc(100vw - 2rem));
}

.toast {
  border: 1px solid #93c5fd;
  background: #eff6ff;
  color: #1e3a8a;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
  font-size: 0.9rem;
}

.toast.toast-error {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #991b1b;
}

.modal-card {
  width: min(680px, 100%);
  background: #ffffff;
  border: 1px solid #d6d9e0;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2);
}

.modal-card h3 {
  margin: 0 0 0.45rem;
}

.modal-actions {
  margin-top: 0.75rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.button-secondary {
  background: #e5e7eb;
  color: #111827;
}

.button-secondary:hover {
  background: #d1d5db;
}

.button-danger {
  background: #dc2626;
}

.button-danger:hover {
  background: #b91c1c;
}

.grid-list button {
  width: 100%;
  text-align: left;
  background: #edf2ff;
  color: #111827;
}

.grid-list button.active {
  background: #2563eb;
  color: #fff;
}

.board-wrap {
  flex: 1;
  padding: 1rem;
  min-height: 500px;
}

.hex-board {
  width: 100%;
  height: 100%;
  background: #f8fafc;
  border: 1px solid #d6d9e0;
  border-radius: 14px;
  cursor: grab;
}

.hex-board.is-panning {
  cursor: grabbing;
}

.hex-tile {
  fill: #dcfce7;
  stroke: #334155;
  stroke-width: 1.6;
  cursor: grab;
}

.hex-tile.selected {
  stroke: #1d4ed8;
  stroke-width: 2.3;
}

.hex-tile.difficulty-1 {
  fill: #4ade80;
}

.hex-tile.difficulty-2 {
  fill: #14b8a6;
}

.hex-tile.difficulty-3 {
  fill: #a78bfa;
}

.hex-tile.difficulty-4 {
  fill: #facc15;
}

.hex-tile.draft {
  fill: #fff7ed;
  stroke: #ea580c;
  stroke-width: 2;
}

.hex-tile.drag-preview {
  fill: #dbeafe;
  stroke: #2563eb;
  stroke-width: 2.2;
  fill-opacity: 0.9;
}

.hex-tile.drag-preview.drop-invalid {
  fill: #fee2e2;
  stroke: #dc2626;
}

.hex-move-slot {
  fill: #dcfce7;
  fill-opacity: 0.7;
  stroke: #22c55e;
  stroke-width: 1.8;
  stroke-dasharray: 3 3;
  pointer-events: none;
}

.tile-label {
  font-size: 11px;
  fill: #0f172a;
  text-anchor: middle;
  pointer-events: none;
}

.tile-count {
  font-size: 11px;
  fill: #334155;
  text-anchor: middle;
  pointer-events: none;
}

.tile-icon-image {
  pointer-events: none;
}

.hex-add {
  fill: #eef2ff;
  stroke: #6366f1;
  stroke-dasharray: 4 4;
  cursor: pointer;
}

.hex-add:hover {
  fill: #dbeafe;
}

.add-symbol {
  font-size: 20px;
  fill: #4338ca;
  text-anchor: middle;
  pointer-events: none;
}

.new-grid-form,
.tile-form {
  display: grid;
  gap: 0.5rem;
  margin-top: 1rem;
}

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

.tile-form-actions button {
  flex: 1;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 260px 1fr;
  }

  .details {
    grid-column: 1 / -1;
    border-left: none;
    border-top: 1px solid #d6d9e0;
  }
}
