* { box-sizing: border-box; }

html,
body {
  height: 100%;
  min-height: 100vh;
  margin: 0;
  font-family: 'Courier New', Courier, monospace;
  background-color: #001500;
  background: radial-gradient(circle at 20% 20%, rgba(4, 13, 4, 0.55) 0, rgb(0, 22, 0) 42%, #010 78%, #000 100%);
  color: #ebcf82;
}

body {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
}

.container {
  position: relative;
  width: min(960px, 100%);
  min-height: min(760px, 95vh);
  background: rgba(0, 12, 0, 0.9);
  border-radius: 18px;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border: 1px solid rgba(107, 255, 149, 0.22);
  box-shadow:
    0 0 40px rgba(40, 255, 145, 0.12),
    inset 0 0 60px rgba(12, 60, 20, 0.4),
    inset 0 0 6px rgba(180, 255, 200, 0.08);
  overflow: hidden;
}

  .container::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(180, 255, 190, 0.035) 0,
    rgba(180, 255, 190, 0.035) 2px,
    transparent 2px,
    transparent 4px
  );
  mix-blend-mode: screen;
  opacity: 0.22;
}

.container::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at top left, rgba(38, 255, 149, 0.16), transparent 60%),
    radial-gradient(circle at bottom right, rgba(10, 120, 60, 0.25), transparent 65%);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  text-transform: uppercase;
  letter-spacing: 0.16rem;
  color: #91e6a9;
}

.status-panel {
  display: flex;
  align-items: center;
  gap: 18px;
}

.scoreboard {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 400;
  text-shadow: 0 0 6px rgba(145, 230, 167, 0.35);
  text-transform: none;
}

.battery {
  font-size: 1.25rem;
  letter-spacing: 0.12rem;
  text-transform: none;
  color: #e6c28d;
  text-shadow: 0 0 5px rgba(160, 255, 200, 0.35);
}

main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 16px 18px 22px;
  background: linear-gradient(180deg, rgba(6, 18, 6, 0.6) 0%, rgba(0, 0, 0, 0.4) 100%);
  border: 1px solid rgba(108, 255, 112, 0.15);
  box-shadow: inset 0 0 18px rgba(12, 70, 24, 0.4);
}

#messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: #f1dda0;
  font-size: 1.05rem;
  line-height: 1.45;
  letter-spacing: 0.06em;
}

#messages::-webkit-scrollbar {
  width: 10px;
}

#messages::-webkit-scrollbar-track {
  background: rgba(0, 20, 0, 0.4);
}

#messages::-webkit-scrollbar-thumb {
  background: rgba(140, 255, 168, 0.35);
  border-radius: 8px;
}

.msg {
  position: relative;
  width: 100%;
  padding-left: 85px;
  white-space: pre-wrap;
  text-shadow: 0 0 2px rgba(240, 255, 170, 0.35);
}

.msg::before {
  position: absolute;
  left: 0;
  width: 72px;
  color: #6cffb8;
  text-shadow: 0 0 4px rgba(124, 255, 196, 0.5);
  opacity: 0.8;
}

.msg.user {
  color: #84c8f0;
  text-shadow: 0 0 3px rgba(118, 219, 255, 0.45);
}

.msg.user::before {
  content: 'DU>';
  color: #55bfee;
  text-shadow: 0 0 3px rgba(89, 208, 255, 0.5);
}

.msg.assistant {
  color: #f1dda0;
  text-shadow: 0 0 2px rgba(248, 226, 137, 0.38);
}

.msg.assistant::before {
  content: 'OKÄND>';
  text-shadow: 0 0 3px rgba(124, 255, 196, 0.42);
}

.msg.system {
  color: #91e6a9;
  text-shadow: 0 0 4px rgba(157, 251, 179, 0.4);
}

.msg.system::before {
  content: 'SYSTEM>';
  color: #73ff9d;
  text-shadow: 0 0 4px rgba(124, 255, 196, 0.45);
}

