:root {
  --ink: #172039;
  --muted: #687188;
  --line: #e4e7ee;
  --panel: #ffffff;
  --pink: #e51b83;
  --pink-dark: #b80b63;
  --pink-soft: #fff0f8;
  --violet: #6655d9;
  --green: #087e64;
  --green-soft: #eafaf5;
  --amber: #9c6104;
  --amber-soft: #fff7e6;
  --red: #b32842;
  --red-soft: #fff0f2;
  --shadow: 0 24px 70px rgba(31, 32, 61, .13);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #f5f3f8; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(250, 207, 230, .72), transparent 29rem),
    radial-gradient(circle at 88% 24%, rgba(205, 218, 255, .72), transparent 30rem),
    linear-gradient(145deg, #fbf9fc, #f0f3fa);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Thai", sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 56px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 28px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: grid; width: 46px; height: 46px; place-items: center; color: #fff; background: linear-gradient(135deg, var(--pink), var(--violet)); border-radius: 15px; box-shadow: 0 10px 25px rgba(196, 34, 132, .22); font-size: 21px; }
.brand-logo { width: 52px; height: 52px; padding: 3px; object-fit: contain; object-position: center; background: #fff; border: 2px solid rgba(255,255,255,.92); border-radius: 17px; box-shadow: 0 10px 25px rgba(196,34,132,.18); }
.brand-copy { min-width: 0; }
.brand strong { display: block; font-size: 16px; }
.brand span { color: var(--muted); font-size: 11px; letter-spacing: .04em; }
.ghost-link, .ghost-button { padding: 10px 13px; color: #545d73; text-decoration: none; background: rgba(255,255,255,.82); border: 1px solid var(--line); border-radius: 11px; font-weight: 750; }
.ghost-button { border: 1px solid var(--line); }

.live-service-badge { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; color: #5a426d; background: rgba(255,255,255,.82); border: 1px solid rgba(221,213,229,.92); border-radius: 999px; box-shadow: 0 7px 24px rgba(62,44,78,.06); font-size: 11px; font-weight: 850; }
.live-service-badge i { width: 8px; height: 8px; background: #15a47d; border-radius: 50%; box-shadow: 0 0 0 5px rgba(21,164,125,.11); }
.login-layout { display: grid; min-height: calc(100vh - 150px); place-items: center; }
.access-card { position: relative; width: min(570px, 100%); overflow: hidden; background: rgba(255,255,255,.96); border: 1px solid rgba(255,255,255,.94); border-radius: 32px; box-shadow: 0 32px 90px rgba(31,32,61,.16); }
.access-card::after { content: ""; position: absolute; z-index: 0; right: -90px; bottom: 95px; width: 190px; height: 190px; pointer-events: none; background: radial-gradient(circle, rgba(229,27,131,.08), transparent 68%); }
.access-hero { position: relative; z-index: 1; overflow: hidden; padding: 30px 34px 32px; color: #fff; background: linear-gradient(135deg, #172651 0%, #4d3699 50%, #d41479 100%); }
.access-hero::before { content: ""; position: absolute; top: -105px; right: -75px; width: 260px; height: 260px; background: radial-gradient(circle, rgba(255,255,255,.22), transparent 68%); border-radius: 50%; }
.access-hero::after { content: ""; position: absolute; right: 26px; bottom: -72px; width: 180px; height: 180px; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; box-shadow: 0 0 0 28px rgba(255,255,255,.035), 0 0 0 56px rgba(255,255,255,.025); }
.hero-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 11px; margin-bottom: 24px; }
.hero-logo-wrap { display: grid; width: 54px; height: 54px; overflow: hidden; place-items: center; background: #fff; border: 2px solid rgba(255,255,255,.86); border-radius: 17px; box-shadow: 0 12px 30px rgba(14,12,43,.24); }
.hero-logo-wrap img { width: 100%; height: 100%; padding: 3px; object-fit: contain; }
.hero-brand strong, .hero-brand span { display: block; }
.hero-brand strong { font-size: 16px; letter-spacing: .01em; }
.hero-brand span { margin-top: 2px; color: rgba(255,255,255,.68); font-size: 9px; font-weight: 850; letter-spacing: .16em; }
.eyebrow { margin: 0 0 10px; font-size: 11px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; opacity: .82; }
.access-hero h1 { position: relative; z-index: 1; margin: 0; font-size: clamp(30px, 6vw, 44px); line-height: 1.1; letter-spacing: -.025em; }
.access-hero p { position: relative; z-index: 1; margin: 15px 0 0; max-width: 455px; color: rgba(255,255,255,.82); line-height: 1.7; }
.access-body { position: relative; z-index: 1; padding: 29px 34px 34px; }
.event-box { margin-bottom: 20px; padding: 18px; background: linear-gradient(145deg, #fafbff, #f6f5fb); border: 1px solid #e3e3ed; border-radius: 18px; box-shadow: inset 0 1px 0 rgba(255,255,255,.85); }
.event-box .state { display: inline-flex; margin-bottom: 8px; padding: 5px 9px; color: var(--green); background: var(--green-soft); border-radius: 999px; font-size: 11px; font-weight: 850; }
.event-box h2 { margin: 0; font-size: 18px; }
.event-box p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
label { display: block; margin-bottom: 7px; color: #4e566b; font-size: 12px; font-weight: 800; }
.code-label { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.code-label small { color: #9398a8; font-size: 9px; font-weight: 650; }
.top-gap { margin-top: 13px; }
.panel-spaced { margin-top: 18px; }
input, select {
  width: 100%; min-height: 48px; padding: 11px 13px; color: var(--ink); background: #fff;
  border: 1px solid #d8dce6; border-radius: 13px; outline: none;
}
input:focus, select:focus { border-color: var(--violet); box-shadow: 0 0 0 4px rgba(102,85,217,.12); }
.code-input { min-height: 56px; text-align: center; text-transform: uppercase; letter-spacing: .1em; font-size: 20px; font-weight: 900; border-width: 1.5px; }
.primary { width: 100%; min-height: 54px; margin-top: 13px; padding: 12px 17px; color: #fff; border: 0; border-radius: 15px; background: linear-gradient(135deg, #ed1682, #c50b68); font-weight: 900; box-shadow: 0 12px 28px rgba(213,30,130,.25); transition: transform .18s ease, box-shadow .18s ease; }
.primary:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 15px 32px rgba(213,30,130,.3); }
.primary:disabled { cursor: wait; opacity: .55; }
.notice { margin-top: 15px; padding: 12px 14px; color: #5f6475; background: #fbf8fc; border: 1px solid #ebe2ec; border-radius: 13px; font-size: 12px; line-height: 1.6; }
.message { margin-top: 13px; padding: 12px 14px; border-radius: 12px; font-size: 13px; line-height: 1.55; }
.message.error { color: var(--red); background: var(--red-soft); }
.message.success { color: var(--green); background: var(--green-soft); }

.watch-shell { width: min(1280px, calc(100% - 26px)); }
.browser-gate-open { overflow: hidden; }
.browser-notice {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: -10px 0 18px;
  padding: 13px 15px; color: #744800; background: var(--amber-soft); border: 1px solid #f0d9a7; border-radius: 15px;
  box-shadow: 0 8px 24px rgba(103,72,10,.07);
}
.browser-notice strong, .browser-notice span { display: block; }
.browser-notice strong { margin-bottom: 3px; font-size: 13px; }
.browser-notice span { font-size: 11px; line-height: 1.55; }
.notice-copy-button { flex: 0 0 auto; padding: 9px 12px; color: #744800; background: #fff; border: 1px solid #e8c986; border-radius: 10px; font-size: 11px; font-weight: 850; }
.source-disclosure {
  position: relative; overflow: hidden; margin: 0 0 18px; padding: 20px 24px; text-align: center;
  background: linear-gradient(135deg, rgba(255,255,255,.96), rgba(255,246,251,.94));
  border: 1px solid rgba(226,207,220,.86); border-radius: 20px; box-shadow: 0 12px 34px rgba(61,45,79,.08);
}
.source-disclosure::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: linear-gradient(var(--pink), var(--violet)); }
.source-live { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 9px; color: var(--pink-dark); font-size: 10px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.source-live i { width: 7px; height: 7px; background: #ef3153; border-radius: 50%; box-shadow: 0 0 0 5px rgba(239,49,83,.1); }
.source-disclosure strong { display: block; font-size: clamp(17px, 2.2vw, 23px); line-height: 1.42; }
.source-disclosure em { color: var(--pink-dark); font-style: normal; }
.source-disclosure p { margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.source-disclosure-compact { margin: 0 0 20px; padding: 16px 18px; border-radius: 16px; box-shadow: none; }
.source-disclosure-compact strong { font-size: 15px; }
.source-disclosure-compact p { font-size: 10px; }
.watch-grid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 18px; align-items: start; }
.player-card { overflow: hidden; background: #070a12; border-radius: 23px; box-shadow: 0 22px 65px rgba(11,13,28,.28); }
.player-stage { position: relative; display: grid; aspect-ratio: 16 / 9; place-items: center; color: #fff; background: radial-gradient(circle at 50% 30%, #28325f, #090b15 65%); }
.player-stage iframe, .player-stage video { width: 100%; height: 100%; border: 0; background: #000; object-fit: contain; }
.waiting { padding: 28px; text-align: center; }
.waiting-icon { display: grid; width: 68px; height: 68px; margin: 0 auto 17px; place-items: center; background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.12); border-radius: 22px; font-size: 30px; }
.waiting h1 { margin: 0; font-size: 24px; }
.waiting p { margin: 10px auto 0; max-width: 520px; color: #aeb6ce; line-height: 1.6; }
.waiting-action { margin-top: 18px; padding: 11px 18px; color: #fff; background: linear-gradient(135deg, var(--pink), var(--violet)); border: 0; border-radius: 12px; font-weight: 850; }
.player-meta { display: flex; justify-content: space-between; gap: 16px; padding: 16px 19px; color: #dce1ee; background: #111522; }
.player-meta strong { color: #fff; }
.player-actions { display: flex; align-items: center; gap: 14px; }
.quality-control { display: flex; align-items: center; gap: 8px; color: #aeb6ce; font-size: 13px; }
.quality-control select { min-width: 122px; padding: 8px 30px 8px 10px; color: #fff; background: #1b2132; border: 1px solid #343d55; border-radius: 10px; font: inherit; }
.quality-control select:disabled { opacity: .55; }
.live-dot { display: inline-flex; align-items: center; gap: 7px; color: #ff7b91; font-size: 12px; font-weight: 850; }
.live-dot::before { content: ""; width: 8px; height: 8px; background: #f23859; border-radius: 50%; box-shadow: 0 0 0 5px rgba(242,56,89,.13); }
.side-card { padding: 20px; background: rgba(255,255,255,.94); border: 1px solid rgba(255,255,255,.9); border-radius: 20px; box-shadow: 0 12px 35px rgba(30,35,65,.08); }
.side-card h2 { margin: 0 0 14px; font-size: 17px; }
.side-item { padding: 12px 0; border-top: 1px solid var(--line); }
.side-item span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; }
.side-item strong { font-size: 13px; overflow-wrap: anywhere; }
.viewer-readiness { margin-top: 14px; padding: 14px; background: #f7f8fc; border: 1px solid var(--line); border-radius: 15px; }
.viewer-readiness h3 { margin: 0 0 10px; font-size: 14px; }
.readiness-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.readiness-grid span { padding: 7px 8px; color: #525b70; background: #fff; border: 1px solid #e5e8ef; border-radius: 9px; font-size: 10px; font-weight: 750; }
.viewer-readiness p { margin: 10px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.playback-help { margin-top: 12px; overflow: hidden; border: 1px solid #dddff0; border-radius: 14px; background: #fff; }
.playback-help summary { position: relative; padding: 12px 36px 12px 13px; color: #4a467c; background: #f6f5ff; cursor: pointer; list-style: none; font-size: 12px; font-weight: 850; line-height: 1.45; }
.playback-help summary::-webkit-details-marker { display: none; }
.playback-help summary::after { content: "+"; position: absolute; top: 50%; right: 14px; transform: translateY(-50%); font-size: 18px; }
.playback-help[open] summary::after { content: "−"; }
.playback-help ol { padding: 2px 16px 0 34px; margin: 12px 0; color: #555e73; font-size: 11px; line-height: 1.65; }
.playback-help li + li { margin-top: 7px; }
.help-callout { margin: 0 12px 12px; padding: 10px; color: #75520f; background: var(--amber-soft); border-radius: 10px; font-size: 10px; line-height: 1.55; }
.security-list { padding-left: 18px; margin: 14px 0 0; color: #5d6579; font-size: 12px; line-height: 1.75; }

.browser-gate { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; padding: 18px; background: rgba(8,11,24,.78); backdrop-filter: blur(9px); }
.browser-gate-card { width: min(480px, 100%); max-height: calc(100vh - 36px); overflow: auto; padding: 27px; text-align: center; background: #fff; border: 1px solid rgba(255,255,255,.85); border-radius: 25px; box-shadow: 0 30px 90px rgba(0,0,0,.32); }
.browser-gate-icon { display: grid; width: 62px; height: 62px; margin: 0 auto 14px; place-items: center; background: linear-gradient(145deg, var(--pink-soft), #eeeeff); border-radius: 19px; font-size: 27px; }
.browser-gate-card .eyebrow { color: var(--pink-dark); }
.browser-gate-card h2 { margin: 0; font-size: 25px; line-height: 1.25; }
.browser-gate-card > p:not(.eyebrow) { margin: 11px 0 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.browser-steps { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 17px; text-align: left; }
.browser-steps div { padding: 12px; background: #f7f8fc; border: 1px solid var(--line); border-radius: 13px; }
.browser-steps strong, .browser-steps span { display: block; }
.browser-steps strong { margin-bottom: 4px; font-size: 12px; }
.browser-steps span { color: var(--muted); font-size: 10px; line-height: 1.5; }
.browser-copy-button { margin-top: 15px; }
.browser-continue-button { width: 100%; margin-top: 9px; padding: 11px; color: #626a7d; background: transparent; border: 0; font-size: 11px; font-weight: 750; text-decoration: underline; text-underline-offset: 3px; }
.browser-gate-card small { display: block; color: #8a91a2; font-size: 9px; line-height: 1.5; }

.admin-login { display: grid; min-height: 100vh; padding: 24px; place-items: center; }
.admin-login .access-card { max-width: 440px; }
.admin-wrap { width: min(1260px, calc(100% - 30px)); margin: 0 auto; padding: 24px 0 60px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 22px; }
.dashboard-grid { display: grid; grid-template-columns: 390px minmax(0, 1fr); gap: 18px; align-items: start; }
.panel { overflow: hidden; background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 21px; box-shadow: 0 9px 30px rgba(30,35,65,.06); }
.panel-head { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 18px; }
.panel-head p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.panel-body { padding: 19px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-grid .full { grid-column: 1 / -1; }
.event-list { display: grid; gap: 12px; }
.admin-event { padding: 17px; border: 1px solid var(--line); border-radius: 16px; background: #fbfcfe; }
.admin-event-top { display: flex; justify-content: space-between; gap: 14px; }
.admin-event h3 { margin: 0; font-size: 16px; }
.status { display: inline-flex; height: fit-content; padding: 5px 9px; border-radius: 999px; font-size: 10px; font-weight: 850; }
.status.live { color: var(--red); background: var(--red-soft); }
.status.open { color: var(--green); background: var(--green-soft); }
.status.draft, .status.ended { color: #646c80; background: #eef0f5; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 13px; }
.metric { padding: 10px; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 11px; }
.metric strong { display: block; font-size: 18px; }
.metric span { color: var(--muted); font-size: 10px; }
.event-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.small-button { padding: 8px 10px; color: #525b70; background: #fff; border: 1px solid #dce0e9; border-radius: 9px; font-size: 11px; font-weight: 800; }
.small-button.accent { color: #fff; background: var(--violet); border-color: var(--violet); }
.small-button.discord { color: #fff; background: #5865f2; border-color: #5865f2; }
.small-button.danger { color: #fff; background: #d92d54; border-color: #d92d54; }
.small-button.danger:hover { background: #ba2044; border-color: #ba2044; }
.discord-state { width: fit-content; padding: 6px 9px; margin: 11px 0 0; border-radius: 999px; font-size: 10px; font-weight: 800; }
.discord-state.enabled { color: #167451; background: #e4f7ef; }
.discord-state.paused { color: #8c6022; background: #fff2d9; }
.codes-output { max-height: 260px; overflow: auto; padding: 12px; margin-top: 13px; background: #111522; border-radius: 13px; color: #f7d8e9; font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; line-height: 1.8; white-space: pre-wrap; }

@media (max-width: 850px) {
  .watch-grid, .dashboard-grid { grid-template-columns: 1fr; }
  .side-card { order: 2; }
}
@media (max-width: 560px) {
  .shell { width: min(100% - 20px, 1120px); padding-top: 16px; }
  .access-hero, .access-body { padding: 24px 20px; }
  .access-card { border-radius: 22px; }
  .topbar { margin-bottom: 18px; }
  .brand { gap: 9px; }
  .brand-logo { width: 45px; height: 45px; border-radius: 14px; }
  .brand strong { max-width: 220px; font-size: 13px; line-height: 1.3; }
  .live-service-badge { padding: 8px 10px; font-size: 9px; }
  .hero-brand { margin-bottom: 20px; }
  .hero-logo-wrap { width: 48px; height: 48px; border-radius: 15px; }
  .code-label { align-items: start; flex-direction: column; gap: 2px; }
  .source-disclosure { padding: 17px 15px; border-radius: 16px; }
  .source-disclosure strong { font-size: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .player-meta { flex-direction: column; }
  .player-actions { width: 100%; justify-content: space-between; }
  .browser-notice { align-items: stretch; flex-direction: column; }
  .notice-copy-button { width: 100%; }
  .browser-gate-card { padding: 23px 18px; border-radius: 21px; }
  .browser-gate-card h2 { font-size: 22px; }
  .browser-steps { grid-template-columns: 1fr; }
}
