/* LIVEL — retro handheld styling */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

:root {
  --gb-darkest: #0f380f;
  --gb-dark: #306230;
  --gb-light: #8bac0f;
  --gb-lightest: #9bbc0f;
  --shell: #c9c0b8;
  --shell-dark: #a49a90;
  --accent: #7b4fa3;
}

body {
  background: #1a1420;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Press Start 2P', monospace;
  color: var(--gb-darkest);
  padding: 12px;
}

.crt { position: relative; }
.crt::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.08) 0 1px, transparent 1px 3px);
  border-radius: 18px;
}

.shell {
  background: var(--shell);
  border: 4px solid var(--shell-dark);
  border-radius: 18px 18px 40px 18px;
  padding: 14px;
  width: 340px;
  box-shadow: 0 12px 40px rgba(0,0,0,.6), inset 0 2px 0 #fff5;
}

.shell-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.logo { font-size: 14px; color: var(--accent); letter-spacing: 2px; }
.logo-dot { color: #d33; animation: blink 2s infinite; }
@keyframes blink { 0%,90% {opacity:1} 95% {opacity:.2} }

.key-btn {
  font-family: inherit; font-size: 8px;
  background: #e0a020; color: #3a2800;
  border: 0; border-bottom: 3px solid #8a6210;
  border-radius: 6px; padding: 6px 8px; cursor: pointer;
  animation: pulse 2.5s infinite;
}
.key-btn.has-key { animation: none; background: #7fbf6a; border-bottom-color: #4a7a3a; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 #e0a02088; } 50% { box-shadow: 0 0 0 6px #e0a02000; } }
.key-status { min-height: 12px; }
.key-status.ok { color: #2f7a3a; }
.key-status.bad { color: #b3392f; }

.tiny-btn {
  font-family: inherit; font-size: 12px;
  background: var(--shell-dark); border: 2px solid #877d73;
  border-radius: 6px; padding: 4px 8px; cursor: pointer;
}

.screen-frame {
  position: relative;
  background: #3a3a4a;
  border-radius: 8px;
  padding: 10px;
}
#screen {
  display: block;
  width: 100%;
  image-rendering: pixelated;
  background: var(--gb-lightest);
  border-radius: 4px;
}

.speech {
  position: absolute;
  left: 14px; right: 14px; top: 14px;
  background: var(--gb-lightest);
  border: 3px solid var(--gb-darkest);
  padding: 8px;
  font-size: 8px;
  line-height: 1.6;
  color: var(--gb-darkest);
  border-radius: 4px;
}
.hidden { display: none !important; }

.stats { margin-top: 10px; display: grid; gap: 4px; }
.stat { display: flex; align-items: center; gap: 6px; }
.stat label { font-size: 7px; width: 62px; }
.bar {
  flex: 1; height: 10px;
  background: #8a8178;
  border: 2px solid #6f665d;
  border-radius: 3px; overflow: hidden;
}
.fill { height: 100%; width: 50%; background: var(--gb-dark); transition: width .5s; }
.fill.low { background: #b3392f; }
.fill.warn.high { background: #b3392f; }

.buttons { margin-top: 10px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pixel-btn {
  font-family: inherit; font-size: 8px;
  padding: 8px 4px;
  background: var(--accent); color: #fff;
  border: 0; border-bottom: 4px solid #4d2f6b;
  border-radius: 6px; cursor: pointer;
}
.pixel-btn:active { border-bottom-width: 1px; transform: translateY(3px); }
.pixel-btn:disabled { background: #948a9e; border-bottom-color: #6f6678; cursor: not-allowed; }
.pixel-btn.danger { background: #b3392f; border-bottom-color: #6e211b; }

.chatbox { margin-top: 8px; display: flex; gap: 6px; }
.chatbox input {
  flex: 1; font-family: inherit; font-size: 8px;
  padding: 8px; border: 2px solid var(--shell-dark); border-radius: 6px;
  background: #efe9e2;
}

.log {
  margin-top: 8px;
  background: #221a2b;
  color: #b8e6b8;
  font-size: 7px;
  line-height: 1.9;
  height: 84px;
  overflow-y: auto;
  padding: 6px 8px;
  border-radius: 6px;
}
.log .you { color: #e6cdb8; }
.log .sys { color: #8a7fa0; }

.footer {
  margin-top: 8px;
  display: flex; justify-content: space-between;
  font-size: 7px; color: #57504a;
}
.brain-off { color: #b3392f; }
.brain-on { color: #2f7a3a; }

.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
}
.modal-inner {
  background: var(--shell);
  border: 4px solid var(--shell-dark);
  border-radius: 12px;
  padding: 18px;
  width: 320px;
}
.modal-inner h2 { font-size: 12px; margin-bottom: 10px; }
.modal-inner .small { font-size: 7px; line-height: 1.8; margin-bottom: 10px; }
.modal-inner input {
  width: 100%; font-family: inherit; font-size: 8px;
  padding: 8px; border: 2px solid var(--shell-dark); border-radius: 6px;
  margin-bottom: 10px;
}
.modal-row { display: flex; gap: 8px; }
.modal-inner hr { margin: 12px 0; border: 1px solid var(--shell-dark); }
.danger-zone { color: #b3392f; }
