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

body {
  background: #2c2c2c;
  color: #eee;
  font-family: 'Segoe UI', system-ui, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow-y: auto;
}

#setup-screen {
  text-align: center;
}

#tiles-top,
#tiles-bottom {
  display: block;
  margin: 0 auto;
}

#tiles-top {
  margin-bottom: 1rem;
}

#tiles-bottom {
  margin-top: 1.5rem;
}

#setup-screen h1 {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.gametype-list {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.gametype-btn {
  width: 125px;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  border: 2px solid #555;
  border-radius: 8px;
  background: #3a3a3a;
  color: #ccc;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.gametype-btn:hover {
  background: #4a4a4a;
  border-color: #999;
  color: #fff;
}

.gametype-btn.selected {
  border-color: #7cb8ff;
  background: #2a4a6a;
  color: #fff;
}

.mode-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.mode-btn {
  width: 260px;
  padding: 0.7rem 1.4rem;
  font-size: 1.1rem;
  border: 2px solid #555;
  border-radius: 8px;
  background: #3a3a3a;
  color: #ccc;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.mode-btn:hover {
  background: #4a4a4a;
  border-color: #999;
  color: #fff;
}

.mode-btn.default {
  border-color: #888;
  background: #444;
  color: #eee;
}

.mode-btn.selected {
  border-color: #7cb8ff;
  background: #2a4a6a;
  color: #fff;
}

#personality-panel {
  margin: 0.5rem auto 0;
  padding: 1rem 1.5rem;
  background: #333;
  border: 1px solid #555;
  border-radius: 8px;
  max-width: 320px;
}

.personality-slot {
  margin-bottom: 0.8rem;
}

.personality-slot label {
  display: block;
  font-size: 0.85rem;
  color: #aaa;
  margin-bottom: 0.4rem;
}

.personality-options {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.personality-options button {
  padding: 0.35rem 0.7rem;
  font-size: 0.9rem;
  border: 1px solid #555;
  border-radius: 5px;
  background: #3a3a3a;
  color: #ccc;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.personality-options button:hover {
  background: #4a4a4a;
  border-color: #999;
}

.personality-options button.active {
  border-color: #7cb8ff;
  background: #2a4a6a;
  color: #fff;
}

.personality-desc {
  font-size: 0.75rem;
  color: #888;
  margin-top: 0.3rem;
  min-height: 1.1em;
}

#start-btn {
  display: block;
  margin: 0.8rem auto 0;
  padding: 0.6rem 2rem;
  font-size: 1.1rem;
  border: 2px solid #7cb8ff;
  border-radius: 8px;
  background: #2a4a6a;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

#start-btn:hover {
  background: #3a5a7a;
}

#game-screen {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#debug-panel {
  width: 100%;
  max-height: 400px;
  overflow-y: auto;
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 4px;
  margin-top: 8px;
  padding: 0;
  user-select: text;
}

.debug-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #252525;
  border-bottom: 1px solid #444;
  position: sticky;
  top: 0;
  cursor: pointer;
}

.debug-header button:first-of-type {
  margin-left: auto;
}

.debug-triangle {
  font-size: 10px;
  color: #888;
  transition: transform 0.15s;
  display: inline-block;
}

#debug-panel:not(.collapsed) .debug-triangle {
  transform: rotate(90deg);
}

#debug-panel.collapsed #debug-content {
  display: none;
}

#debug-panel.collapsed .debug-header {
  border-bottom: none;
}

.debug-header span {
  font-size: 12px;
  color: #aaa;
}

.debug-header small {
  color: #666;
}

.debug-header button {
  padding: 2px 10px;
  font-size: 11px;
  border: 1px solid #555;
  border-radius: 3px;
  background: #333;
  color: #ccc;
  cursor: pointer;
}

.debug-header button:hover {
  background: #444;
}

#debug-content {
  margin: 0;
  padding: 8px 10px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 11px;
  line-height: 1.4;
  color: #ccc;
  white-space: pre;
}

#debug-load-area {
  padding: 8px 10px;
  border-bottom: 1px solid #444;
}

#debug-load-area textarea {
  width: 100%;
  box-sizing: border-box;
  background: #111;
  color: #ccc;
  border: 1px solid #555;
  border-radius: 3px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 11px;
  line-height: 1.4;
  padding: 6px;
  resize: vertical;
}

.debug-load-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.debug-load-error {
  font-size: 11px;
  color: #f44;
}

.debug-load-actions button {
  margin-left: auto;
  padding: 3px 14px;
  font-size: 11px;
  border: 1px solid #555;
  border-radius: 3px;
  background: #2a6e2a;
  color: #eee;
  cursor: pointer;
}

.debug-load-actions button:hover {
  background: #3a8e3a;
}

#debug-panel.collapsed #debug-load-area {
  display: none;
}

#debug-panel.collapsed #tile-ref-panel {
  display: none;
}

#tile-ref-panel {
  border-top: 1px solid #444;
}

.tile-ref-header {
  padding: 6px 10px;
  background: #252525;
  border-bottom: 1px solid #444;
  font-size: 12px;
  color: #aaa;
}

#tile-ref-canvas {
  display: block;
  margin: 0 auto;
  padding: 4px 0;
}

#game-screen canvas {
  display: block;
}

#overlay {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.hidden {
  display: none !important;
}
