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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #1a1a2e;
  color: #eee;
  overflow: hidden;
}

.board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(4, 1fr);
  width: 100vw;
  height: 100vh;
  gap: 2px;
  padding: 2px;
}

.tile {
  background: #16213e;
  border-radius: 4px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.tile-key {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-size: 12px;
  color: #555;
  text-transform: uppercase;
}

.button {
  position: absolute;
  inset: 4px;
  background: #0f3460;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s, background 0.1s;
  overflow: hidden;
}

.button:hover {
  background: #1a4a7a;
}

.button:active {
  transform: scale(0.97);
}

.button.tab {
  background: #533483;
}

.button.tab:hover {
  background: #6a4a9a;
}

.button.tab.active {
  background: #7b5aa6;
  box-shadow: 0 0 0 2px #a78bfa;
}


.button-title {
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  padding: 4px 8px;
  word-break: break-word;
}

.button-key {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
}

.button-controls {
  position: absolute;
  top: 2px;
  right: 2px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.button:hover .button-controls {
  opacity: 1;
}

.btn-icon {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 3px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: rgba(255,255,255,0.25);
}

.drag-handle {
  cursor: grab;
}

.drag-handle:active {
  cursor: grabbing;
}

.tile.drag-over {
  background: #2a3a5e;
  outline: 2px dashed #4a6a9e;
}

.button.tab.drag-over {
  outline: 2px dashed #a78bfa;
}

/* New button prompt */
.new-button-prompt {
  display: flex;
  gap: 8px;
}

.new-button-prompt button {
  padding: 8px 12px;
  border: none;
  border-radius: 4px;
  background: #0f3460;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
}

.new-button-prompt button:hover {
  background: #1a4a7a;
}

.new-button-prompt button.tab-btn {
  background: #533483;
}

.new-button-prompt button.tab-btn:hover {
  background: #6a4a9a;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: #1a1a2e;
  border-radius: 8px;
  padding: 20px;
  min-width: 320px;
  max-width: 90vw;
}

.modal h2 {
  margin-bottom: 16px;
  font-size: 18px;
}

.modal label {
  display: block;
  margin-bottom: 12px;
}

.modal label span {
  display: block;
  font-size: 12px;
  color: #888;
  margin-bottom: 4px;
}

.modal input, .modal textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid #333;
  border-radius: 4px;
  background: #16213e;
  color: #fff;
  font-size: 14px;
}

.modal textarea {
  min-height: 200px;
  font-family: monospace;
  font-size: 12px;
}

.modal-buttons {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: flex-end;
}

.modal-buttons button {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.modal-buttons .save {
  background: #0f3460;
  color: #fff;
}

.modal-buttons .save:hover {
  background: #1a4a7a;
}

.modal-buttons .cancel {
  background: #333;
  color: #fff;
}

.modal-buttons .cancel:hover {
  background: #444;
}

.modal-buttons .delete {
  background: #8b0000;
  color: #fff;
}

.modal-buttons .delete:hover {
  background: #a00;
}

/* Export/Import panel */
.export-panel {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 50;
}

.export-panel button {
  padding: 8px 12px;
  border: none;
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  margin-left: 4px;
}

.export-panel button:hover {
  background: rgba(255,255,255,0.2);
}

/* Instructions */
.instructions {
  position: fixed;
  bottom: 10px;
  left: 10px;
  font-size: 11px;
  color: #555;
  z-index: 50;
}
