:root {
  --color-primary: #ff0033;
  --color-primary-dark: #680015;
  --color-background-main: #0a0205;
  --color-background-panel: rgba(20, 5, 10, 0.85);
  --color-text-main: #f0e6e6;
  --color-text-bright: #ffffff;

  --font-body: 'VT323', monospace;
  --font-serif: 'Cormorant Garamond', serif;
}

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

html {
  height: 100%;
}

body {
  background: url('https://storage.googleapis.com/generative-ai-gallery-assets/user-owned-assets/55d7a6e1-2b9a-4a6c-850f-56155986f376.jpeg') no-repeat center center fixed;
  background-color: var(--color-background-main);
  background-size: cover;
  color: var(--color-text-main);
  font-family: var(--font-body);
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  overflow: hidden;
  font-size: 1.2rem;
}

/* Global flicker effect */
body::before {
  content: "";
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.03),
    rgba(255, 255, 255, 0.03) 1px,
    transparent 1px,
    transparent 4px
  );
  pointer-events: none;
  z-index: 200;
  animation: flicker 0.15s infinite;
}

/* Initiation Screen */
#initiation-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(10, 2, 5, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  padding: 1rem;
  animation: fadeIn 1.5s ease-in;
}

#initiation-screen.fade-out {
  animation: fadeOut 0.5s ease-out forwards;
  pointer-events: none;
}

.initiation-step {
  max-width: 600px;
  width: 100%;
  padding: 2.5rem 3rem;
  text-align: center;
  border: 1px solid var(--color-primary);
  box-shadow: 0 0 15px var(--color-primary), inset 0 0 10px var(--color-primary);
  background-color: var(--color-background-panel);
}

.initiation-step h2 {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 1.5rem;
  text-shadow: 0 0 8px var(--color-primary);
}

.initiation-step .initiation-text {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  line-height: 1.6;
  color: var(--color-text-main);
  margin-bottom: 2rem;
}

#riddle-form,
#username-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#riddle-answer,
#username-input {
  background-color: transparent;
  border: 1px solid var(--color-primary-dark);
  border-bottom: 1px solid var(--color-primary);
  color: var(--color-text-bright);
  padding: 0.75rem;
  font-family: var(--font-serif);
  font-size: 1.3rem;
  text-align: center;
  transition: all 0.3s;
}

#riddle-answer:focus,
#username-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 10px var(--color-primary);
}

#riddle-form button,
#username-form button {
  background-color: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  padding: 0.75rem 1.5rem;
  font-family: var(--font-body);
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.3s, color 0.3s;
  letter-spacing: 2px;
}

#riddle-form button:hover,
#riddle-form button:focus,
#username-form button:hover,
#username-form button:focus {
  background-color: var(--color-primary);
  color: var(--color-text-bright);
}

.error-message {
  color: var(--color-primary);
  margin-top: 1rem;
  height: 1.5em;
  font-family: var(--font-serif);
}

#app-container {
  width: 100%;
  max-width: 800px;
  height: 100%;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-primary);
  box-shadow: 0 0 15px var(--color-primary), inset 0 0 15px var(--color-primary);
  background-color: var(--color-background-panel);
  backdrop-filter: blur(5px);
  position: relative;
}

#app-container:not([hidden]) {
    animation: fadeIn 1s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}


@keyframes flicker {
  0% { opacity: 0.8; }
  20% { opacity: 1; }
  40% { opacity: 0.9; }
  60% { opacity: 1; }
  80% { opacity: 0.85; }
  100% { opacity: 0.95; }
}


header {
  padding: 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--color-primary);
  flex-shrink: 0;
}

h1 {
  font-family: var(--font-body);
  font-size: 3rem;
  color: var(--color-primary);
  text-shadow: 0 0 5px var(--color-primary), 0 0 10px var(--color-primary);
  position: relative;
  animation: glitch 5s infinite steps(1);
  font-weight: normal;
}

/* Glitch Effect */
h1::before,
h1::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--color-background-panel);
  overflow: hidden;
  clip-path: inset(50% 50% 50% 50%);
}

h1::before {
  left: 2px;
  text-shadow: -2px 0 var(--color-text-bright);
  animation: glitch-anim-1 2s infinite linear alternate-reverse;
}

h1::after {
  left: -2px;
  text-shadow: -2px 0 var(--color-primary), 2px 2px var(--color-text-bright);
  animation: glitch-anim-2 2s infinite linear alternate-reverse;
}

@keyframes glitch-anim-1 {
  0% { clip-path: inset(40% 0 40% 0); }
  20% { clip-path: inset(10% 0 85% 0); }
  40% { clip-path: inset(50% 0 30% 0); }
  60% { clip-path: inset(70% 0 10% 0); }
  80% { clip-path: inset(90% 0 5% 0); }
  100% { clip-path: inset(40% 0 40% 0); }
}

@keyframes glitch-anim-2 {
  0% { clip-path: inset(60% 0 10% 0); }
  20% { clip-path: inset(90% 0 5% 0); }
  40% { clip-path: inset(30% 0 50% 0); }
  60% { clip-path: inset(10% 0 70% 0); }
  80% { clip-path: inset(5% 0 90% 0); }
  100% { clip-path: inset(60% 0 10% 0); }
}

#action-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 0.5rem 1rem 1rem 1rem;
  border-bottom: 1px dashed var(--color-primary-dark);
  flex-shrink: 0;
}

.cta-button {
  border: 1px solid var(--color-primary);
  padding: 0.5rem 1.5rem;
  color: var(--color-primary);
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  background-color: transparent;
  cursor: pointer;
  transition: all 0.3s ease;
}

