@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Silkscreen:wght@400;700&display=swap');

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

body {
  background: #0a0a0f;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-family: 'Silkscreen', cursive;
  overflow: hidden;
  color: #c8b07a;
}

/* ---- Canvas layers ---- */
.game-container {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#scene {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  transform-origin: center center;
}

.ui-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 10;
}

#ui {
  pointer-events: none;
  width: 100vw;
  height: 100vh;
}

/* ---- Shared UI panel styles ---- */
.panel {
  background: rgba(26, 20, 16, 0.92);
  border: 1px solid #3a2e20;
  color: #c8b07a;
  font-family: 'Silkscreen', cursive;
}

.panel-title {
  font-family: 'Press Start 2P', cursive;
  font-size: 10px;
  color: #c8b07a;
  text-shadow: 0 0 8px rgba(200, 176, 122, 0.3);
  padding: 6px 10px;
  border-bottom: 1px solid #3a2e20;
  letter-spacing: 1px;
}

.btn {
  font-family: 'Press Start 2P', cursive;
  font-size: 8px;
  background: #2a2018;
  color: #c8b07a;
  border: 1px solid #3a2e20;
  padding: 8px 16px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: #3a2e20;
  border-color: #5a4a30;
}

.btn:active {
  background: #4a3a28;
}

.btn-primary {
  background: #3a2e20;
  border-color: #5a4a30;
}

.btn-primary:hover {
  background: #4a3a28;
  border-color: #6a5a40;
}

.btn-danger {
  color: #d45a5a;
  border-color: #5a2020;
}

.btn-danger:hover {
  background: #3a1818;
  border-color: #7a3030;
}

/* ---- Login screen ---- */
#login-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: #0a0a0f;
}

#login-screen canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  image-rendering: pixelated;
}

.login-content {
  position: relative;
  z-index: 1;
  text-align: center;
}

.game-title {
  font-family: 'Press Start 2P', cursive;
  font-size: 24px;
  color: #c8b07a;
  text-shadow: 0 0 20px rgba(200, 176, 122, 0.4), 3px 3px 0 #0a0a0f;
  letter-spacing: 4px;
  margin-bottom: 8px;
}

.game-subtitle {
  font-family: 'Silkscreen', cursive;
  font-size: 10px;
  color: rgba(200, 176, 122, 0.4);
  margin-bottom: 40px;
}

#apple-signin-btn {
  font-family: 'Press Start 2P', cursive;
  font-size: 9px;
  background: #1a1410;
  color: #c8b07a;
  border: 2px solid #3a2e20;
  padding: 14px 28px;
  cursor: pointer;
  letter-spacing: 2px;
  transition: all 0.2s;
}

#apple-signin-btn:hover {
  background: #2a2018;
  border-color: #5a4a30;
  box-shadow: 0 0 20px rgba(200, 176, 122, 0.15);
}

#apple-signin-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.auth-status {
  margin-top: 12px;
  min-height: 16px;
  font-size: 10px;
  color: rgba(200, 176, 122, 0.75);
}

/* ---- Character Select ---- */
#character-select {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: #0a0a0f;
}

.char-select-title {
  font-family: 'Press Start 2P', cursive;
  font-size: 14px;
  color: #c8b07a;
  text-shadow: 0 0 12px rgba(200, 176, 122, 0.3);
  margin-bottom: 30px;
  letter-spacing: 2px;
}

.char-list {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.char-slot {
  width: 160px;
  height: 200px;
  background: rgba(26, 20, 16, 0.9);
  border: 1px solid #3a2e20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.char-slot:hover {
  border-color: #5a4a30;
  box-shadow: 0 0 15px rgba(200, 176, 122, 0.1);
}

.char-slot.selected {
  border-color: #c8b07a;
  box-shadow: 0 0 20px rgba(200, 176, 122, 0.2);
}

.char-slot-empty {
  font-family: 'Press Start 2P', cursive;
  font-size: 24px;
  color: #3a2e20;
}

.char-slot-name {
  font-family: 'Press Start 2P', cursive;
  font-size: 9px;
  color: #c8b07a;
  margin-top: 8px;
}

.char-slot-info {
  font-size: 10px;
  color: rgba(200, 176, 122, 0.6);
  margin-top: 4px;
}

.char-actions {
  display: flex;
  gap: 12px;
}

/* ---- Character Create ---- */
#character-create {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: #0a0a0f;
  gap: 16px;
}

.create-section {
  text-align: center;
}

.create-section h3 {
  font-family: 'Press Start 2P', cursive;
  font-size: 9px;
  color: #c8b07a;
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.option-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 520px;
}

.option-btn {
  font-family: 'Silkscreen', cursive;
  font-size: 11px;
  background: #1a1410;
  color: #8a7a60;
  border: 1px solid #2a2018;
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.option-btn:hover {
  color: #c8b07a;
  border-color: #3a2e20;
}

.option-btn.selected {
  background: #2a2018;
  color: #c8b07a;
  border-color: #5a4a30;
}

.name-input {
  font-family: 'Press Start 2P', cursive;
  font-size: 10px;
  background: #1a1410;
  color: #c8b07a;
  border: 1px solid #3a2e20;
  padding: 10px 16px;
  width: 220px;
  text-align: center;
  outline: none;
  letter-spacing: 2px;
}

.name-input:focus {
  border-color: #5a4a30;
}

.create-error {
  font-family: 'Silkscreen', cursive;
  font-size: 10px;
  color: #d45a5a;
  min-height: 14px;
}

/* ---- Game HUD (HTML-based overlays for windows) ---- */
.game-window {
  position: fixed;
  z-index: 50;
  pointer-events: auto;
  display: none;
}

.game-window .panel {
  min-width: 240px;
}

.close-btn {
  position: absolute;
  top: 4px;
  right: 6px;
  font-family: 'Press Start 2P', cursive;
  font-size: 8px;
  color: #8a7a60;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
}

.close-btn:hover {
  color: #d45a5a;
}

/* ---- Inventory window ---- */
#inventory-window {
  top: 100px;
  right: 20px;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(5, 36px);
  gap: 2px;
  padding: 8px;
}

