:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #121a26;
  --border: #2d3a4f;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --primary: #5b8def;
  --primary-hover: #7aa3f5;
  --secondary: #3d8f6e;
  --secondary-hover: #4cad84;
  --error: #f07178;
  --success: #6bcf8e;
  --pwn-accent: #ff6b35;
  --pwn-accent-2: #f72585;
  --server-accent: #4cc9f0;
  --radius: 10px;
  --font: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.page-header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.env-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.2em 0.5em;
  border-radius: 4px;
  background: #2d6a4f;
  color: #d8f3dc;
}

.subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

.subtitle code,
.hint code,
.tech-line code,
.zone-status dd {
  font-family: var(--mono);
}

.subtitle code,
.tech-line code {
  font-size: 0.85em;
  background: var(--bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-top: 1.25rem;
}

.card h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.config-grid {
  display: grid;
  gap: 0.85rem;
}

label {
  display: block;
  font-size: 0.9rem;
}

input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

button {
  font-family: inherit;
  font-size: 0.95rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.1s ease;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
}

button.ghost:hover {
  color: var(--text);
  border-color: var(--muted);
}

.btn-reset {
  flex-shrink: 0;
  margin-top: 0.25rem;
}

/* Zones */
.zone {
  position: relative;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.zone-pwn {
  border-color: #4a3550;
  background: linear-gradient(180deg, #1e2438 0%, var(--surface) 100%);
}

.zone-studio {
  border-color: #2a4555;
  background: linear-gradient(180deg, #152028 0%, var(--surface) 100%);
}

.zone-state-loading {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(91, 141, 239, 0.35);
}

.zone-state-success {
  border-color: var(--success);
  box-shadow: 0 0 0 1px rgba(107, 207, 142, 0.35);
}

.zone-state-error {
  border-color: var(--error);
  box-shadow: 0 0 0 1px rgba(240, 113, 120, 0.35);
}

.zone-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.zone-title {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.zone-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.zone-icon-pwn {
  background: linear-gradient(135deg, var(--pwn-accent), var(--pwn-accent-2));
  color: #fff;
}

.zone-icon-server {
  background: #1a3a4a;
  color: var(--server-accent);
  border: 1px solid #2d5a6e;
}

.zone-sub {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.phase-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.35em 0.6em;
  border-radius: 999px;
  flex-shrink: 0;
}

.phase-pre {
  background: rgba(255, 107, 53, 0.15);
  color: #ffb088;
  border: 1px solid rgba(255, 107, 53, 0.35);
}

.phase-post {
  background: rgba(76, 201, 240, 0.12);
  color: #8ee4f8;
  border: 1px solid rgba(76, 201, 240, 0.3);
}

.zone-hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}

.tech-line {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Ad banner */
.ad-banner {
  display: block;
  width: 100%;
  max-width: 728px;
  margin: 0 auto;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  background: linear-gradient(
    135deg,
    #1a1030 0%,
    #2d1b4e 40%,
    #1a2a4a 100%
  );
  color: #fff;
  text-align: left;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  min-height: 90px;
  transition:
    transform 0.12s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.ad-banner:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  border-color: rgba(255, 107, 53, 0.5);
}

.ad-banner:focus-visible {
  outline: 2px solid var(--pwn-accent);
  outline-offset: 3px;
}

.ad-banner:active:not(:disabled) {
  transform: translateY(0);
}

.zone-state-loading .ad-banner {
  pointer-events: none;
  opacity: 0.85;
}

.ad-sim-label {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  background: rgba(0, 0, 0, 0.35);
  padding: 0.15em 0.45em;
  border-radius: 4px;
}

.ad-brand {
  position: absolute;
  top: 8px;
  left: 10px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--pwn-accent);
  background: rgba(0, 0, 0, 0.4);
  padding: 0.2em 0.45em;
  border-radius: 4px;
}

.ad-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1rem 1rem;
}

.ad-art {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  background: linear-gradient(145deg, #ff6b35, #7209b7);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3);
}

.ad-art-icon {
  font-size: 1.5rem;
  opacity: 0.9;
}

.ad-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.ad-sponsored {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.55);
}

.ad-title {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
}

.ad-tagline {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
}

.ad-cta {
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--pwn-accent), #e63946);
  padding: 0.55em 1em;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

@media (max-width: 560px) {
  .ad-content {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .ad-cta {
    width: 100%;
    text-align: center;
  }

  .ad-title {
    font-size: 1rem;
  }
}

/* Flow connector */
.flow-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0.5rem 0;
  gap: 0.25rem;
}

.flow-line {
  width: 2px;
  height: 20px;
  background: linear-gradient(180deg, var(--pwn-accent), var(--server-accent));
  opacity: 0.6;
}

.flow-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

.flow-arrow {
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
}

/* Server panel */
.server-panel {
  border: 1px solid #2d4a5c;
  border-radius: 8px;
  background: var(--surface-2);
  overflow: hidden;
}

.server-chrome {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  background: #0d1520;
  border-bottom: 1px solid #2d4a5c;
}

.server-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.server-dot.red {
  background: #ff5f57;
}

.server-dot.yellow {
  background: #febc2e;
}

.server-dot.green {
  background: #28c840;
}

.server-host {
  margin-left: 0.5rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--server-accent);
}

.server-body {
  padding: 0.85rem 1rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.6;
}

.terminal-line {
  margin-bottom: 0.35rem;
}

.terminal-line.muted {
  color: var(--muted);
}

.terminal-line.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.chip {
  display: inline-block;
  padding: 0.15em 0.5em;
  border-radius: 4px;
  background: #1a3040;
  border: 1px solid #2d5a6e;
  color: #a8d8ea;
  font-size: 0.72rem;
}

.btn-server {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #1a4a5e, #2d6a8a);
  color: #e8f4f8;
  border: 1px solid #3d7a9a;
  font-weight: 600;
}

.btn-server:hover:not(:disabled) {
  background: linear-gradient(135deg, #235a72, #3a7fa0);
  border-color: var(--server-accent);
}

.btn-server:focus-visible {
  outline: 2px solid var(--server-accent);
  outline-offset: 2px;
}

/* Zone status */
.zone-status {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.zone-status dl {
  margin: 0;
}

.zone-status dt {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.5rem;
}

.zone-status dt:first-child {
  margin-top: 0;
}

.zone-status dd {
  margin: 0.1rem 0 0;
  font-size: 0.8rem;
  word-break: break-all;
}

/* Global status */
.status h2 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.75rem;
}

dl {
  margin: 0;
}

dt {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.65rem;
}

dt:first-child {
  margin-top: 0;
}

dd {
  margin: 0.15rem 0 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  word-break: break-all;
}

dd.error {
  color: var(--error);
}

.log {
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.75rem;
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
}

footer {
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

footer code {
  font-family: var(--mono);
  font-size: 0.85em;
}
