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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

#screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.05s;
}

#screen .icon {
  font-size: 80vmin;
  line-height: 1;
  text-align: center;
}

#screen .text {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 900;
  text-align: center;
  padding: 5vw;
  word-break: break-word;
}

/* ---------- CLI scrolling text effect ---------- */
.fx-cli {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;
  font-size: clamp(0.9rem, 4.2vw, 1.6rem);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 6vw 5vw;
  width: 100%;
  box-sizing: border-box;
}

/* ---------- Braille-art kraken (boot hero + KRAKEN effect) ---------- */
.kraken-art-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  animation: kraken-glitch 9s infinite steps(1);
}

.kraken-art-wrap.boot {
  width: 100%;
  margin: 0.3em 0 0.5em;
  padding: 0.2em 0;
}

.kraken-art-wrap.full {
  width: 100%;
  height: 100%;
}

.kraken-art {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;
  font-size: clamp(3px, 1.05vmin, 9px);
  line-height: 1;
  letter-spacing: 0;
  white-space: pre;
  color: #ff6a1a;
  margin: 0;
  padding: 0;
  display: inline-block;
  transform-origin: center top;
  filter: drop-shadow(0 0 10px rgba(255, 80, 20, 0.55));
  animation:
    kraken-breathe 4.8s ease-in-out infinite,
    kraken-reveal 1.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.kraken-art-wrap.boot .kraken-art {
  font-size: clamp(2.5px, 0.85vmin, 6px);
}

.kraken-art-wrap::after {
  /* scanner-bar sweep overlay */
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 14%;
  top: -14%;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(255, 210, 120, 0.0) 20%,
    rgba(255, 220, 140, 0.35) 50%,
    rgba(255, 210, 120, 0.0) 80%,
    transparent 100%
  );
  mix-blend-mode: screen;
  animation: kraken-scanner 3.6s linear infinite;
  filter: blur(1px);
}

@keyframes kraken-breathe {
  0%, 100% {
    transform: translateY(0) scale(1);
    filter: drop-shadow(0 0 8px rgba(255, 70, 10, 0.5));
  }
  50% {
    transform: translateY(-0.3vmin) scale(1.012);
    filter: drop-shadow(0 0 22px rgba(255, 110, 20, 0.95));
  }
}

@keyframes kraken-reveal {
  0%   { clip-path: inset(0 0 100% 0); opacity: 0.2; }
  60%  { opacity: 1; }
  100% { clip-path: inset(0 0 0% 0); opacity: 1; }
}

@keyframes kraken-scanner {
  0%   { top: -14%; }
  100% { top: 100%; }
}

@keyframes kraken-glitch {
  0%, 92%, 100% { transform: translate(0, 0) skewX(0deg); }
  93%           { transform: translate(-2px, 0) skewX(0.6deg); }
  94%           { transform: translate(2px, -1px) skewX(-0.6deg); }
  95%           { transform: translate(-1px, 1px) skewX(0deg); }
  96%           { transform: translate(0, 0) skewX(0deg); }
}

/* ---------- Matrix rain ---------- */
.fx-matrix {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- Glitch text ---------- */
.fx-glitch {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: clamp(2rem, 9vw, 7rem);
  font-weight: 900;
  letter-spacing: 0.05em;
  text-align: center;
  padding: 4vw 2vw;
  position: relative;
  line-height: 1.1;
  text-shadow: 0 0 16px var(--fx-glitch-color, #ff2a00);
  animation: glitch-skew 3.2s infinite steps(1);
}

.fx-glitch::before,
.fx-glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 4vw 2vw auto 2vw;
  width: calc(100% - 4vw);
  text-align: center;
  pointer-events: none;
}

.fx-glitch::before {
  color: #ff00c8;
  mix-blend-mode: screen;
  animation: glitch-a 2.4s infinite linear alternate-reverse;
  clip-path: polygon(0 0, 100% 0, 100% 48%, 0 48%);
}

.fx-glitch::after {
  color: #00e5ff;
  mix-blend-mode: screen;
  animation: glitch-b 2.1s infinite linear alternate-reverse;
  clip-path: polygon(0 52%, 100% 52%, 100% 100%, 0 100%);
}

@keyframes glitch-a {
  0%, 100% { transform: translate(0, 0); }
  20%      { transform: translate(-3px, -1px); }
  40%      { transform: translate(2px,  1px); }
  60%      { transform: translate(-2px, 1px); }
  80%      { transform: translate(3px, -1px); }
}
@keyframes glitch-b {
  0%, 100% { transform: translate(0, 0); }
  20%      { transform: translate(3px, 1px); }
  40%      { transform: translate(-2px, -2px); }
  60%      { transform: translate(2px, -1px); }
  80%      { transform: translate(-3px, 2px); }
}
@keyframes glitch-skew {
  0%, 85%, 100% { transform: skew(0deg); }
  88%           { transform: skew(1.2deg); }
  91%           { transform: skew(-0.8deg); }
  94%           { transform: skew(0.6deg); }
}

/* Tap-to-join overlay */
#overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: pointer;
}

#overlay.hidden {
  display: none;
}

/* ---------- CLI / terminal aesthetic (Wrath of the Kraken) ---------- */
#overlay {
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255, 80, 20, 0.22), transparent 65%),
    radial-gradient(ellipse at 50% 80%, rgba(180, 30, 10, 0.15), transparent 70%),
    #0a0200;
}

