* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Old Standard TT", serif;
  background: #000;
  color: #fff;
  height: 100dvh;
  display: flex;
  overflow: hidden;
  position: relative;
}

.bg-layer {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateX(0);
  height: 100dvh;
  width: 100dvh;
  z-index: 0;
  pointer-events: none;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1.5s ease;
}

@media (min-aspect-ratio: 10/6) {
  .bg-layer {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
  }
}

.bg-layer.active {
  opacity: 1;
}

.bg-overlay {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateX(0);
  height: 100dvh;
  width: 100dvh;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(to right, #000 0%, transparent 50%, transparent 50%, #000 100%);
  /* background: linear-gradient(to right, #000099 0%, transparent 50%, transparent 50%, #990000 100%); */
}

@media (min-aspect-ratio: 10/6) {
  .bg-overlay {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
  }
}

.chat-container {
  position: relative;
  z-index: 1;
  width: calc(100dvh + 250px);
  max-width: 100%;
  height: 100dvh;
  margin: 0;
  display: flex;
  flex-direction: column;
  opacity: 1;
  transition: opacity 0.8s ease;
}

@media (min-aspect-ratio: 10/7) {
  .chat-container {
    width: calc(100dvh + 250px + 250px);
    margin: 0 auto;
  }
}

.chat-container.hidden {
  opacity: 0;
}

#sendButton,
#newSessionButton,
#profileButton,
#rulesButton,
#favBgButton,
#deleteBgButton {
  padding: 12px 12px 8px 12px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 18px;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background 0.2s,
    color 0.2s;
  line-height: 1;
}

#newSessionButton:hover,
#profileButton:hover,
#favBgButton:hover {
  background: rgba(255, 255, 255, 0.25);
}

#favBgButton.active {
  color: #ff4d6a;
}

#deleteBgButton:hover {
  background: rgba(255, 80, 80, 0.35);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 60px 20px 20px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-messages::after {
  content: "";
  display: block;
  min-height: calc(100dvh - 120px);
  flex-shrink: 0;
}

.message {
  max-width: 400px;
  padding: 30px 30px 30px 14px;
  border-radius: 12px;
  line-height: 1.2;
  font-size: 19px;
  word-wrap: break-word;
  white-space: pre-wrap;
  background: rgba(0, 0, 0, 0.01);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #fff;
}

.message.assistant p:first-child:before {
  content: "»";
}
.message.assistant p:last-child:after {
  content: "«";
}

.message.assistant {
  white-space: normal;
  padding-top: 80px;
}

.message.assistant p {
  margin: 0 0 8px 0;
}

.message.assistant p:last-child {
  margin-bottom: 0;
}

.message.assistant ul,
.message.assistant ol {
  margin: 4px 0 8px 20px;
}

.message.assistant code {
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
}

.message.assistant pre {
  background: rgba(255, 255, 255, 0.1);
  color: #e0e0e0;
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
}

.message.assistant pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.message.assistant a {
  text-decoration: none;
}

.message.assistant strong {
  font-weight: 700;
}

.message.assistant h1,
.message.assistant h2,
.message.assistant h3 {
  margin: 8px 0 4px 0;
  font-size: 15px;
  font-weight: 700;
}

.message.user {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  padding-top: 70px;
  padding-bottom: 7px;
  margin-top: 45px;
  color: #000;
  font-weight: bold;
  text-shadow:
    0 0 35px #bbb,
    0 0 25px #bbb,
    0 0 20px #bbb,
    0 0 15px #bbb,
    0 0 10px #bbb,
    0 0 5px #bbb;
}

.message.assistant {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.message.typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 20px 22px;
}

.message.typing .dot {
  width: 7px;
  height: 7px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  animation: typing-bounce 1.4s ease-in-out infinite;
}

.message.typing .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.message.typing .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

.chat-input {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.chat-input textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 120px;
  background: transparent;
  color: #fff;
  transition: border-color 0.2s;
}

.chat-input textarea::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.chat-input textarea:focus {
  border-color: rgba(255, 255, 255, 0.5);
}

.chat-input textarea:disabled {
  opacity: 0.5;
}

.chat-input button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Reward Trigger */

.reward-trigger {
  cursor: pointer;
  font-size: 20px;
  display: inline-block;
  transition: transform 0.2s;
}

.reward-trigger:hover {
  transform: scale(1.3);
}

/* Rewardbox Lightbox */

.rewardbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.92);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: rewardbox-fadein 0.4s ease;
}

@keyframes rewardbox-fadein {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.rewardbox {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 92vw;
  height: 92vh;
}

.rewardbox iframe {
  width: 100%;
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.rewardbox-image {
  height: min(92vw, 92vh);
  width: min(92vw, 92vh);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.rewardbox-close {
  position: relative;
  z-index: 1;
  padding: 12px 28px;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  font-family: "Old Standard TT", serif;
  font-size: 15px;
  font-style: italic;
  cursor: pointer;
  transition:
    color 0.3s,
    border-color 0.3s;
}

.rewardbox-close:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.5);
}

/* Reward Animations */

.reward-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

/* Constellation */

.constellation-star {
  position: absolute;
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  box-shadow:
    0 0 14px 4px rgba(255, 255, 255, 0.7),
    0 0 30px 8px rgba(255, 255, 255, 0.3);
  opacity: 0;
  filter: blur(3px);
  animation: constellation-pulse 1.6s ease-in-out forwards;
}

@keyframes constellation-pulse {
  0% {
    opacity: 0;
    transform: scale(0);
  }
  25% {
    opacity: 1;
    transform: scale(2);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.2);
  }
  100% {
    opacity: 0;
    transform: scale(0.3);
  }
}

/* Rule System Styles */
#rulesButton {
  color: #d4af37;
  position: relative;
}

#rulesButton:hover {
  background: rgba(212, 175, 55, 0.25);
}

#rulesButton.pulse {
  animation: rules-pulse 2s ease-in-out 3;
}

@keyframes rules-pulse {
  0%, 100% { color: #d4af37; }
  50% { color: #fff; text-shadow: 0 0 10px rgba(212, 175, 55, 0.8); }
}

/* Rules Modal */
.rules-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: rewardbox-fadein 0.3s ease;
}

.rules-modal {
  background: rgba(20, 15, 10, 0.95);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 12px;
  padding: 30px;
  max-width: 420px;
  width: 90vw;
}

.rules-modal-header {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #d4af37;
  margin-bottom: 20px;
}

.rules-modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.rule-item {
  border-left: 2px solid rgba(212, 175, 55, 0.5);
  padding-left: 14px;
}

.rule-item p {
  font-size: 15px;
  line-height: 1.4;
  color: #fff;
  margin: 0 0 4px 0;
}

.rule-item small {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
}

.rules-modal-close {
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 10px 24px;
  font-family: "Old Standard TT", serif;
  font-size: 14px;
  font-style: italic;
  cursor: pointer;
  transition: color 0.3s, border-color 0.3s;
}

.rules-modal-close:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.5);
}

/* New Session Blackout */
.session-blackout {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.session-blackout.active {
  opacity: 1;
  pointer-events: all;
}

.session-blackout-text {
  font-family: "Old Standard TT", serif;
  font-size: 16px;
  font-style: italic;
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 3px;
  animation: blackout-pulse 2s ease-in-out infinite;
}

@keyframes blackout-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}
