* {
  box-sizing: border-box;
}

:root {
  --bg: #0b1020;
  --bg-soft: #10172d;
  --surface: rgba(255 255 255 / 0.06);
  --surface-strong: rgba(255 255 255 / 0.1);
  --border: rgba(255 255 255 / 0.12);
  --text: #edf1ff;
  --muted: #92a0d3;
  --accent: #6c7cff;
  --accent-2: #8a98ff;
  --danger: #ff6b6b;
  --success: #4cd67f;
  --shadow: 0 12px 40px rgba(0 0 0 / 0.35);
  --radius: 18px;
  --yt: #ff244a;
  --tc: #2196f3;
  --tw: #9146ff;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Yu Gothic', sans-serif;
  -webkit-text-size-adjust: 100%;
}

body[data-page='admin'] {
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(108 124 255 / 0.25), transparent 35%),
    radial-gradient(circle at top right, rgba(76 214 127 / 0.14), transparent 28%),
    linear-gradient(180deg, #0b1020 0%, #11192f 100%);
  color: var(--text);
}

body[data-page='overlay'] {
  overflow: hidden;
  background: transparent;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255 255 255 / 0.05);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}

input:focus {
  border-color: rgba(108 124 255 / 0.9);
  box-shadow: 0 0 0 3px rgba(108 124 255 / 0.18);
}

.admin-shell {
  width: min(980px, calc(100% - 24px));
  margin: 0 auto;
  padding: 20px 0 36px;
  display: grid;
  gap: 16px;
}

.panel-card,
.hero-card {
  background: rgba(13 18 36 / 0.72);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.hero-card {
  padding: 20px;
  display: grid;
  gap: 16px;
}

.hero-copy {
  color: var(--muted);
  line-height: 1.6;
  margin-top: 8px;
}

.eyebrow {
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 8px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 34px);
}

h2 {
  font-size: 18px;
}

.hero-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  min-height: 46px;
  border-radius: 14px;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
  opacity: 0.82;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
}

.btn-secondary {
  background: rgba(255 255 255 / 0.07);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: rgba(255 107 107 / 0.15);
  color: var(--danger);
  border: 1px solid rgba(255 107 107 / 0.28);
}

.overlay-url-wrap {
  display: grid;
  gap: 8px;
}

.field-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.status-card {
  padding: 14px 18px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #596382;
  flex: none;
}

.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 18px rgba(76 214 127 / 0.65);
}

.status-dot.error {
  background: var(--danger);
  box-shadow: 0 0 18px rgba(255 107 107 / 0.65);
}

.status-subtext {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.panel-card {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  background: rgba(255 255 255 / 0.04);
  border-radius: 14px;
}

.tab {
  min-height: 42px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.tab.active {
  background: rgba(108 124 255 / 0.24);
  color: white;
}

.tab-panel {
  display: none;
  gap: 12px;
}

.tab-panel.active {
  display: grid;
}

.hint {
  color: var(--muted);
  line-height: 1.6;
  font-size: 12px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(80px);
  z-index: 1000;
  background: rgba(12 17 35 / 0.94);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 12px 18px;
  color: white;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

#comment-canvas {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.overlay-status {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 10;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: rgba(255 255 255 / 0.85);
  background: rgba(0 0 0 / 0.42);
  border: 1px solid rgba(255 255 255 / 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.comment-item {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  line-height: 1.2;
  font-weight: 800;
  color: white;
  will-change: transform;
  pointer-events: none;
}

.comment-item.stroke-on {
  -webkit-text-stroke: 1.5px rgba(0 0 0 / 0.95);
  paint-order: stroke fill;
  text-shadow:
    0 2px 5px rgba(0 0 0 / 0.92),
    0 0 12px rgba(0 0 0 / 0.64);
}

.comment-item.effect-gift-glow.type-gift {
  filter: drop-shadow(0 0 8px rgba(255 235 59 / 0.95)) drop-shadow(0 0 22px rgba(255 235 59 / 0.34));
}

.comment-item.effect-gift-glow.type-member {
  filter: drop-shadow(0 0 8px rgba(76 214 127 / 0.95)) drop-shadow(0 0 22px rgba(76 214 127 / 0.34));
}

.comment-service,
.comment-badge,
.comment-amount {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.2em 0.55em;
  font-size: 0.62em;
  font-weight: 900;
  line-height: 1;
}

.comment-service {
  background: rgba(255 255 255 / 0.16);
}

.service-youtube .comment-service {
  background: var(--yt);
}

.service-twitcasting .comment-service {
  background: var(--tc);
}

.service-twitch .comment-service {
  background: var(--tw);
}

.comment-badge {
  background: rgba(255 255 255 / 0.18);
}

.comment-name {
  color: rgba(255 255 255 / 0.76);
  font-size: 0.85em;
}

.comment-text {
  display: inline-block;
}

.comment-amount {
  color: #161600;
  background: #fff176;
}

@media (max-width: 720px) {
  .admin-shell {
    width: min(100%, calc(100% - 16px));
    padding: 12px 0 24px;
  }

  .hero-card,
  .panel-card {
    border-radius: 16px;
    padding: 14px;
  }

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

  .tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .button-row,
  .hero-actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}