#overlay::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 90, 30, 0.045) 0px,
    rgba(255, 90, 30, 0.045) 1px,
    transparent 1px,
    transparent 3px
  );
  z-index: 1;
  mix-blend-mode: screen;
}

.overlay-content.terminal {
  position: relative;
  z-index: 2;
  width: min(92vw, 560px);
  background: rgba(18, 4, 0, 0.82);
  border: 1px solid rgba(255, 90, 30, 0.45);
  border-radius: 6px;
  box-shadow:
    0 0 0 1px rgba(255, 90, 30, 0.1),
    0 0 50px rgba(255, 70, 20, 0.28),
    inset 0 0 80px rgba(255, 60, 10, 0.06);
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;
  color: #ff9a5a;
  text-shadow: 0 0 6px rgba(255, 120, 40, 0.6);
  overflow: hidden;
}

.term-header {
  display: flex;
  align-items: center;
  gap: 0.75em;
  padding: 0.55em 0.9em;
  background: rgba(255, 90, 30, 0.1);
  border-bottom: 1px solid rgba(255, 90, 30, 0.3);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
}

.term-dots {
  display: inline-flex;
  gap: 5px;
}
.term-dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 90, 30, 0.3);
  border: 1px solid rgba(255, 90, 30, 0.55);
}
.term-dots i:nth-child(1) { background: rgba(255, 80, 80, 0.55); border-color: rgba(255, 80, 80, 0.8); }
.term-dots i:nth-child(2) { background: rgba(255, 200, 60, 0.55); border-color: rgba(255, 200, 60, 0.8); }
.term-dots i:nth-child(3) { background: rgba(60, 255, 120, 0.55); border-color: rgba(60, 255, 120, 0.8); }

.term-title {
  flex: 1;
  text-align: center;
  opacity: 0.85;
}

.term-blink {
  font-size: 0.65rem;
  padding: 0.1em 0.5em;
  border: 1px solid rgba(255, 80, 80, 0.6);
  color: #ff5a5a;
  border-radius: 3px;
  animation: recblink 1.4s steps(2, start) infinite;
  text-shadow: 0 0 4px rgba(255, 80, 80, 0.7);
}

@keyframes recblink {
  50% { opacity: 0.25; }
}

.term-body {
  padding: 1.4em 1.2em 1.2em;
}

.hero-preline {
  text-align: center;
  font-size: 0.68rem;
  letter-spacing: 0.35em;
  color: rgba(255, 180, 100, 0.7);
  margin-bottom: 0.3em;
}

.hero-hyperdome {
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: clamp(1.3rem, 5.5vw, 2rem);
  font-weight: 900;
  letter-spacing: 0.3em;
  color: #ffd7a8;
  text-shadow:
    0 0 10px rgba(255, 140, 40, 0.9),
    0 0 28px rgba(255, 70, 10, 0.55);
  margin-bottom: 0.25em;
}

.logo {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: clamp(3rem, 14vw, 6.2rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: center;
  margin: 0.1em 0 0.2em;
  background: linear-gradient(180deg, #ffe08a 0%, #ff8a1a 45%, #ff2a00 80%, #7a0a00 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 22px rgba(255, 80, 10, 0.6));
  animation: logo-glitch 4.5s infinite;
}

@keyframes logo-glitch {
  0%, 92%, 100% { transform: translate(0, 0); filter: drop-shadow(0 0 22px rgba(255, 80, 10, 0.6)); }
  93%           { transform: translate(-1px, 0); filter: drop-shadow(2px 0 0 rgba(255, 0, 0, 0.7)) drop-shadow(-2px 0 0 rgba(255, 180, 40, 0.7)); }
  94%           { transform: translate(1px, -1px); }
  95%           { transform: translate(-1px, 1px); }
  96%           { transform: translate(0, 0); }
}

.hero-tagline {
  text-align: center;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  color: #ffb070;
  text-shadow: 0 0 8px rgba(255, 120, 30, 0.7);
  margin-bottom: 0.4em;
}

.hero-meta {
  text-align: center;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: rgba(255, 180, 120, 0.75);
  margin-bottom: 1em;
  padding-bottom: 0.8em;
  border-bottom: 1px dashed rgba(255, 90, 30, 0.3);
}

.boot-log {
  font-family: inherit;
  font-size: 0.78rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 7.5em;
  margin: 0 0 0.8em;
  opacity: 0.9;
}

.prompt {
  display: flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  margin-top: 0.3em;
}

.prompt-arrow { color: #ffb070; }
.prompt-text { flex: 0 0 auto; }

.cursor {
  display: inline-block;
  width: 0.55em;
  color: #ff8a1a;
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.permission-note {
  margin-top: 1.1em;
  padding: 0.7em 0.9em;
  border: 1px dashed rgba(255, 200, 60, 0.55);
  background: rgba(255, 200, 60, 0.05);
  color: #ffcf5a;
  text-shadow: 0 0 5px rgba(255, 200, 60, 0.45);
  font-size: 0.72rem;
  line-height: 1.55;
  letter-spacing: 0.03em;
}

.warn-line { font-weight: 700; }
.warn-sub  { opacity: 0.75; margin-top: 0.2em; }

@media (max-width: 380px) {
  .boot-log { font-size: 0.7rem; min-height: 8em; }
  .prompt { font-size: 0.8rem; }
  .permission-note { font-size: 0.68rem; }
}

/* Connection status indicator */
#status {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 50;
  pointer-events: none;
}

#status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #444;
  transition: background 0.3s;
}

#status-dot.connected {
  background: #22c55e;
}

#status-dot.disconnected {
  background: #ef4444;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
