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

:root {
  --text-main: #fff8e0;
  --text-dim: #c8b8a0;
  --panel-bg: rgba(48, 32, 72, 0.92);
  --panel-bg-2: rgba(62, 46, 92, 0.92);
  --panel-border: #2a1810;
  --panel-accent: #f0a830;
  --panel-shadow: rgba(0, 0, 0, 0.5);
  --accent-dino: #58b848;
  --accent-peluche: #f0a830;
  --sky-blue: #5a7ec0;
  --sky-purple: #8b70b8;
  --dirt-brown: #6b4028;
  --grass-green: #48a838;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--text-main);
  font-family: 'Press Start 2P', 'Courier New', monospace;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: #1a0e28;
  image-rendering: pixelated;
}

#gameCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.panel {
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.04) 0 2px,
      transparent 2px 4px
    ),
    linear-gradient(180deg, var(--panel-bg-2), var(--panel-bg));
  border: 4px solid var(--panel-border);
  outline: 3px solid var(--panel-accent);
  outline-offset: -1px;
  box-shadow:
    inset 0 0 0 2px rgba(240, 168, 48, 0.12),
    6px 6px 0 0 rgba(0, 0, 0, 0.4);
}

/* ── Join Screen ── */

#joinScreen {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 460px);
  padding: 24px 20px;
  text-align: center;
  pointer-events: auto;
}

#joinScreen.hidden {
  display: none;
}

#joinScreen h1 {
  margin: 0 0 8px;
  font-size: clamp(14px, 3vw, 22px);
  color: #ffd060;
  text-shadow:
    3px 3px 0 #2a1810,
    -1px -1px 0 #2a1810;
  line-height: 1.4;
}

#joinScreen p {
  margin: 8px 0;
  font-size: 9px;
  color: var(--text-dim);
  line-height: 1.5;
}

.char-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.char-btn {
  border: 4px solid var(--panel-border);
  outline: 3px solid var(--panel-accent);
  outline-offset: -2px;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.06) 0 2px,
      transparent 2px 4px
    ),
    linear-gradient(180deg, #5a8e40, #3a6828);
  color: #fff8d0;
  padding: 14px 10px;
  cursor: pointer;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  font-weight: 400;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6);
  box-shadow:
    0 4px 0 #264018,
    0 6px 0 rgba(0, 0, 0, 0.3);
  transition: transform 80ms ease;
  text-transform: uppercase;
  line-height: 1.4;
}

.char-btn:hover:not(:disabled) {
  transform: translateY(2px);
  box-shadow:
    0 2px 0 #264018,
    0 3px 0 rgba(0, 0, 0, 0.3);
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.08) 0 2px,
      transparent 2px 4px
    ),
    linear-gradient(180deg, #68a050, #488030);
}

.char-btn:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0.3);
}

.char-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.5) brightness(0.7);
}

#joinStatus {
  min-height: 24px;
  margin-top: 12px;
  color: #a0d8f0;
  font-size: 8px;
  line-height: 1.5;
}

/* ── HUD ── */

#hud {
  position: absolute;
  left: 12px;
  top: 12px;
  width: min(420px, calc(100vw - 24px));
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.03) 0 2px,
      transparent 2px 4px
    ),
    linear-gradient(180deg, rgba(52, 36, 78, 0.92), rgba(36, 22, 56, 0.92));
  border: 4px solid var(--panel-border);
  outline: 3px solid var(--sky-purple);
  outline-offset: -1px;
  box-shadow: 4px 4px 0 var(--panel-shadow);
}

.hp-row {
  display: grid;
  grid-template-columns: 80px 1fr 42px;
  gap: 8px;
  align-items: center;
  font-size: 8px;
  font-weight: 400;
}

.hp-track {
  width: 100%;
  height: 16px;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.08) 0 8px,
      rgba(255, 255, 255, 0.02) 8px 16px
    ),
    rgba(0, 0, 0, 0.4);
  border: 3px solid var(--panel-border);
  box-shadow: inset 0 0 0 1px rgba(139, 112, 184, 0.3);
  overflow: hidden;
}

.hp-fill {
  height: 100%;
  width: 100%;
  background:
    repeating-linear-gradient(
      90deg,
      #48b838 0 8px,
      #60d050 8px 16px
    );
  transition: width 120ms linear;
  image-rendering: pixelated;
}

.hp-fill.peluche {
  background:
    repeating-linear-gradient(
      90deg,
      #d08830 0 8px,
      #f0a840 8px 16px
    );
}

/* ── Controls Help ── */

#controlsHelp {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: min(300px, calc(100vw - 24px));
  padding: 12px 14px;
  font-size: 8px;
  line-height: 1.8;
}

#controlsHelp strong {
  display: inline-block;
  margin-bottom: 6px;
  color: #ffd060;
  font-size: 9px;
  text-shadow: 2px 2px 0 #2a1810;
}

#controlsHelp p {
  margin: 4px 0;
  color: var(--text-dim);
}

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 6px;
  border: 3px solid var(--panel-border);
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.06) 0 2px,
      transparent 2px 4px
    ),
    linear-gradient(180deg, #6b4830, #4a3020);
  color: #ffd860;
  font-family: 'Press Start 2P', monospace;
  font-weight: 400;
  font-size: 7px;
  text-align: center;
  text-transform: none;
  box-shadow: 0 2px 0 #2a1810;
}

/* ── Chat Input ── */

#chatInputWrap {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: min(600px, calc(100vw - 24px));
  padding: 10px 12px;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

#chatInputWrap.hidden {
  display: none;
}

#chatInputWrap label {
  color: #ffd060;
  font-size: 9px;
}

#chatInputWrap input {
  flex: 1;
  min-width: 0;
  border: 4px solid var(--panel-border);
  outline: 3px solid var(--sky-purple);
  outline-offset: -1px;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.05) 0 2px,
      transparent 2px 4px
    ),
    rgba(24, 14, 40, 0.94);
  color: #fff8d0;
  padding: 8px 10px;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  text-transform: none;
}

#chatInputWrap input::placeholder {
  color: #8878a0;
  text-transform: none;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
}

/* ── Responsive ── */

@media (max-width: 720px) {
  .char-grid {
    grid-template-columns: 1fr;
  }

  #controlsHelp,
  #hud {
    width: calc(100vw - 24px);
  }

  #controlsHelp {
    bottom: 10px;
  }
}
