:root {
  color-scheme: dark;
  --bg: #08090b;
  --surface: rgba(15, 17, 21, 0.78);
  --surface-strong: rgba(20, 23, 28, 0.92);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #f4f1ea;
  --muted: #a8acb5;
  --accent: #e0443e;
  --accent-soft: rgba(224, 68, 62, 0.2);
  --ok: #63b995;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 16% 18%, rgba(224, 68, 62, 0.12), transparent 27%),
    linear-gradient(135deg, #08090b 0%, #131519 52%, #08090b 100%);
  color: var(--text);
  overflow-x: hidden;
}

body.has-modal {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.page {
  min-height: 100vh;
}

.map-stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
}

.admin-stage {
  padding-top: 92px;
  padding-bottom: 96px;
}

.map-frame {
  width: min(100%, calc((100vh - 48px) * 16 / 9));
  max-width: 1920px;
  aspect-ratio: 16 / 9;
  position: relative;
  border: 1px solid var(--line);
  background: #111318;
  overflow: hidden;
  box-shadow: var(--shadow);
  border-radius: 8px;
}

.admin-stage .map-frame {
  width: min(100%, calc((100vh - 196px) * 16 / 9));
}

.map-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}

.map-marker {
  width: clamp(23px, 2.6vw, 44px);
  height: clamp(23px, 2.6vw, 44px);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.55));
  transition: left 300ms ease, top 300ms ease, transform 180ms ease;
  pointer-events: none;
}

.admin-marker {
  width: clamp(24px, 2.5vw, 42px);
  height: clamp(24px, 2.5vw, 42px);
  border: 0;
  padding: 0;
  border-radius: 999px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: transparent url("/assets/marker.png") center / contain no-repeat;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.55));
  transition: left 120ms ease, top 120ms ease, transform 120ms ease;
  touch-action: none;
}

.admin-marker:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 4px;
}

.admin-marker.is-dirty {
  transform: translate(-50%, -50%) scale(1.06);
}

.timer-panel {
  position: absolute;
  z-index: 10;
  top: clamp(10px, 1.25vw, 22px);
  right: clamp(10px, 1.25vw, 22px);
  display: grid;
  gap: 2px;
  min-width: 164px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
}

.timer-value {
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  line-height: 1;
  font-weight: 750;
}

.timer-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.timer-panel.is-expired {
  border-color: rgba(224, 68, 62, 0.58);
  background: rgba(37, 15, 16, 0.88);
}

.sound-button {
  position: absolute;
  z-index: 10;
  left: clamp(10px, 1.25vw, 22px);
  top: clamp(10px, 1.25vw, 22px);
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 17, 21, 0.74);
  color: var(--muted);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.24);
  font-size: 13px;
  line-height: 1;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.sound-button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  color: var(--text);
}

.sound-button.is-active {
  color: var(--text);
  border-color: rgba(99, 185, 149, 0.5);
  background: rgba(25, 52, 43, 0.72);
}

.admin-header {
  position: fixed;
  z-index: 11;
  top: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 206px;
  max-width: calc(100vw - 40px);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  backdrop-filter: blur(18px);
}

.admin-header-actions {
  display: grid;
  gap: 10px;
  width: 100%;
}

.admin-header-actions .ghost-button {
  width: 100%;
}

.logout-form {
  margin: 0;
}

.admin-description-control {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.admin-title {
  display: grid;
  gap: 2px;
  width: 100%;
}

.admin-title strong {
  font-size: 16px;
  line-height: 1.1;
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.admin-actions {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: min(780px, calc(100vw - 40px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  backdrop-filter: blur(18px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
}

.admin-status {
  color: var(--muted);
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.success-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 18px;
  border: 1px solid transparent;
  color: var(--text);
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.primary-button {
  background: linear-gradient(135deg, #e0443e, #a92f2b);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 28px rgba(224, 68, 62, 0.25);
  font-weight: 700;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line);
}

.success-button {
  background: rgba(99, 185, 149, 0.16);
  border-color: rgba(99, 185, 149, 0.5);
}

.primary-button:hover,
.ghost-button:hover,
.success-button:hover {
  transform: translateY(-1px);
}

.primary-button:active,
.ghost-button:active,
.success-button:active {
  transform: translateY(0);
}

.primary-button:disabled,
.ghost-button:disabled,
.success-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(100%, 392px);
}

.login-card {
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.login-heading {
  display: grid;
  gap: 4px;
  margin-bottom: 4px;
}

.login-heading h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.field input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.field input:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.05);
}

.full-width {
  width: 100%;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(4, 5, 7, 0.72);
  backdrop-filter: blur(14px);
}

.modal-backdrop.is-open {
  display: grid;
}

.modal-card {
  width: min(100%, 560px);
  max-height: calc(100vh - 48px);
  display: grid;
  gap: 18px;
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 18, 23, 0.96);
  box-shadow: var(--shadow);
}

.event-modal-card {
  width: min(100%, 620px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.event-modal-card .markdown-body {
  overflow: auto;
  padding-right: 4px;
}

.editor-modal-card {
  width: min(100%, 980px);
}

.modal-heading {
  display: grid;
  gap: 6px;
}

.modal-heading h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.markdown-body {
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

.markdown-body > *:first-child {
  margin-top: 0;
}

.markdown-body > *:last-child {
  margin-bottom: 0;
}

.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 18px 0 8px;
  line-height: 1.18;
}

.markdown-body h2 {
  font-size: 22px;
}

.markdown-body h3 {
  font-size: 18px;
}

.markdown-body h4 {
  font-size: 16px;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote {
  margin: 0 0 12px;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 22px;
}

.markdown-body blockquote {
  padding: 10px 12px;
  border-left: 3px solid rgba(224, 68, 62, 0.72);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 0 8px 8px 0;
  color: #d6d8dd;
}

.markdown-body a {
  color: #f1746e;
  text-decoration: none;
  border-bottom: 1px solid rgba(241, 116, 110, 0.45);
}

.markdown-body code {
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.editor-toolbar button {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.editor-toolbar button:hover {
  border-color: var(--line-strong);
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.editor-field,
.editor-preview {
  display: grid;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.editor-field textarea {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 12px;
  outline: none;
  line-height: 1.45;
}

.editor-field textarea:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.05);
}

.editor-preview .markdown-body {
  min-height: 320px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 760px) {
  .map-stage {
    padding: 16px;
  }

  .admin-stage {
    padding-top: 124px;
    padding-bottom: 112px;
  }

  .timer-value {
    font-size: 24px;
  }

  .admin-header {
    top: 14px;
    left: 14px;
    width: 190px;
    max-width: calc(100vw - 28px);
    gap: 10px;
  }

  .admin-header-actions {
    gap: 6px;
  }

  .admin-actions {
    bottom: 14px;
    width: calc(100vw - 28px);
  }

  .admin-status {
    font-size: 13px;
  }

  .primary-button,
  .ghost-button,
  .success-button {
    padding: 0 13px;
  }
}

@media (max-width: 520px) {
  .admin-header {
    right: 14px;
  }

  .modal-backdrop {
    padding: 14px;
  }

  .modal-card {
    max-height: calc(100vh - 28px);
    padding: 18px;
  }

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

  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-controls {
    width: 100%;
  }

  .admin-status {
    white-space: normal;
  }

  .primary-button,
  .ghost-button,
  .success-button {
    flex: 1 1 100%;
    width: 100%;
  }
}
