* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #0f1115;
  color: #f5f7fb;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  row-gap: 10px;
  padding: 16px 24px;
  background: #151923;
  border-bottom: 1px solid #22283a;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-size: 24px;
}

.title {
  font-size: 18px;
  font-weight: 600;
}

.subtitle {
  font-size: 12px;
  color: #9aa4b2;
}

.controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.name-label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: #c6ccd8;
}

.name-label input {
  margin-top: 4px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #2c3245;
  background: #0f1115;
  color: #f5f7fb;
}

.status {
  padding: 6px 10px;
  border-radius: 6px;
  background: #442020;
  border: 1px solid #7a2d2d;
  color: #ffb4b4;
  font-size: 12px;
}

.status.update {
  background: #1b2a14;
  border-color: #3f6b2a;
  color: #d6f5c6;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.status.update button {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #3f6b2a;
  background: #2f4d1f;
  color: #e8ffe0;
  font-size: 11px;
  cursor: pointer;
}

.indicators {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 11px;
  color: #c6ccd8;
}

.indicator {
  min-width: 140px;
  text-align: center;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #2c3245;
  background: #0f1115;
}

.hidden {
  display: none !important;
}

main {
  display: grid;
  gap: 20px;
  padding: 20px 24px 32px;
}

.preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview video {
  width: 240px;
  height: 180px;
  border-radius: 12px;
  background: #090b10;
  border: 1px solid #22283a;
  object-fit: cover;
}

.preview-encoded {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preview-subtitle {
  font-size: 12px;
  color: #9aa4b2;
}

.preview-encoded img {
  width: 240px;
  height: 180px;
  border-radius: 12px;
  background: #090b10;
  border: 1px solid #22283a;
  object-fit: contain;
}

.reaction-panel,
.reaction-feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reaction-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.reaction-button {
  min-width: 40px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #2c3245;
  background: #111520;
  color: #f5f7fb;
  font-size: 16px;
  cursor: pointer;
}

.reaction-button:hover {
  border-color: #3a4560;
  background: #151923;
}

.reaction-feed-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
  padding-right: 4px;
}

.reaction-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  background: #111520;
  border: 1px solid #252c40;
  font-size: 12px;
  color: #d7dce8;
}

.reaction-item .reaction-time {
  margin-left: auto;
  font-size: 11px;
  color: #9aa4b2;
}

.reaction-item .emoji {
  font-size: 16px;
}

.settings {
  margin-top: 6px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid #252c40;
  background: #111520;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-header {
  font-size: 12px;
  color: #c6ccd8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.setting-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: #cfd6e2;
}

.setting-inline {
  display: flex;
  align-items: center;
  gap: 6px;
}

.setting-inline input {
  width: 80px;
}

.setting-row input[type="number"],
.setting-row input[type="range"] {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #2c3245;
  background: #0f1115;
  color: #f5f7fb;
}

.setting-value {
  font-size: 11px;
  color: #9aa4b2;
}

.setting-actions {
  display: flex;
  justify-content: flex-end;
}

.setting-actions button {
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: #4b7bff;
  color: white;
  font-size: 12px;
  cursor: pointer;
}

.preview-header,
.grid-header {
  font-size: 14px;
  color: #c6ccd8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.bell-style {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #9aa4b2;
}

.bell-style select {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #2c3245;
  background: #0f1115;
  color: #f5f7fb;
  font-size: 11px;
}

.ghost-button {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #2c3245;
  background: transparent;
  color: #c6ccd8;
  font-size: 11px;
  cursor: pointer;
}

.ghost-button:disabled {
  opacity: 0.6;
  cursor: default;
}

.grid-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, 160px);
  justify-content: start;
}

.tile {
  background: #151923;
  border: 1px solid #252c40;
  border-radius: 12px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}

