:root {
  color-scheme: light;
  font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
  color: #17301f;
  background: #a9d8e5;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  line-height: 1.5;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .7; }
button:focus-visible, input:focus-visible {
  outline: 3px solid #f8d777;
  outline-offset: 3px;
}

.forest-page {
  background:
    linear-gradient(180deg, #91cfe1 0 34%, #cde9b2 34% 53%, #4d7d3b 53% 100%);
  isolation: isolate;
  overflow-x: hidden;
}

.forest-page::before, .forest-page::after {
  content: "";
  position: fixed;
  z-index: -1;
  right: 0;
  bottom: 0;
  left: 0;
  pointer-events: none;
  image-rendering: pixelated;
  background-repeat: repeat-x;
  background-position: center bottom;
}

.forest-page::before {
  height: 320px;
  opacity: .62;
  background-image: url("/static/assets/forest-back-trees.png");
  background-size: 544px 320px;
}

.forest-page::after {
  height: 240px;
  opacity: .92;
  background-image: url("/static/assets/forest-front-trees.png");
  background-size: 408px 240px;
}

.dashboard-shell, .card {
  width: min(100% - 1.5rem, 72rem);
  margin: 0 auto;
}

.dashboard-shell { padding: 1.25rem 0 2.25rem; }

.masthead {
  margin: 0 .25rem 1rem;
  padding: 1.25rem;
  color: #fff9e7;
  text-shadow: 2px 2px 0 #17301f;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .35rem; font-size: clamp(1.65rem, 7vw, 2.7rem); letter-spacing: -.08em; line-height: 1.12; }
h2 { margin-bottom: 0; font-size: 1.05rem; line-height: 1.25; }
.eyebrow { margin-bottom: .3rem; color: #7a4d20; font-size: .7rem; font-weight: 900; letter-spacing: .09em; }
.masthead .eyebrow { color: #ffec9a; }
.subtitle { margin-bottom: 0; font-family: system-ui, sans-serif; font-size: .95rem; font-weight: 600; }

.status-panel, .players-panel, .operations-panel, .card, .confirm-dialog {
  border: 4px solid #29482a;
  border-radius: 0;
  box-shadow: 4px 4px 0 #19321d, inset 0 0 0 2px #f4d77d;
}

.status-panel, .players-panel, .operations-panel {
  margin: 0 .25rem 1rem;
  padding: 1.1rem;
  background: #fff8dc;
}

.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.section-heading.compact { align-items: center; }
.status-orb, .count-badge {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 3px solid #29482a;
  box-shadow: 2px 2px 0 #19321d;
}
.status-orb { background: #8f9b82; }
.status-panel[data-state="running"] .status-orb { background: #3d9b57; }
.status-panel[data-state="stopped"] .status-orb, .status-panel[data-state="error"] .status-orb { background: #c7593b; }
.status-panel[data-state="starting"] .status-orb { background: #e0aa3e; }
.count-badge { background: #f8d777; color: #17301f; font-weight: 900; }
.status-value { margin: 1rem 0 .2rem; color: #17301f; font-size: clamp(1.45rem, 6vw, 2rem); font-weight: 900; line-height: 1.15; }
.status-detail, .empty-state { margin-bottom: 0; color: #53664b; font-family: system-ui, sans-serif; font-size: .9rem; }
.server-address { margin-top: 1rem; padding-top: .9rem; border-top: 2px dashed #a07b43; }
.address-label { display: block; margin-bottom: .35rem; color: #68532f; font-size: .75rem; font-weight: 800; }
.address-button {
  width: 100%;
  min-height: 44px;
  padding: .65rem .75rem;
  overflow-wrap: anywhere;
  border: 3px solid #7d5c31;
  border-radius: 0;
  background: #f6e7b3;
  color: #382817;
  font-weight: 800;
  text-align: left;
  box-shadow: 2px 2px 0 #7d5c31;
}
.address-button:hover { background: #ffefb1; }

.players-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: .55rem; margin: 1rem 0 0; padding: 0; list-style: none; }
.players-list:empty { display: none; }
.player-chip { padding: .55rem .7rem; border: 2px solid #50763a; background: #e4f2c8; color: #244e2d; font-weight: 800; overflow-wrap: anywhere; }
.player-chip::before { content: "● "; color: #2f9356; }

.actions { display: grid; grid-template-columns: 1fr; gap: .7rem; margin-top: 1rem; }
.action-button, .secondary-button, .danger-button, .card button {
  min-height: 52px;
  padding: .7rem .8rem;
  border: 3px solid #29482a;
  border-radius: 0;
  color: #fffced;
  font-weight: 900;
  text-align: left;
  box-shadow: 3px 3px 0 #19321d;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.action-button:hover, .secondary-button:hover, .danger-button:hover, .card button:hover { filter: brightness(1.08); }
.action-button:active, .secondary-button:active, .danger-button:active, .card button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #19321d; }
.action-button span, .action-button small { display: block; }
.action-button small { margin-top: .15rem; color: #fff5c9; font-family: system-ui, sans-serif; font-size: .73rem; font-weight: 700; }
.action-button.start { background: #397b42; }
.action-button.stop { background: #9b4f33; }
.action-button.restart { background: #875f2a; }
.action-button.backup { background: #466c85; }
.message { min-height: 1.5rem; margin: 1rem 0 0; color: #8b2f25; font-family: system-ui, sans-serif; font-weight: 700; }
.message.success { color: #236a3c; }

.confirm-dialog {
  width: min(calc(100% - 2rem), 30rem);
  padding: 1.25rem;
  background: #fff8dc;
  color: #17301f;
}
.confirm-dialog::backdrop { background: #132d1aaa; }
.confirm-dialog h2 { margin-bottom: .75rem; font-size: 1.3rem; }
.dialog-actions { display: grid; grid-template-columns: 1fr; gap: .7rem; margin-top: 1.2rem; }
.secondary-button { background: #607963; }
.danger-button { background: #a54f35; }

.card {
  width: min(100% - 2rem, 29rem);
  margin-top: max(1rem, 12vh);
  padding: 1.25rem;
  background: #fff8dc;
  color: #17301f;
}
.card h1 { font-size: 1.8rem; }
.card label { display: block; color: #382817; font-weight: 900; }
.card input { width: 100%; min-height: 48px; margin: .45rem 0 1rem; padding: .7rem; border: 3px solid #7d5c31; border-radius: 0; background: #fffced; color: #17301f; }
.card button { width: 100%; background: #397b42; text-align: center; }

@media (min-width: 640px) {
  .dashboard-shell { padding-top: 2rem; }
  .masthead, .status-panel, .players-panel, .operations-panel { margin-right: 0; margin-left: 0; }
  .status-panel, .players-panel, .operations-panel { padding: 1.35rem; }
  .actions { grid-template-columns: repeat(2, 1fr); }
  .dialog-actions { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 920px) {
  .dashboard-shell { display: grid; grid-template-columns: 1.1fr .9fr; gap: 1rem; }
  .masthead, .operations-panel { grid-column: 1 / -1; }
  .status-panel, .players-panel { margin: 0; }
  .forest-page::before { height: 400px; background-size: 680px 400px; }
  .forest-page::after { height: 300px; background-size: 510px 300px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
