:root {
  color-scheme: dark;
  --bg: #0e0e10;
  --surface: #18181b;
  --surface-2: #1f1f23;
  --line: #2f2f35;
  --text: #efeff1;
  --muted: #adadb8;
  --accent: #9147ff;
  --accent-2: #00f0b5;
  --danger: #ff4f8b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 50px 1fr;
}

.top-bar {
  display: grid;
  grid-template-columns: auto minmax(180px, 420px) auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: #18181b;
  border-bottom: 1px solid #000;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 152px;
}

.brand img {
  display: block;
  width: 150px;
  max-height: 34px;
  object-fit: contain;
  object-position: left center;
}

.search-box {
  height: 34px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: #0f0f11;
  border: 1px solid #33333a;
  border-radius: 6px;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.soft-button,
.reaction-action,
.special-stamp-button {
  border: 0;
  border-radius: 6px;
  color: var(--text);
  background: #303037;
  cursor: pointer;
}

.soft-button {
  height: 34px;
  padding: 0 14px;
}

.viewer-chip {
  height: 34px;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-radius: 999px;
  background: #0f0f11;
  border: 1px solid #33333a;
  color: var(--text);
  font-size: 13px;
}

.viewer-chip[hidden],
.auth-prompt[hidden] {
  display: none;
}

.viewer-chip img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
}

.viewer-chip a {
  color: var(--muted);
  text-decoration: none;
}

.watch-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
}

.stream-column {
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(320px, 1fr) auto auto;
  background: var(--bg);
}

.player-frame {
  position: relative;
  min-height: 320px;
  background: #000;
  overflow: hidden;
}

.player-frame iframe,
.chat-column iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.interaction-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.reaction-action[hidden] {
  display: none;
}

.viewer-stamp-panel {
  min-width: 0;
  padding: 12px 18px 14px;
  border-top: 1px solid #ead2e1;
  border-bottom: 1px solid #e7cbdc;
  background:
    linear-gradient(90deg, rgba(255, 229, 244, .96), rgba(255, 248, 252, .98) 55%, rgba(241, 225, 255, .96)),
    #fff7fb;
  color: #302b31;
}

.viewer-stamp-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.viewer-stamp-heading h2,
.viewer-stamp-heading p,
.viewer-stamp-status {
  margin: 0;
}

.viewer-stamp-heading h2 {
  font-size: 16px;
  line-height: 1.25;
}

.viewer-stamp-heading p {
  margin-top: 2px;
  color: #806d7a;
  font-size: 11px;
  font-weight: 700;
}

.viewer-stamp-test {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 4px;
  background: #ffe3f1;
  color: #b8256b;
  font-size: 11px;
  font-weight: 800;
}

.viewer-stamp-list {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
  padding: 1px 1px 4px;
}

.viewer-stamp-button {
  position: relative;
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  padding: 5px;
  border: 1px solid #ecc7dc;
  border-radius: 6px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 3px 10px rgba(157, 71, 121, .08);
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}

.viewer-stamp-button:hover:not(:disabled),
.viewer-stamp-button:focus-visible:not(:disabled) {
  z-index: 1;
  transform: translateY(-2px);
  border-color: #dc6aa4;
  box-shadow: 0 7px 16px rgba(184, 37, 107, .15);
  outline: none;
}

.viewer-stamp-button:active:not(:disabled) {
  transform: translateY(0) scale(.96);
}

.viewer-stamp-button:disabled {
  cursor: not-allowed;
  filter: grayscale(.35);
  opacity: .5;
}

.viewer-stamp-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.viewer-stamp-status {
  min-height: 17px;
  margin-top: 5px;
  color: #806d7a;
  font-size: 11px;
  font-weight: 700;
}

.viewer-stamp-status.is-error {
  color: #b4234f;
}

.viewer-stamp-status.is-success {
  color: #8f1e6a;
}

.reaction-action,
.special-stamp-button {
  pointer-events: auto;
  position: absolute;
  right: 20px;
  z-index: 5;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.38);
}