.cta-button:hover,
.cta-button:focus {
  background-color: var(--color-primary);
  color: var(--color-text-bright);
  box-shadow: 0 0 10px var(--color-primary);
  text-decoration: none;
}

.cta-button.disabled {
  pointer-events: none;
  opacity: 0.4;
  border-color: var(--color-primary-dark);
  color: var(--color-primary-dark);
  cursor: not-allowed;
}

.cta-button.disabled:hover,
.cta-button.disabled:focus {
  background-color: transparent;
  box-shadow: none;
  color: var(--color-primary-dark);
}

#devout-log {
  padding: 1rem;
  border-bottom: 1px dashed var(--color-primary-dark);
  text-align: center;
  flex-shrink: 0;
}

#devout-log h3 {
  color: var(--color-primary);
  font-size: 1.1rem;
  letter-spacing: 2px;
  margin-bottom: 0.75rem;
  font-weight: normal;
}

#devout-log p {
  color: var(--color-text-main);
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

#devout-log ul {
  list-style-type: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  font-size: 1rem;
  color: var(--color-text-main);
  opacity: 0.8;
}

#devout-log li {
  animation: fadeInEntry 0.5s ease-in;
}

#devout-log li.user-entry {
    color: var(--color-text-bright);
    font-weight: bold;
    text-shadow: 0 0 5px var(--color-primary);
}


@keyframes fadeInEntry {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  overflow-y: hidden;
}

#chat-history {
  flex-grow: 1;
  overflow-y: auto;
  padding-right: 1rem;
  margin-bottom: 1rem;
}

#chat-history::-webkit-scrollbar {
    width: 8px;
}
#chat-history::-webkit-scrollbar-track {
    background: var(--color-primary-dark);
}
#chat-history::-webkit-scrollbar-thumb {
    background-color: var(--color-primary);
    border-radius: 0;
    border: none;
}

.message {
  margin-bottom: 1rem;
  max-width: 80%;
  padding: 0.75rem;
  border-radius: 0px;
  line-height: 1.5;
  font-family: var(--font-body);
  word-wrap: break-word;
}

.message.user {
  background-color: var(--color-primary);
  color: var(--color-text-bright);
  margin-left: auto;
  text-align: right;
  font-weight: bold;
}

.message.model {
  background-color: transparent;
  color: var(--color-text-main);
  border: 1px solid var(--color-primary);
  margin-right: auto;
  white-space: pre-wrap;
}

#chat-form {
  display: flex;
  flex-shrink: 0;
}

#chat-input {
  flex-grow: 1;
  background-color: transparent;
  border: 1px solid var(--color-primary);
  color: var(--color-text-bright);
  padding: 0.75rem;
  font-family: var(--font-body);
  font-size: 1.2rem;
}

#chat-input:focus {
  outline: none;
  box-shadow: 0 0 10px var(--color-primary);
}

#chat-form button {
  background-color: var(--color-primary);
  color: var(--color-background-main);
  border: none;
  padding: 0.75rem 1.5rem;
  font-family: var(--font-body);
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.3s, color 0.3s;
}

#chat-form button:hover,
#chat-form button:focus {
  background-color: var(--color-text-bright);
  color: var(--color-primary);
  animation: button-glitch-2 0.3s steps(2, end) infinite;
}

@keyframes button-glitch-2 {
    0% { transform: translate(0); }
    10% { transform: translate(-2px, 2px); }
    30% { transform: translate(2px, -2px); }
    50% { transform: translate(-1px, 1px); }
    70% { transform: translate(1px, -1px); }
    90% { transform: translate(-2px, -1px); }
    100% { transform: translate(0); }
}


/* Sippy Terminal */
.sippy-terminal {
  flex-shrink: 0;
  background-color: rgba(0,0,0,0.5);
  border-top: 1px solid var(--color-primary);
  padding: 0.5rem 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  height: 150px;
  display: flex;
  flex-direction: column;
}

#sippy-terminal-output {
  color: var(--color-text-main);
  white-space: pre-wrap;
  flex-grow: 1;
  overflow-y: auto;
  margin-bottom: 0.5rem;
}

#sippy-terminal-output p {
    margin: 0 0 0.25rem 0;
}

.terminal-prompt {
  display: flex;
  align-items: center;
}

.terminal-prompt span {
  color: var(--color-primary);
  margin-right: 0.5rem;
}

#sippy-terminal-input {
  background: transparent;
  border: none;
  color: var(--color-text-bright);
  font-family: var(--font-body);
  font-size: 1rem;
  width: 100%;
  caret-color: var(--color-primary);
}

#sippy-terminal-input:focus {
  outline: none;
}

/* Modal */
.modal {
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.8);
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal[hidden] {
  display: none;
}

.modal-content {
  background-color: #100508;
  padding: 2rem;
  border: 2px solid var(--color-primary);
  box-shadow: 0 0 20px var(--color-primary);
  width: 80%;
  max-width: 500px;
  position: relative;
  text-align: left;
}

.modal-content h2 {
  font-family: var(--font-serif);
  color: var(--color-primary);
  margin-bottom: 1rem;
  font-size: 2rem;
  text-align: center;
}

.modal-content p {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}
.modal-content strong {
    color: var(--color-primary);
    font-weight: normal;
}

.close-button {
  color: var(--color-primary);
  position: absolute;
  top: 10px;
  right: 25px;
  font-size: 35px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.3s, text-shadow 0.3s;
}

.close-button:hover,
.close-button:focus {
  color: var(--color-text-bright);
  text-decoration: none;
  text-shadow: 0 0 8px var(--color-primary), 0 0 25px var(--color-primary);
}