:root {
  --bg: #07131f;
  --panel: #102033;
  --panel-soft: #152a40;
  --ink: #f4ead2;
  --muted: #afbbb8;
  --gold: #d5ad5c;
  --green: #62c79f;
  --danger: #e07777;
  --line: rgba(244, 234, 210, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(98, 199, 159, 0.13), transparent 28rem),
    linear-gradient(180deg, #07131f, #03080f);
  font-family: Arial, sans-serif;
}

a {
  color: var(--gold);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding: 1rem clamp(1rem, 4vw, 3rem);
  background: rgba(3, 8, 15, 0.76);
}

.brand {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.top-nav a,
.link-button {
  color: var(--gold);
  background: transparent;
  border: 0;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.user-pill,
.status-pill,
.joined-pill,
.muted-pill {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.joined-pill {
  color: var(--green);
}

.muted-pill {
  color: var(--muted);
}

.page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(1.2rem, 4vw, 3rem);
}

.flash {
  border: 1px solid rgba(213, 173, 92, 0.35);
  background: rgba(213, 173, 92, 0.12);
  color: var(--ink);
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
}

.auth-panel {
  max-width: 460px;
  margin: 8vh auto;
  border: 1px solid var(--line);
  background: rgba(16, 32, 51, 0.88);
  padding: clamp(1.4rem, 4vw, 2.2rem);
}

.eyebrow {
  margin: 0 0 0.65rem;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.1rem, 5vw, 4rem);
  line-height: 1;
}

h2 {
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.stack-form,
.create-card {
  display: grid;
  gap: 1rem;
}

.stack-form {
  margin-top: 1.5rem;
}

label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.25rem;
  background: #07131f;
  color: var(--ink);
  font: inherit;
  padding: 0.75rem 0.8rem;
}

.primary-button,
.secondary-button {
  border: 1px solid rgba(213, 173, 92, 0.72);
  border-radius: 0.25rem;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 0.78rem 1rem;
}

.primary-button {
  background: linear-gradient(135deg, #d0a34c, #f0d78c);
  color: #1a1208;
}

.secondary-button {
  background: rgba(98, 199, 159, 0.15);
  color: var(--ink);
}

.form-note {
  color: var(--muted);
}

.lobby-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: clamp(1.3rem, 4vw, 3rem);
  align-items: start;
  margin-bottom: 2rem;
}

.lobby-hero p {
  color: var(--muted);
  line-height: 1.6;
}

.create-card,
.game-card {
  border: 1px solid var(--line);
  background: rgba(16, 32, 51, 0.86);
  padding: 1.1rem;
}

.game-list h2 {
  margin-bottom: 1rem;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.game-card {
  display: grid;
  gap: 1rem;
}

.card-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.as-link {
  display: inline-flex;
  text-decoration: none;
}

.game-card h3 {
  margin-top: 0.8rem;
}

.game-card p,
.empty-state {
  color: var(--muted);
}

.game-shell {
  display: grid;
  gap: 1rem;
}

.game-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.resource-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.resource-strip span {
  border: 1px solid var(--line);
  background: rgba(16, 32, 51, 0.8);
  padding: 0.55rem 0.75rem;
}

.game-result {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid #d5ad5c;
  background: linear-gradient(90deg, rgba(213, 173, 92, 0.24), rgba(19, 40, 60, 0.92));
  color: #f4ead2;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1rem;
  align-items: stretch;
}

#game-map {
  width: 100%;
  height: min(74vh, 760px);
  min-height: 520px;
  border: 1px solid var(--line);
  background: #13283c;
  cursor: grab;
}

#game-map:active {
  cursor: grabbing;
}

.game-side-panel {
  border: 1px solid var(--line);
  background: rgba(16, 32, 51, 0.9);
  padding: 1rem;
}

.tile-details {
  color: var(--muted);
}

.tile-details dl {
  display: grid;
  gap: 0.55rem;
}

.tile-details dt {
  color: var(--gold);
  font-weight: 700;
}

.tile-details dd {
  margin: 0 0 0.45rem;
}

.marker-name {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0.35rem 0.25rem 0;
}

.icon-button {
  display: inline-grid;
  width: 1.75rem;
  height: 1.75rem;
  place-items: center;
  border: 1px solid rgba(213, 173, 92, 0.42);
  border-radius: 0.25rem;
  background: rgba(213, 173, 92, 0.12);
  color: var(--gold);
  cursor: pointer;
  font: inherit;
  line-height: 1;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: rgba(240, 215, 140, 0.82);
  background: rgba(213, 173, 92, 0.2);
}

.disabled-actions,
.build-actions,
.road-actions,
.prospect-actions,
.pending-actions,
.side-form {
  display: grid;
  gap: 0.5rem;
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.disabled-actions strong,
.build-actions strong,
.road-actions strong,
.prospect-actions strong,
.pending-actions strong {
  color: var(--gold);
}

.disabled-actions button,
.build-actions button,
.road-actions button,
.prospect-actions button,
.side-form button,
.panel-button {
  border: 1px solid var(--line);
  border-radius: 0.25rem;
  padding: 0.65rem;
}

.disabled-actions button {
  background: rgba(175, 187, 184, 0.08);
  color: rgba(175, 187, 184, 0.7);
}

.build-actions button,
.road-actions button,
.prospect-actions button,
.side-form button,
.panel-button {
  cursor: pointer;
  background: rgba(98, 199, 159, 0.15);
  color: var(--ink);
}

.hint,
.pending-actions span {
  color: var(--muted);
  line-height: 1.5;
}

.setup-modal {
  width: min(460px, calc(100vw - 2rem));
  border: 1px solid var(--line);
  background: rgba(16, 32, 51, 0.98);
  color: var(--ink);
  padding: 0;
}

.setup-modal::backdrop {
  background: rgba(3, 8, 15, 0.72);
}

.modal-card {
  position: relative;
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
}

.modal-card h2,
.modal-card p {
  margin: 0;
}

.modal-copy {
  color: var(--muted);
  line-height: 1.55;
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

@media (max-width: 720px) {
  .app-header,
  .lobby-hero,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .game-toolbar {
    align-items: start;
    flex-direction: column;
  }

  #game-map {
    min-height: 420px;
  }
}