.inv-slot {
  width: 36px;
  height: 36px;
  background: #0e0a08;
  border: 1px solid #2a2018;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 8px;
  color: #5a4a30;
}

.inv-slot:hover {
  border-color: #4a3a28;
}

.inv-slot.has-item {
  border-color: #3a2e20;
}

.equipment-slots {
  display: flex;
  gap: 2px;
  padding: 8px;
  justify-content: center;
  border-bottom: 1px solid #2a2018;
}

.equip-slot {
  width: 36px;
  height: 36px;
  background: #0e0a08;
  border: 1px solid #2a2018;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 6px;
  color: #3a2e20;
  cursor: pointer;
}

/* ---- Character window ---- */
#character-window {
  top: 100px;
  left: 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 8px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  padding: 2px 4px;
}

.stat-label {
  color: #8a7a60;
}

.stat-value {
  color: #c8b07a;
  font-family: 'Press Start 2P', cursive;
  font-size: 8px;
}

/* ---- Skills window ---- */
#skills-window {
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
}

#settings-window {
  top: 120px;
  left: 50%;
  transform: translateX(-50%);
  width: 380px;
}

#settings-window .panel {
  width: 100%;
}

.settings-body {
  padding: 14px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.setting-row {
  display: grid;
  grid-template-columns: 110px 1fr 44px;
  align-items: center;
  gap: 10px;
  font-size: 11px;
}

.setting-row span {
  color: #c8b07a;
}

.setting-row input[type="range"] {
  width: 100%;
  accent-color: #a48a54;
}

.settings-help {
  color: rgba(200, 176, 122, 0.6);
  font-size: 10px;
  text-align: right;
}

.skills-list {
  padding: 8px;
}

.skill-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border-bottom: 1px solid #1a1410;
  cursor: pointer;
}

.skill-row:hover {
  background: #1a1410;
}

.skill-row.selected {
  background: #241a12;
  outline: 1px solid #5a4a30;
}

.skill-icon {
  width: 24px;
  height: 24px;
  background: #0e0a08;
  border: 1px solid #2a2018;
}

.skill-name {
  font-size: 10px;
  color: #c8b07a;
}

.skill-cost {
  font-size: 8px;
  color: #5a4a30;
  margin-left: auto;
}

.skills-hotbar-help {
  font-size: 9px;
  color: rgba(200, 176, 122, 0.7);
  padding: 6px 10px 10px;
  border-top: 1px solid #1a1410;
}

/* ---- Chat ---- */
#chat-container {
  position: fixed;
  bottom: 60px;
  left: 10px;
  width: 320px;
  z-index: 50;
  pointer-events: auto;
}

#chat-log {
  background: rgba(10, 8, 6, 0.7);
  border: 1px solid #2a2018;
  height: 120px;
  overflow-y: auto;
  padding: 4px 8px;
  font-size: 10px;
  scrollbar-width: thin;
  scrollbar-color: #3a2e20 transparent;
}

#chat-log::-webkit-scrollbar {
  width: 4px;
}

#chat-log::-webkit-scrollbar-thumb {
  background: #3a2e20;
}

.chat-msg {
  padding: 1px 0;
  word-wrap: break-word;
}

.chat-msg .name {
  color: #7a9ab8;
  font-family: 'Press Start 2P', cursive;
  font-size: 7px;
}

.chat-msg .text {
  color: #b0a080;
}

.chat-msg.system {
  color: #6a8a5a;
  font-style: italic;
}

#chat-input {
  width: 100%;
  font-family: 'Silkscreen', cursive;
  font-size: 10px;
  background: rgba(10, 8, 6, 0.9);
  color: #c8b07a;
  border: 1px solid #2a2018;
  border-top: none;
  padding: 6px 8px;
  outline: none;
}

#chat-input:focus {
  border-color: #3a2e20;
}

/* ---- Zone name ---- */
.zone-name {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Press Start 2P', cursive;
  font-size: 13px;
  color: #c8b07a;
  text-shadow: 0 0 12px rgba(200, 176, 122, 0.4), 2px 2px 0 #0a0a0f;
  letter-spacing: 3px;
  white-space: nowrap;
  z-index: 20;
  pointer-events: none;
}

.zone-sub {
  position: fixed;
  top: 32px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Silkscreen', cursive;
  font-size: 9px;
  color: rgba(200, 176, 122, 0.35);
  z-index: 20;
  pointer-events: none;
}

.btn-settings {
  position: fixed;
  top: 12px;
  right: 14px;
  z-index: 35;
}

/* ---- Loading / transitions ---- */
.screen-fade {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  background: #0a0a0f;
  z-index: 200;
  transition: opacity 0.5s;
  pointer-events: none;
}

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