.tile.bell-highlight {
  border-color: #ffd166;
  box-shadow: 0 0 0 2px rgba(255, 209, 102, 0.35), 0 0 24px rgba(255, 209, 102, 0.25);
  animation: bell-glow 6s ease-in-out infinite;
}

.tile.bell-highlight::after {
  content: "";
  position: absolute;
  inset: -40%;
  background: conic-gradient(
    from 120deg,
    rgba(255, 209, 102, 0.4),
    rgba(255, 255, 255, 0.08),
    rgba(255, 209, 102, 0.35),
    rgba(255, 255, 255, 0.08),
    rgba(255, 209, 102, 0.4)
  );
  opacity: 0.4;
  animation: bell-shimmer 6s linear infinite;
  pointer-events: none;
}

@keyframes bell-glow {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 2px rgba(255, 209, 102, 0.25), 0 0 18px rgba(255, 209, 102, 0.2);
  }
  50% {
    transform: scale(1.01);
    box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.45), 0 0 32px rgba(255, 209, 102, 0.35);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 2px rgba(255, 209, 102, 0.25), 0 0 18px rgba(255, 209, 102, 0.2);
  }
}

@keyframes bell-shimmer {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.tile img {
  width: 100%;
  height: 120px;
  border-radius: 8px;
  background: #0b0e16;
  object-fit: contain;
  object-position: center;
  cursor: pointer;
}

.tile .label {
  font-size: 11px;
  color: #cfd6e2;
}

.reaction-burst {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 48px;
  pointer-events: none;
  animation: reaction-pop 1.1s ease-out forwards;
  text-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.bell-burst {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 56px;
  pointer-events: none;
  animation: bell-burst 1.4s ease-out forwards;
  text-shadow: 0 10px 26px rgba(0, 0, 0, 0.6);
}

@keyframes reaction-pop {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  20% {
    opacity: 1;
    transform: scale(1.15);
  }
  100% {
    opacity: 0;
    transform: translateY(-24px) scale(0.9);
  }
}

@keyframes bell-burst {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  20% {
    opacity: 1;
    transform: scale(1.2);
  }
  100% {
    opacity: 0;
    transform: translateY(-32px) scale(0.9);
  }
}

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #151923;
  border: 1px solid #2c3245;
  color: #e9edf6;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 12px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.35);
  animation: toast-slide 4s ease forwards;
}

.game-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  color: #c6ccd8;
}

.game-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.game-status {
  font-size: 11px;
  color: #9aa4b2;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #2c3245;
  background: #0f1115;
}

.game-help {
  font-size: 12px;
  color: #9aa4b2;
}

@keyframes toast-slide {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  10% {
    opacity: 1;
    transform: translateY(0);
  }
  85% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(8px);
  }
}

.gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(9, 11, 16, 0.9);
  z-index: 20;
}

.gate-card {
  background: #151923;
  border: 1px solid #252c40;
  border-radius: 16px;
  padding: 28px;
  width: min(360px, 90vw);
  text-align: center;
}

.gate-card button {
  margin-top: 16px;
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  background: #4b7bff;
  color: white;
  font-size: 14px;
  cursor: pointer;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.login-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: #cfd6e2;
  text-align: left;
}

.login-label input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #2c3245;
  background: #0f1115;
  color: #f5f7fb;
}

.gate-error {
  margin-top: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #442020;
  color: #ffb4b4;
  font-size: 12px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 11, 16, 0.92);
}

.lightbox-content {
  position: relative;
  z-index: 1;
  background: #151923;
  border: 1px solid #252c40;
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(720px, 92vw);
  max-height: 90vh;
}

.lightbox-content img {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 12px;
  background: #0b0e16;
}

.lightbox-label {
  font-size: 13px;
  color: #cfd6e2;
  text-align: center;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 11, 16, 0.9);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(420px, 92vw);
  background: #151923;
  border: 1px solid #252c40;
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

@media (min-width: 960px) {
  main {
    grid-template-columns: 260px 1fr;
    align-items: start;
  }
}
