/* =============================================
   The Last Dungeon - Dark Dungeon Theme
   ============================================= */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0808;
  color: #d4cbb8;
  font-family: system-ui, -apple-system, 'Segoe UI', monospace;
  font-size: 14px;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: #0a0808;
}
::-webkit-scrollbar-thumb {
  background: #3a3232;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #4a3e3e;
}

/* --- Screens --- */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  z-index: 5;
}
.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Auth Screen --- */
#auth-screen {
  background: radial-gradient(ellipse at center bottom, #1a1210 0%, #0a0808 70%);
}

.auth-container {
  text-align: center;
}

.game-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 4rem;
  font-weight: 700;
  color: #ff8830;
  text-shadow:
    0 0 20px rgba(255, 136, 48, 0.5),
    0 0 60px rgba(255, 136, 48, 0.2),
    0 2px 4px rgba(0, 0, 0, 0.8);
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.tagline {
  font-size: 1.1rem;
  color: #8a7e6e;
  font-style: italic;
  margin-bottom: 48px;
  letter-spacing: 1px;
}

.auth-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.apple-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 280px;
  height: 44px;
  background: #1a1818;
  color: #d4cbb8;
  border: 1px solid #3a3232;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.apple-btn:hover {
  background: #201e1e;
  border-color: #ff8830;
}
.apple-btn svg {
  flex-shrink: 0;
}

/* --- Panels --- */
.panel {
  background: #1a1818;
  border: 1px solid #2a2424;
  border-radius: 8px;
  padding: 32px;
  min-width: 360px;
  max-width: 480px;
  text-align: center;
}
.panel h2 {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.6rem;
  color: #ff8830;
  margin-bottom: 24px;
  text-shadow: 0 0 10px rgba(255, 136, 48, 0.3);
}

/* --- Buttons --- */
.btn {
  display: inline-block;
  padding: 10px 24px;
  background: #1a1818;
  color: #d4cbb8;
  border: 1px solid #4a3828;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 12px;
}
.btn:hover {
  background: #201e1e;
  border-color: #ff8830;
  box-shadow: 0 0 12px rgba(255, 136, 48, 0.2);
}
.btn-secondary {
  border-color: #2a2424;
  color: #8a7e6e;
}
.btn-secondary:hover {
  border-color: #5a4e3e;
  box-shadow: none;
}

/* --- Character Select --- */
.character-slots {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.character-slot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #141212;
  border: 1px solid #2a2424;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.character-slot:hover {
  border-color: #ff8830;
  background: #1a1616;
}

.char-slot-preview {
  image-rendering: pixelated;
  width: 36px;
  height: 48px;
  background: #0a0808;
  border-radius: 3px;
}

.char-info {
  text-align: left;
  flex: 1;
}
.char-name {
  font-size: 15px;
  color: #d4cbb8;
  font-weight: 600;
}
.char-details {
  font-size: 12px;
  color: #8a7e6e;
  margin-top: 2px;
  text-transform: capitalize;
}

.delete-char-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: #5a4444;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
}
.delete-char-btn:hover {
  color: #c0392b;
}

/* --- Character Create --- */
.create-panel {
  min-width: 400px;
  max-width: 520px;
}

.create-form {
  text-align: left;
}

.form-row {
  margin-bottom: 16px;
}
.form-row label {
  display: block;
  font-size: 12px;
  color: #8a7e6e;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.form-row input[type="text"] {
  width: 100%;
  padding: 8px 12px;
  background: #0a0808;
  border: 1px solid #2a2424;
  border-radius: 4px;
  color: #d4cbb8;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.form-row input[type="text"]:focus {
  border-color: #ff8830;
}
.form-row input[type="text"]::placeholder {
  color: #4a4040;
}

.option-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.option-btn {
  padding: 6px 14px;
  background: #0a0808;
  border: 1px solid #2a2424;
  border-radius: 4px;
  color: #8a7e6e;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}
.option-btn:hover {
  border-color: #4a3e3e;
  color: #d4cbb8;
}
.option-btn.selected {
  background: #2a1e14;
  border-color: #ff8830;
  color: #ff8830;
  box-shadow: 0 0 8px rgba(255, 136, 48, 0.15);
}

.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.color-row label {
  display: inline;
  margin-bottom: 0;
}
.color-row input[type="color"] {
  width: 36px;
  height: 28px;
  border: 1px solid #2a2424;
  border-radius: 3px;
  background: #0a0808;
  cursor: pointer;
  padding: 0;
}
.color-row input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}
.color-row input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.preview-container {
  display: flex;
  justify-content: center;
  padding: 16px 0;
}
#char-preview {
  image-rendering: pixelated;
  background: #0a0808;
  border: 1px solid #2a2424;
  border-radius: 4px;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.error-text {
  color: #c0392b;
  font-size: 13px;
  text-align: center;
  margin-top: 8px;
  min-height: 18px;
}

/* --- Game Screen --- */
#game-screen {
  display: none;
  z-index: 1;
}
#game-screen.active {
  display: block;
}

#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  image-rendering: pixelated;
}

#light-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

/* --- HUD --- */
#hud {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  pointer-events: none;
}

.bar-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.bar {
  position: relative;
  width: 180px;
  height: 16px;
  background: #141010;
  border: 1px solid #2a2424;
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  transition: width 0.3s ease;
  border-radius: 2px;
}

.hp-bar .bar-fill {
  background: linear-gradient(to bottom, #e74c3c, #c0392b);
}
.mp-bar .bar-fill {
  background: linear-gradient(to bottom, #3498db, #2980b9);
}
.stamina-bar .bar-fill {
  background: linear-gradient(to bottom, #2ecc71, #27ae60);
}

.bar span {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  white-space: nowrap;
  z-index: 1;
}

.player-info {
  display: flex;
  gap: 8px;
  font-size: 12px;
}
#player-name {
  color: #d4cbb8;
  font-weight: 600;
}
#player-level {
  color: #8a7e6e;
}

/* --- Chat Panel --- */
#chat-panel {
  position: absolute;
  bottom: 12px;
  left: 12px;
  width: 300px;
  z-index: 10;
}

#chat-messages {
  height: 200px;
  overflow-y: auto;
  padding: 8px;
  background: rgba(10, 8, 8, 0.75);
  border: 1px solid #2a2424;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
}

.chat-message {
  font-size: 12px;
  line-height: 1.4;
  margin-bottom: 2px;
  word-wrap: break-word;
}
.chat-name {
  color: #ff8830;
  font-weight: 600;
}

#chat-input {
  width: 100%;
  padding: 6px 10px;
  background: rgba(10, 8, 8, 0.85);
  border: 1px solid #2a2424;
  border-radius: 0 0 4px 4px;
  color: #d4cbb8;
  font-size: 12px;
  font-family: inherit;
  outline: none;
}
#chat-input:focus {
  border-color: #ff8830;
  background: rgba(20, 16, 16, 0.9);
}
#chat-input::placeholder {
  color: #4a4040;
}

/* --- Map Overlay --- */
#map-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 20;
  background: rgba(10, 8, 8, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#map-overlay.hidden {
  display: none;
}

#map-canvas {
  image-rendering: pixelated;
  max-width: 80vw;
  max-height: 70vh;
  border: 1px solid #2a2424;
  border-radius: 4px;
}

.map-title {
  margin-top: 12px;
  font-size: 13px;
  color: #8a7e6e;
  letter-spacing: 1px;
}

/* --- Utilities --- */
.hidden {
  display: none !important;
}