.reaction-action {
  min-width: 128px;
  height: 46px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: linear-gradient(135deg, #9147ff, #ff4f8b);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.reaction-action:hover,
.special-stamp-button:hover,
.soft-button:hover {
  filter: brightness(1.12);
}

.special-stamp-button:disabled {
  cursor: default;
  filter: saturate(0.7) brightness(0.86);
}

.react-icon {
  color: #ffe66d;
  font-size: 18px;
  line-height: 1;
}

.reaction-action.is-star {
  right: 20px;
  bottom: 20px;
  background: linear-gradient(135deg, #9147ff, #ff4f8b);
}

.reaction-action.is-heart {
  right: 20px;
  bottom: 76px;
  background: linear-gradient(135deg, #ff4f8b, #9147ff);
}

.reaction-action.is-heart .react-icon {
  color: #fff1f6;
}

.special-stamp-button {
  bottom: 132px;
  right: 34px;
  min-width: 104px;
  height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background:
    linear-gradient(135deg, rgba(255, 209, 102, 0.98), rgba(0, 240, 181, 0.96)),
    #ffd166;
  color: #111113;
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
}

.special-stamp-button[hidden] {
  display: none;
}

.special-stamp-icon {
  color: #9147ff;
  font-size: 14px;
  line-height: 1;
}

.special-stamp-count {
  min-width: 22px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(17, 17, 19, 0.18);
  color: #111113;
  font-size: 11px;
  line-height: 1;
}

.reaction {
  position: absolute;
  width: 108px;
  height: 108px;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -50%) scale(0.35);
  pointer-events: none;
  animation: popFlight 1.35s cubic-bezier(.18,.9,.2,1) forwards;
  filter: drop-shadow(0 14px 20px rgba(0, 0, 0, 0.45));
}

.reaction img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.reaction-label {
  position: absolute;
  left: 50%;
  bottom: -18px;
  transform: translateX(-50%);
  max-width: 160px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(15, 15, 17, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reaction::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.6);
  animation: ripple 0.75s ease-out forwards;
}

@keyframes popFlight {
  0% {
    opacity: 0;
    transform: translate(-50%, -30%) scale(0.2) rotate(-12deg);
  }
  14% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05) rotate(6deg);
  }
  55% {
    opacity: 1;
    transform: translate(-50%, -105%) scale(0.94) rotate(-4deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -185%) scale(0.62) rotate(12deg);
  }
}

@keyframes ripple {
  to {
    opacity: 0;
    transform: scale(2.15);
  }
}

.stream-info {
  min-height: 96px;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  background: var(--bg);
  border-top: 1px solid #080809;
}

.channel-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background:
    radial-gradient(circle at 30% 25%, #00f0b5, transparent 28px),
    linear-gradient(135deg, #4cc9f0, #9147ff);
}

.stream-copy {
  min-width: 0;
}

.channel-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
}

.channel-row h1 {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.25;
}

.stream-copy p {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-badge {
  min-height: 20px;
  display: inline-flex;
  align-items: center;
  padding: 0 7px;
  border-radius: 4px;
  background: #3a3a42;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.live-badge.is-live {
  background: #e91916;
}

.live-badge.is-offline {
  background: #53535f;
}

.live-badge.is-error {
  background: #b45309;
}

.stream-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.stream-meta span:not(:last-child)::after {
  content: "";
  display: inline-block;
  width: 3px;
  height: 3px;
  margin-left: 12px;
  border-radius: 50%;
  vertical-align: middle;
  background: #6f6f7b;
}

.chat-column {
  min-width: 0;
  display: grid;
  grid-template-rows: 46px auto minmax(0, 1fr);
  background: var(--surface);
  border-left: 1px solid var(--line);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 800;
}

.chat-login-strip {
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #121214;
  color: var(--muted);
  font-size: 12px;
}

.chat-login-strip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-login-button {
  height: 30px;
  padding: 0 10px;
  border: 1px solid #3a3a42;
  border-radius: 6px;
  color: var(--text);
  background: #242428;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  border-color: transparent;
  background: var(--accent);
  color: #fff;
}

.chat-login-button:hover {
  filter: brightness(1.12);
}

.auth-prompt {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.56);
}

.auth-dialog {
  width: min(420px, 100%);
  padding: 22px;
  border-radius: 8px;
  border: 1px solid #3a3a42;
  background: #18181b;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.auth-dialog h2 {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.2;
}

.auth-dialog p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.auth-dialog .auth-note {
  margin-top: -10px;
  margin-bottom: 18px;
  color: #7f7f8a;
  font-size: 12px;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.login-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  text-decoration: none;
}

@media (max-width: 980px) {
  .watch-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(420px, 62vh) minmax(320px, 38vh);
  }

  .stream-column {
    grid-template-rows: 1fr auto auto;
  }

  .stream-info {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .chat-column {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 640px) {
  .top-bar {
    grid-template-columns: auto 1fr;
    height: auto;
    padding: 8px;
  }

  .soft-button {
    grid-column: 2;
  }

  .viewer-chip {
    grid-column: 1 / -1;
    justify-self: stretch;
    justify-content: center;
  }

  .brand {
    min-width: 0;
  }

  .brand img {
    width: 126px;
  }

  .viewer-stamp-panel {
    padding-inline: 12px;
  }

  .stream-info {
    grid-template-columns: 44px minmax(0, 1fr);
    padding: 14px;
  }

  .channel-avatar {
    width: 44px;
    height: 44px;
  }

  .stream-copy p {
    white-space: normal;
  }

  .reaction-action {
    right: 12px;
  }

  .reaction-action.is-star {
    bottom: 14px;
  }

  .reaction-action.is-heart {
    bottom: 70px;
  }

  .special-stamp-button {
    right: 18px;
    bottom: 126px;
  }

}
