:root {
  --bg-top: #b8dcd5;
  --bg-mid: #95cbb9;
  --bg-bottom: #76ad99;
  --card: #f7f4e9;
  --card-2: #fff9ef;
  --text: #2a3d39;
  --muted: #5f7b73;
  --accent: #2d8670;
  --accent-soft: #65b199;
  --danger: #b95454;
  --shadow: 0 14px 28px rgba(16, 46, 40, 0.16);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-mid) 40%, var(--bg-bottom));
  overflow-x: hidden;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
  letter-spacing: 0.03em;
}

.sky-glow {
  position: fixed;
  inset: -15vh -10vw auto;
  height: 45vh;
  background: radial-gradient(circle at 20% 35%, rgba(255, 244, 199, 0.52), transparent 42%),
    radial-gradient(circle at 85% 22%, rgba(243, 255, 244, 0.4), transparent 38%);
  pointer-events: none;
  z-index: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 16px 24px;
}

.card {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(34, 74, 67, 0.13);
}

.topbar {
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
}

.day-panel {
  display: flex;
  gap: 14px;
}

.day-panel > div {
  background: rgba(104, 171, 151, 0.14);
  border-radius: 12px;
  padding: 8px 12px;
  min-width: 82px;
}

.label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: 320px 1fr 360px;
  gap: 14px;
}

.left-column,
.right-column {
  display: grid;
  gap: 12px;
  align-content: start;
}

.center-column {
  display: grid;
}

.card h2 {
  font-size: 1.1rem;
  margin-bottom: 10px;
}

.resource-card,
.worker-card,
.goal-card,
.task-card,
.build-card,
.assign-card,
.log-card,
.controls,
.island-card {
  padding: 14px;
}

.resource-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.resource-item {
  background: rgba(90, 148, 131, 0.14);
  border-radius: 12px;
  padding: 8px;
}

.resource-item .name {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.resource-item .amount {
  font-weight: 700;
  font-size: 1.1rem;
}

.worker-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.worker-stats div {
  border-radius: 10px;
  padding: 8px;
  background: rgba(57, 130, 111, 0.11);
}

.worker-stats .big {
  font-size: 1.15rem;
  font-weight: 700;
}

.goal-card p,
.task-card p,
.hint {
  margin: 0;
}

.goal-pill {
  background: rgba(126, 188, 165, 0.2);
  border-radius: 12px;
  padding: 10px;
}

.task-list {
  display: grid;
  gap: 8px;
}

.task-item {
  background: rgba(127, 173, 158, 0.16);
  border: 1px solid rgba(54, 103, 91, 0.14);
  border-radius: 12px;
  padding: 10px;
}

.task-item.complete {
  background: rgba(131, 202, 145, 0.25);
}

.progress-bar {
  margin-top: 8px;
  height: 6px;
  background: rgba(31, 62, 56, 0.16);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #5fb28f, #8fd0a4);
}

.island-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 6px;
  border-radius: 14px;
  background: rgba(56, 113, 101, 0.21);
  padding: 10px;
  min-height: 360px;
}

.tile {
  position: relative;
  border-radius: 9px;
  border: 1px solid rgba(43, 87, 77, 0.2);
  aspect-ratio: 1 / 1;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

.tile:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

.tile.grass {
  background: linear-gradient(160deg, #73ba79, #55985b);
}

.tile.sand {
  background: linear-gradient(160deg, #d7c38f, #c9af75);
}

.tile.rock {
  background: linear-gradient(160deg, #aeb8bb, #8f989c);
}

.tile.water {
  background: linear-gradient(160deg, #4a94b9, #2f708f);
  animation: wave 4s ease-in-out infinite;
  cursor: not-allowed;
}

.tile.locked {
  filter: grayscale(0.6) brightness(0.7);
}

.tile.selected::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 2px solid rgba(238, 249, 204, 0.9);
  border-radius: 11px;
}

.tile .building {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  text-shadow: 0 2px 1px rgba(0, 0, 0, 0.25);
}

.build-menu,
.assignment-list {
  display: grid;
  gap: 8px;
}

.build-option,
.assign-item {
  border-radius: 12px;
  border: 1px solid rgba(62, 104, 95, 0.2);
  background: rgba(108, 163, 146, 0.13);
  padding: 9px;
}

.build-option.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.build-option button {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.assign-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.assign-controls button {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  border: none;
  background: #4a8e7b;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  max-height: 190px;
  overflow: auto;
}

.log-list li {
  border-radius: 10px;
  padding: 8px;
  background: rgba(106, 161, 144, 0.14);
  font-size: 0.92rem;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

button {
  font-family: inherit;
}

.btn-primary,
.btn-alt,
.btn-danger {
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 100ms ease, filter 100ms ease;
}

.btn-primary:hover,
.btn-alt:hover,
.btn-danger:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.btn-primary {
  background: linear-gradient(180deg, #3f9d81, #2e7c66);
  color: #f8fffb;
}

.btn-alt {
  background: rgba(66, 126, 110, 0.16);
  color: var(--text);
}

.btn-danger {
  background: linear-gradient(180deg, #d87878, #ba5252);
  color: #fff;
}

.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(12, 35, 30, 0.42);
  z-index: 20;
}

.overlay.visible {
  display: grid;
}

.overlay-card {
  width: min(92vw, 430px);
  border-radius: 20px;
  padding: 24px;
  background: linear-gradient(170deg, #fffcf3, #ecf7ef);
  box-shadow: 0 24px 42px rgba(14, 37, 33, 0.34);
}

.overlay-actions {
  display: grid;
  gap: 8px;
  margin: 16px 0 8px;
}

.overlay-hint {
  color: var(--muted);
  font-size: 0.92rem;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: rgba(21, 67, 57, 0.9);
  color: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
  z-index: 30;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.resource-flyup {
  position: absolute;
  font-size: 0.82rem;
  font-weight: 700;
  color: #f7fff9;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
  animation: flyup 1000ms ease forwards;
  pointer-events: none;
}

@keyframes wave {
  0%,
  100% {
    filter: saturate(1);
  }
  50% {
    filter: saturate(1.14);
  }
}

@keyframes flyup {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(-24px);
    opacity: 0;
  }
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .center-column {
    order: -1;
  }

  .map-grid {
    min-height: 290px;
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .map-grid {
    gap: 4px;
    padding: 7px;
  }

  .tile .building {
    font-size: 0.95rem;
  }
}
