* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: #14181c;
  color: #e8e8e8;
}
.screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.hidden { display: none !important; }

.auth-box {
  background: #1e242a;
  padding: 32px;
  border-radius: 10px;
  width: 320px;
  text-align: center;
}
.auth-box h1 { margin-top: 0; color: #f0c674; }
.tabs { display: flex; margin-bottom: 16px; }
.tab {
  flex: 1;
  padding: 8px;
  background: #262d34;
  border: none;
  color: #aaa;
  cursor: pointer;
  border-radius: 6px;
}
.tab.active { background: #3a4552; color: #fff; }
#auth-form { display: flex; flex-direction: column; gap: 10px; }
#auth-form input {
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #3a4552;
  background: #14181c;
  color: #eee;
}
#auth-form button[type="submit"] {
  padding: 10px;
  border-radius: 6px;
  border: none;
  background: #f0c674;
  color: #1e242a;
  font-weight: bold;
  cursor: pointer;
}
.error { color: #e06c75; min-height: 1.2em; }

/* Mobile first: map on top, panels stacked underneath. */
#game-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  padding: 12px;
  width: 100%;
}
.hud {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#map-wrapper { order: -1; }

/* Wide screens: menus on the left, map in the middle, social panels on the right. */
@media (min-width: 1100px) {
  #game-screen {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
    justify-content: center;
    gap: 16px;
    padding: 16px;
  }
  .hud {
    width: 240px;
    max-width: 240px;
    flex: 0 0 240px;
  }
  #map-wrapper {
    order: 0;
    flex: 0 1 840px;
    min-width: 0;
  }
}
.hud-title { font-weight: bold; font-size: 1.1em; color: #f0c674; }
.hud-gold { font-size: 0.9em; color: #f0c674; margin-top: -6px; }
.hud-region { font-size: 0.85em; color: #9aa4ae; margin-top: -8px; }

.character-editor { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
#character-preview {
  background: #262d34;
  border-radius: 6px;
  flex-shrink: 0;
}
.character-controls { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.gender-toggle { display: flex; gap: 6px; }
.gender-btn {
  flex: 1;
  padding: 5px 0;
  border: 1px solid #3a4552;
  border-radius: 5px;
  background: #14181c;
  color: #aaa;
  cursor: pointer;
  font-size: 0.8em;
}
.gender-btn.active { background: #3a4552; color: #fff; border-color: #f0c674; }
.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78em;
  color: #9aa4ae;
}
.color-row input[type="color"] {
  width: 32px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: none;
  cursor: pointer;
}
.panel { background: #1e242a; border-radius: 8px; padding: 10px; }
.panel h3 { margin: 0 0 8px; font-size: 0.9em; color: #aaa; }
.panel ul { list-style: none; margin: 0; padding: 0; font-size: 0.9em; }
.panel li { padding: 2px 0; }

#guide-panel ul li, #workbench-panel ul li {
  padding: 8px 0;
  border-top: 1px solid #2c333b;
}
#guide-panel ul li:first-child, #workbench-panel ul li:first-child {
  border-top: none;
}
.recipe-detail { color: #9aa4ae; font-size: 0.85em; }
.craft-btn {
  margin-top: 6px;
  padding: 5px 10px;
  border: none;
  border-radius: 5px;
  background: #f0c674;
  color: #1e242a;
  font-weight: bold;
  cursor: pointer;
  font-size: 0.85em;
}
.craft-btn:disabled {
  background: #3a4552;
  color: #777;
  cursor: not-allowed;
}
.craft-message { min-height: 1.2em; font-size: 0.85em; margin: 8px 0 0; }
.craft-message.error { color: #e06c75; }
.craft-message.success { color: #7ec27e; }

.hint { margin: 0 0 8px; font-size: 0.78em; color: #6b7580; }

.inventory-item {
  padding: 6px 4px;
  border-radius: 5px;
  cursor: pointer;
}
.inventory-item:hover { background: #262d34; }
.item-actions {
  padding: 8px 6px 10px;
  margin: 2px 0 4px;
  background: #161b20;
  border-radius: 6px;
}
.item-actions .recipe-detail { display: block; margin-top: 4px; }
.drink-btn {
  padding: 5px 10px;
  border: none;
  border-radius: 5px;
  background: #57a0f0;
  color: #12181e;
  font-weight: bold;
  cursor: pointer;
  font-size: 0.85em;
}

#effects-ul li {
  display: flex;
  justify-content: space-between;
  font-size: 0.85em;
  padding: 3px 0;
}
#effects-ul .effect-timer { color: #9aa4ae; }

#game-canvas {
  background: #000;
  border-radius: 8px;
  cursor: pointer;
  image-rendering: pixelated;
  display: block;
  width: 100%;
  max-width: 840px;
  height: auto;
}

#map-wrapper {
  position: relative;
  display: block;
  width: 100%;
  max-width: 840px;
  line-height: 0;
}
.map-arrow {
  position: absolute;
  border: none;
  border-radius: 6px;
  background: rgba(240, 198, 116, 0.85);
  color: #1e242a;
  font-weight: bold;
  font-size: 1em;
  line-height: 1;
  cursor: pointer;
  padding: 8px 12px;
  transition: background 0.15s;
}
.map-arrow:hover { background: #f0c674; }
.arrow-up { top: 6px; left: 50%; transform: translateX(-50%); }
.arrow-down { bottom: 6px; left: 50%; transform: translateX(-50%); }
.arrow-left { left: 6px; top: 50%; transform: translateY(-50%); }
.arrow-right { right: 6px; top: 50%; transform: translateY(-50%); }

.scroll-list {
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 8px;
}
.scroll-list li { padding: 4px 0; border-top: 1px solid #2c333b; }
.scroll-list li:first-child { border-top: none; }

.inline-form { display: flex; gap: 6px; margin-bottom: 8px; }
.inline-form input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 5px;
  border: 1px solid #3a4552;
  background: #14181c;
  color: #eee;
  font-size: 0.85em;
}
.inline-form button {
  padding: 6px 10px;
  border: none;
  border-radius: 5px;
  background: #f0c674;
  color: #1e242a;
  font-weight: bold;
  cursor: pointer;
  font-size: 0.8em;
  white-space: nowrap;
}

.market-form { flex-wrap: wrap; }
.market-form select { flex: 1 1 100%; padding: 6px; border-radius: 5px; border: 1px solid #3a4552; background: #14181c; color: #eee; font-size: 0.85em; }
.market-form input { flex: 1; }

.chat-line { font-size: 0.85em; }
.chat-author { color: #f0c674; font-weight: bold; }
.chat-time { color: #666; font-size: 0.75em; margin-left: 4px; }

.listing-line { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 0.85em; }
.listing-info { flex: 1; }
.listing-seller { color: #9aa4ae; font-size: 0.8em; }
.market-btn {
  padding: 4px 8px;
  border: none;
  border-radius: 5px;
  background: #7ec27e;
  color: #12181e;
  font-weight: bold;
  cursor: pointer;
  font-size: 0.78em;
  white-space: nowrap;
}
.market-btn.cancel { background: #e0574f; }

.suggestion-line { font-size: 0.85em; }
.suggestion-author { color: #57a0f0; font-weight: bold; }

/* Collapsible panels: the heading toggles its own panel. */
.panel h3 { cursor: pointer; user-select: none; }
.panel h3::before { content: '▾ '; color: #6b7580; }
.panel.collapsed h3::before { content: '▸ '; }
.panel.collapsed > *:not(h3) { display: none; }

#worldmap-canvas {
  background: #10141a;
  border-radius: 6px;
  display: block;
  width: 100%;
  max-width: 200px;
  height: auto;
  image-rendering: pixelated;
  margin: 0 auto;
}
#worldmap-hint { text-align: center; margin-top: 6px; }

#post-ul li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 0;
  border-top: 1px solid #2c333b;
  font-size: 0.85em;
}
#post-ul li:first-child { border-top: none; }

#clan-content { font-size: 0.85em; }
.clan-header { color: #f0c674; font-weight: bold; margin-bottom: 6px; }
.clan-sub { color: #9aa4ae; font-size: 0.9em; margin: 6px 0 4px; }
.clan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 3px 0;
}
.clan-tag { color: #7ec27e; font-weight: bold; }

#construction-ul li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 0;
  border-top: 1px solid #2c333b;
  font-size: 0.85em;
}
#construction-ul li:first-child { border-top: none; }
.build-btn {
  padding: 5px 10px;
  border: none;
  border-radius: 5px;
  background: #f0c674;
  color: #1e242a;
  font-weight: bold;
  cursor: pointer;
  font-size: 0.8em;
  white-space: nowrap;
}
.build-btn.armed { background: #e0574f; color: #fff; }

.building-actions { display: flex; gap: 8px; margin-top: 8px; }
#building-content { font-size: 0.85em; }
#building-content .storage-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border-top: 1px solid #2c333b;
}
#building-content .storage-row:first-child { border-top: none; }
#building-content textarea {
  width: 100%;
  min-height: 60px;
  padding: 6px;
  border-radius: 5px;
  border: 1px solid #3a4552;
  background: #14181c;
  color: #eee;
  font-family: inherit;
  font-size: 0.9em;
  resize: vertical;
}
.small-btn {
  padding: 3px 7px;
  border: none;
  border-radius: 4px;
  background: #57a0f0;
  color: #12181e;
  font-weight: bold;
  cursor: pointer;
  font-size: 0.78em;
}
