@font-face {
  font-family: "Majesty";
  src: url("/assets/fonts/majesty-bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "CalibriWeb";
  src: url("/assets/fonts/calibri.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #050608;
  --surface: #131519;
  --surface-strong: #17191f;
  --line: #2a2e36;
  --text: #f2f3f5;
  --muted: #a7abb3;
  --accent: #35d6f4;
  --accent-text: #0b0c0f;
  --danger: #ff6b63;
  --warning: #ffd166;
  --radius: 14px;
  --radius-large: 24px;
  --font-display: "Majesty", Georgia, "Times New Roman", serif;
  --font-body: "CalibriWeb", "Segoe UI", Arial, sans-serif;
  font-family: var(--font-body);
}

* { box-sizing: border-box; }

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.admin-layout {
  display: grid;
  min-height: 100dvh;
  grid-template-columns: 252px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100dvh;
  flex-direction: column;
  padding: 28px 18px 20px;
  border-right: 1px solid var(--line);
  background: #080a0d;
}

.sidebar-logo {
  width: 172px;
  height: auto;
  margin: 4px 10px 42px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-button {
  display: flex;
  width: 100%;
  min-height: 50px;
  align-items: center;
  gap: 13px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.nav-button:hover,
.nav-button.active {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.nav-button.active .icon { color: var(--accent); }

.sidebar-user {
  margin-top: auto;
  padding: 18px 12px 0;
  border-top: 1px solid var(--line);
}

.sidebar-user strong,
.sidebar-user span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user strong { font-size: 14px; }
.sidebar-user span { margin-top: 4px; color: var(--muted); font-size: 12px; }

.logout-button {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.admin-main {
  min-width: 0;
  padding: 42px clamp(26px, 5vw, 76px) 70px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 40px;
}

.page-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(38px, 4.7vw, 60px);
  font-weight: 700;
  letter-spacing: .015em;
  line-height: .95;
  text-transform: uppercase;
}

.page-copy {
  max-width: 58ch;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.button,
.icon-action {
  border-radius: 12px;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

.button:active,
.icon-action:active { transform: scale(.98); }

.button {
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 20px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.button.danger {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
  background: transparent;
  color: var(--danger);
}

.button.small {
  min-height: 40px;
  padding: 0 14px;
  font-size: 14px;
}

.button:disabled {
  cursor: not-allowed;
  filter: grayscale(.7);
  opacity: .55;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  overflow: hidden;
}

.metric-block {
  min-height: 150px;
  padding: 26px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.metric-block:last-child { border-right: 0; }
.metric-block:first-child { background: var(--accent); color: var(--accent-text); }

.metric-value {
  display: block;
  margin-top: 25px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(34px, 4vw, 54px);
  font-weight: 850;
  letter-spacing: -.06em;
}

.metric-label {
  color: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.section-block { margin-top: 48px; }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.live-winners-section {
  padding: clamp(22px, 3vw, 32px);
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  background: linear-gradient(160deg, #17191f 0%, #101216 78%);
}

.live-update {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.live-update.is-offline { color: var(--danger); }

.winner-list {
  display: grid;
  max-height: 440px;
  padding-right: 8px;
  overflow-y: auto;
  scrollbar-color: var(--line) transparent;
}

.winner-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.winner-row:first-child { padding-top: 4px; }
.winner-row:last-child { padding-bottom: 0; border-bottom: 0; }

.winner-row.is-new {
  animation: winner-arrives .6s cubic-bezier(.16, 1, .3, 1) both;
}

.winner-main {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.winner-main strong {
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.winner-main > span:last-child {
  color: var(--muted);
  font-size: 13px;
}

.winner-prize {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.winner-code {
  display: grid;
  min-width: 138px;
  gap: 4px;
  text-align: right;
}

.winner-code span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.winner-code strong {
  color: var(--text);
  font: 700 19px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .035em;
}

.winner-empty {
  display: flex;
  min-height: 112px;
  align-items: center;
  gap: 18px;
  color: var(--accent);
}

.winner-empty div { display: grid; gap: 4px; }
.winner-empty strong { color: var(--text); font-size: 16px; }
.winner-empty span { color: var(--muted); font-size: 14px; }

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  background: var(--surface);
  overflow: hidden;
}

.data-table th,
.data-table td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: 0; }

.data-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.data-table td { font-size: 14px; }

.table-primary {
  display: grid;
  gap: 4px;
}

.table-primary strong { font-size: 15px; }
.table-primary span { color: var(--muted); font-size: 12px; }

.status-badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-badge.published,
.status-badge.ready {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  color: var(--accent);
}

.status-badge.closed { color: var(--warning); }

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.icon-action {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}

.icon-action:hover { background: var(--surface-strong); color: var(--text); }

.empty-state {
  display: grid;
  min-height: 260px;
  place-items: center;
  padding: 36px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-large);
  color: var(--muted);
  text-align: center;
}

.empty-state .icon { width: 54px; height: 54px; margin-bottom: 14px; }
.empty-state h3 { margin: 0 0 8px; color: var(--text); font-family: var(--font-display); font-size: 22px; letter-spacing: .04em; text-transform: uppercase; }
.empty-state p { max-width: 42ch; margin: 0 0 22px; line-height: 1.5; }

.form-shell {
  display: grid;
  gap: 34px;
}

.form-section {
  padding: clamp(22px, 3vw, 34px);
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  background: var(--surface);
}

.form-section h2 {
  margin: 0 0 24px;
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.field {
  display: grid;
  align-content: start;
  gap: 8px;
}

.field.full { grid-column: 1 / -1; }

.field label,
.field-label {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.field-help {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--text);
}

.textarea {
  min-height: 112px;
  padding-top: 13px;
  padding-bottom: 13px;
  resize: vertical;
  line-height: 1.5;
}

.input::placeholder,
.textarea::placeholder { color: #7c818a; }

.input:hover,
.select:hover,
.textarea:hover { border-color: #454b56; }

.input[type="color"] {
  padding: 7px;
  cursor: pointer;
}

.check-group {
  display: flex;
  min-height: 50px;
  align-items: center;
  gap: 18px;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 14px;
}

.check-label input { width: 18px; height: 18px; accent-color: var(--accent); }

.form-actions {
  position: sticky;
  bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  background: rgba(5, 6, 8, .92);
  backdrop-filter: blur(16px);
}

.event-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, .7fr);
  gap: 18px;
}

.event-summary,
.device-panel {
  min-height: 190px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  background: var(--surface);
}

.event-summary h1 { margin: 18px 0 8px; font-family: var(--font-display); font-size: clamp(34px, 5vw, 58px); letter-spacing: .015em; line-height: .95; text-transform: uppercase; }
.event-summary p { margin: 0; color: var(--muted); }
.device-panel { display: flex; flex-direction: column; justify-content: space-between; }
.device-panel p { margin: 8px 0 18px; color: var(--muted); font-size: 14px; line-height: 1.5; }

.device-security {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.link-result {
  display: grid;
  gap: 18px;
}

.link-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.link-box {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #080a0d;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  user-select: text;
}

.access-password-box {
  width: 100%;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--line));
  border-radius: 10px;
  background: #080a0d;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(24px, 5vw, 38px);
  font-weight: 850;
  letter-spacing: .08em;
  text-align: center;
  user-select: text;
}

.link-copy-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.prize-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.prize-item {
  display: grid;
  min-height: 128px;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  background: var(--surface);
}

.prize-visual {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 12px;
  background: var(--surface-strong);
  color: var(--accent);
  overflow: hidden;
}

.prize-visual img { width: 80%; height: 80%; object-fit: contain; }
.prize-item h3 { margin: 0; font-size: 17px; }
.prize-item p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.prize-count { font: 850 28px/1 ui-monospace, monospace; }

.app-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  background: var(--surface);
  color: var(--text);
  overflow: auto;
}

.app-dialog::backdrop { background: rgba(5, 6, 7, .78); backdrop-filter: blur(6px); }

.dialog-body { padding: 28px; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.dialog-header h2 { margin: 0; font-family: var(--font-display); font-size: 27px; letter-spacing: .04em; text-transform: uppercase; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; }

.toast-region {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  display: grid;
  width: min(390px, calc(100vw - 48px));
  gap: 10px;
}

.toast {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #17191f;
  color: var(--text);
  box-shadow: 0 18px 45px rgba(5, 6, 8, .38);
  animation: toast-in .3s cubic-bezier(.16, 1, .3, 1) both;
}

.toast.error { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }

.login-page {
  display: grid;
  min-height: 100dvh;
  grid-template-columns: minmax(0, 1.2fr) minmax(380px, .8fr);
}

.login-brand {
  position: relative;
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(36px, 6vw, 84px);
  background: var(--bg);
  overflow: hidden;
}

.login-brand img { width: min(230px, 46vw); }
.login-brand h1 { max-width: 8ch; margin: 0; font-family: var(--font-display); font-size: clamp(62px, 8vw, 122px); letter-spacing: .01em; line-height: .86; }
.login-brand p { max-width: 36ch; margin: 24px 0 0; color: var(--muted); font-size: 18px; line-height: 1.45; }

.login-panel {
  display: grid;
  min-height: 100dvh;
  align-content: center;
  padding: clamp(34px, 6vw, 84px);
  border-left: 1px solid var(--line);
  background: var(--surface);
}

.login-panel h2 { margin: 0 0 10px; font-family: var(--font-display); font-size: 36px; letter-spacing: .04em; text-transform: uppercase; }
.login-panel > p { margin: 0 0 34px; color: var(--muted); line-height: 1.5; }
.login-form { display: grid; gap: 20px; }
.login-form .button { width: 100%; margin-top: 6px; }
.inline-error { margin: 0; color: var(--danger); font-size: 14px; line-height: 1.5; }

.admin-loading {
  display: grid;
  min-height: 100dvh;
  place-content: center;
  gap: 28px;
}

.admin-loading img { width: 190px; }
.admin-skeleton { width: 280px; height: 120px; border-radius: var(--radius); background: var(--surface); animation: pulse 1s ease-in-out infinite alternate; }

@keyframes pulse { to { opacity: .45; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes winner-arrives {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 980px) {
  .admin-layout { grid-template-columns: 82px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .sidebar-logo { width: 48px; height: 34px; object-fit: cover; object-position: left; margin-inline: 5px; }
  .nav-button { justify-content: center; padding: 0; }
  .nav-button span,
  .sidebar-user strong,
  .sidebar-user span,
  .logout-button span { display: none; }
  .logout-button { justify-content: center; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-block:nth-child(2) { border-right: 0; }
  .metric-block:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .event-hero { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .admin-layout { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 18px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-logo { width: 142px; height: auto; margin: 0 0 18px; object-fit: contain; }
  .nav-list { grid-template-columns: repeat(3, 1fr); }
  .nav-button { min-height: 46px; }
  .nav-button span { display: none; }
  .sidebar-user { display: none; }
  .admin-main { padding: 28px 18px 60px; }
  .page-header { display: grid; margin-bottom: 28px; }
  .page-header .button { width: 100%; }
  .metric-grid,
  .form-grid,
  .form-grid.three,
  .prize-grid { grid-template-columns: 1fr; }
  .metric-block { min-height: 116px; border-right: 0; border-bottom: 1px solid var(--line); }
  .metric-block:last-child { border-bottom: 0; }
  .data-table { display: block; overflow-x: auto; }
  .form-actions { position: static; display: grid; }
  .form-actions .button { width: 100%; }
  .login-page { grid-template-columns: 1fr; }
  .login-brand { min-height: 44dvh; padding: 34px 24px; }
  .login-brand h1 { font-size: 62px; }
  .login-panel { min-height: 56dvh; padding: 36px 24px; border-top: 1px solid var(--line); border-left: 0; }
  .winner-row { grid-template-columns: 1fr; gap: 10px; }
  .winner-code { min-width: 0; text-align: left; }
  .live-winners-section .section-heading { align-items: flex-start; flex-direction: column; }
  .link-copy-actions { grid-template-columns: 1fr; }
}

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