.msg.error::before {
  content: 'ERROR>';
  color: #ff6b6b;
  text-shadow: 0 0 5px rgba(255, 80, 80, 0.6);
}

.msg.error {
  color: #ffacac;
  text-shadow: 0 0 3px rgba(255, 80, 80, 0.5);
}

.msg.assistant.pending::after {
  content: '█';
  margin-left: 10px;
  display: inline-block;
  animation: cursor-blink 0.9s steps(1, end) infinite;
  color: inherit;
  text-shadow: 0 0 3px rgba(255, 245, 200, 0.55);
}

@keyframes cursor-blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

form {
  display: flex;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(90, 200, 120, 0.25);
}

form.disabled {
  opacity: 0.55;
}

form.disabled input,
form.disabled button {
  cursor: not-allowed;
}

input {
  flex: 1;
  padding: 12px 14px;
  background: rgba(0, 28, 0, 0.75);
  border: 1px solid rgba(116, 255, 164, 0.4);
  color: #f3f7c0;
  border-radius: 4px;
  font-size: 1rem;
  letter-spacing: 0.08em;
  caret-color: #b8ff9c;
  text-shadow: 0 0 2px rgba(200, 255, 170, 0.35);
}

input::placeholder {
  color: rgba(180, 220, 180, 0.25);
}

input:focus {
  outline: 2px solid rgba(188, 255, 200, 0.4);
  box-shadow: 0 0 16px rgba(135, 255, 155, 0.2);
}

button {
  padding: 12px 20px;
  border: 1px solid rgba(116, 255, 164, 0.6);
  background: rgba(0, 40, 0, 0.6);
  color: #a7ffcb;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  border-radius: 4px;
  cursor: pointer;
  transition: box-shadow 0.2s ease, background 0.2s ease;
  text-shadow: 0 0 6px rgba(160, 255, 200, 0.7);
}

button:hover {
  background: rgba(0, 60, 0, 0.8);
  box-shadow: 0 0 16px rgba(132, 255, 164, 0.35);
}

button:active {
  transform: translateY(1px);
  box-shadow: inset 0 0 12px rgba(132, 255, 164, 0.4);
}

button:disabled {
  opacity: 0.6;
  box-shadow: none;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  body {
    padding: 16px;
    align-items: stretch;
    justify-content: flex-start;
  }

  .container {
    width: 100%;
    min-height: calc(100vh - 32px);
    padding: 20px 18px;
    gap: 16px;
    border-color: rgba(107, 255, 149, 0.08);
    box-shadow:
      0 0 26px rgba(40, 255, 145, 0.12),
      inset 0 0 34px rgba(12, 60, 20, 0.28),
      inset 0 0 4px rgba(180, 255, 200, 0.06);
  }

  header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  #new-session {
    order: -1;
  }

  .status-panel {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .scoreboard {
    font-size: 1.1rem;
    letter-spacing: 0.12rem;
  }

  .battery {
    font-size: 1.05rem;
    letter-spacing: 0.1rem;
  }

  header button {
    width: 100%;
    padding: 14px;
    font-size: 0.85rem;
    letter-spacing: 0.16em;
  }

  main {
    padding: 12px 14px 16px;
    background: linear-gradient(180deg, rgba(6, 18, 6, 0.48) 0%, rgba(0, 0, 0, 0.32) 100%);
    border: 1px solid rgba(108, 255, 112, 0.05);
    box-shadow: inset 0 0 10px rgba(12, 70, 24, 0.26);
  }

  #messages {
    gap: 10px;
    font-size: 0.97rem;
  }

  .msg {
    padding-left: 62px;
  }

  .msg::before {
    width: 46px;
  }

  form {
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(90, 200, 120, 0.12);
  }

  input {
    padding: 12px;
  }

  form button {
    width: 100%;
    padding: 14px;
    font-size: 0.85rem;
    letter-spacing: 0.16em;
  }
}
