:root {
  --ink: #24190f;
  --muted: #6d5d4b;
  --paper: #fff8e9;
  --panel: #f8ecd3;
  --line: #d5b98b;
  --leaf: #2f6948;
  --leaf-dark: #19442f;
  --ember: #ba4d2d;
  --gold: #efb84f;
  --sky: #d5eef0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 248, 233, 0.92), rgba(255, 248, 233, 0.9)),
    radial-gradient(circle at 25% 10%, #ffd37a 0, transparent 28%),
    linear-gradient(140deg, #cce6d4, #f6d9a8 52%, #b9d6d2);
  font-family: Georgia, "Times New Roman", serif;
}

a {
  color: var(--leaf-dark);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 42px);
  background: rgba(255, 248, 233, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.brand {
  font-size: 1.35rem;
  font-weight: 700;
  text-decoration: none;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

nav a {
  text-decoration: none;
  font-weight: 700;
}

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 96px;
}

.hero,
.village-hero,
.game-hero {
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(26px, 6vw, 58px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 248, 233, 0.94), rgba(255, 248, 233, 0.58)),
    radial-gradient(circle at 78% 35%, rgba(239, 184, 79, 0.65), transparent 18%),
    linear-gradient(135deg, #7ea66d, #e7b85c 55%, #79523a);
}

.hero h1,
.village-hero h1,
.game-hero h1 {
  margin: 0;
  font-size: clamp(2.4rem, 7vw, 5.4rem);
  letter-spacing: 0;
}

.hero p,
.village-hero p,
.game-hero p {
  max-width: 590px;
  font-size: 1.15rem;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--ember);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.actions,
.resource-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.resource-tile {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 4px 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.9);
}

.resource-tile strong {
  grid-column: 2;
  font-size: 1.25rem;
}

.resource-icon {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--leaf);
  color: white;
  font: 700 0.9rem system-ui, sans-serif;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 18px;
}

.village-map {
  min-height: 430px;
}

.camp-scene {
  position: relative;
  min-height: 330px;
  overflow: hidden;
  border: 1px solid #dfc89e;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 58%, rgba(239, 184, 79, 0.35), transparent 20%),
    linear-gradient(180deg, #cfe2b7, #b7d197);
}

.campfire,
.hut,
.patch,
.villager {
  position: absolute;
}

.campfire {
  left: 48%;
  top: 52%;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffd36a 0 28%, #c6532d 29% 52%, #6b3f2a 53%);
}

.hut {
  width: 92px;
  height: 70px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(145deg, #8b5e38, #d2a060);
}

.hut::before {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: -34px;
  height: 48px;
  background: #6f4b32;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.hut-a {
  left: 16%;
  top: 32%;
}

.hut-b {
  right: 16%;
  top: 42%;
}

.patch {
  left: 14%;
  bottom: 14%;
  width: 126px;
  height: 62px;
  border-radius: 50%;
  background: repeating-radial-gradient(circle, #f1e0a6 0 8px, #9d6d56 9px 14px);
}

.villager {
  width: 24px;
  height: 34px;
  border-radius: 50% 50% 42% 42%;
  background: #5b8f4d;
  border: 2px solid #244226;
}

.v1 { left: 43%; top: 42%; }
.v2 { left: 58%; top: 48%; }
.v3 { left: 38%; top: 62%; }

.population-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  padding: 12px;
  border-radius: 8px;
  background: #fffaf0;
}

.needs-list {
  padding-left: 20px;
}

.button,
button {
  min-height: 40px;
  border: 1px solid var(--leaf-dark);
  border-radius: 6px;
  padding: 8px 13px;
  background: #fffaf0;
  color: var(--leaf-dark);
  font: 700 0.95rem system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
}

.button.primary,
button.primary {
  background: var(--leaf);
  color: white;
}

.button.danger {
  border-color: #8f2d22;
  color: #8f2d22;
}

.panel {
  margin-top: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 248, 233, 0.86);
}

.panel.narrow {
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 18px;
}

.resource-bar {
  position: sticky;
  top: 58px;
  z-index: 4;
  margin: 16px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 236, 211, 0.96);
}

.resource-bar span {
  padding: 8px 10px;
  border-radius: 6px;
  background: #fffaf0;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.card,
.gift,
.chat-message {
  border: 1px solid #dfc89e;
  border-radius: 8px;
  padding: 14px;
  background: #fffaf0;
}

.chat-message {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px 10px;
}

.card h3 {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px;
}

.chat-feed {
  height: 360px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px;
  border: 1px solid #dfc89e;
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.72);
}

.chat-feed.compact {
  height: calc(100vh - 170px);
}

.chat-message > div:not(.chat-avatar) {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
}

.chat-message p {
  grid-column: 2;
  margin: 7px 0;
}

.chat-message .link-button {
  grid-column: 2;
  justify-self: start;
}

.chat-avatar,
.profile-preview {
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #dfc89e;
  border-radius: 50%;
  background: #f8ecd3;
}

.chat-avatar {
  width: 44px;
  height: 44px;
  grid-row: span 3;
}

.chat-avatar-img,
.profile-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-avatar-fallback,
.profile-preview span {
  color: var(--leaf-dark);
  font-weight: 700;
  font-family: system-ui, sans-serif;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 10px;
}

.chat-peek {
  position: fixed;
  left: 18px;
  right: 18px;
  bottom: 14px;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 54px;
  text-align: left;
  box-shadow: 0 10px 30px rgba(36, 25, 15, 0.2);
}

.chat-peek span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-dock {
  position: fixed;
  top: 58px;
  right: 0;
  bottom: 0;
  z-index: 30;
  width: min(420px, 100vw);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px;
  border-left: 1px solid var(--line);
  background: rgba(255, 248, 233, 0.98);
  transform: translateX(100%);
  transition: transform 180ms ease;
  box-shadow: -12px 0 30px rgba(36, 25, 15, 0.16);
}

.chat-open .chat-dock {
  transform: translateX(0);
}

.chat-dock-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.chat-dock-header h2 {
  margin: 0;
}

.stack {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 5px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fffaf0;
  color: var(--ink);
  font: 1rem system-ui, sans-serif;
}

.profile-form {
  width: min(420px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px auto;
  gap: 8px;
}

.profile-card {
  width: min(520px, 100%);
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.profile-preview {
  width: 72px;
  height: 72px;
}

.profile-preview.large {
  width: 96px;
  height: 96px;
}

.profile-picture-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.profile-form,
.avatar-upload-form,
.custom-avatar-note {
  grid-column: 2;
}

.avatar-upload-form {
  display: grid;
  gap: 8px;
}

.objectives {
  list-style: none;
  padding: 0;
  margin: 0;
}

.online-list {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.online-player {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid #dfc89e;
  border-radius: 8px;
  background: #fffaf0;
}

.online-player span,
.online-player small,
.muted {
  color: var(--muted);
}

.presence {
  width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: 700 0.78rem system-ui, sans-serif;
}

.presence::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.presence.online {
  color: var(--leaf-dark);
}

.presence.online::before {
  background: #2f9e44;
}

.presence.offline {
  color: var(--muted);
}

.objectives li {
  margin: 7px 0;
  padding: 9px 10px;
  border-radius: 6px;
  background: #fffaf0;
}

.objectives li.done {
  color: white;
  background: var(--leaf);
}

.link-button {
  min-height: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ember);
  text-decoration: underline;
}

.error {
  padding: 10px;
  border: 1px solid #b54630;
  border-radius: 6px;
  background: #ffe8df;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--leaf-dark);
  color: white;
  box-shadow: 0 10px 30px rgba(36, 25, 15, 0.22);
}

.toast.inline {
  position: static;
  display: inline-block;
  margin: 12px 0 0;
}

.account-header {
  display: flex;
  gap: 16px;
  align-items: center;
}

.big-number {
  margin: 0;
  font-size: 3rem;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.muted-row {
  opacity: 0.55;
}

@media (max-width: 760px) {
  .topbar,
  .village-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .profile-card,
  .profile-picture-row,
  .profile-form,
  .chat-form {
    grid-template-columns: 1fr;
  }

  .profile-form,
  .avatar-upload-form,
  .custom-avatar-note {
    grid-column: 1;
  }

  .resource-bar {
    position: static;
  }
}
