* {
  box-sizing: border-box;
}

:root {
  --gb0: #0f380f;
  --gb1: #306230;
  --gb2: #8bac0f;
  --gb3: #9bbc0f;

  --shell-light: #d8d8d8;
  --shell-mid: #bdbdbd;
  --shell-dark: #8e8e8e;

  --screen-bg: #9bbc0f;
  --screen-dark: #0f380f;
  --screen-mid: #306230;

  --panel: #dce7ba;
  --panel-light: #eef5d8;
  --shadow: #6a7b38;

  --burn: #8f2f18;
  --sleep: #4a4a7f;

  /* AJUSTES DOS SPRITES */
  --enemy-sprite-base-width: 180px;
  --enemy-sprite-scale: 4.50;
  --enemy-sprite-x: 175px;
  --enemy-sprite-y: 20px;
  --enemy-side-min-height: 320px;
  --enemy-side-width: 360px;

  --player-sprite-base-width: 120px;
  --player-sprite-scale: 4.7;
  --player-sprite-x: -140px;
  --player-sprite-y: 158px;
  --player-sprite-wrap-width: 280px;
  --player-sprite-wrap-height: 240px;

  --battlefield-min-height: 280px;
  --player-row-margin-top: -70px;
  --player-gap: 18px;
  --player-hud-width: 360px;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: linear-gradient(180deg, #9ebc3a 0%, #6f8f10 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  font-family: "Courier New", monospace;
  image-rendering: pixelated;
}

button {
  font: inherit;
}

.device {
  position: relative;
  width: min(100%, 1000px);
  background: linear-gradient(180deg, var(--shell-light), var(--shell-mid));
  border: 8px solid var(--shell-dark);
  border-radius: 18px 18px 52px 18px;
  box-shadow:
    inset 8px 8px 0 #ededed,
    inset -8px -8px 0 #9b9b9b,
    0 20px 40px rgba(0, 0, 0, 0.35);
  padding: 18px 22px 30px;
}

.device-top {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: #3f3f3f;
  margin-bottom: 16px;
  padding-left: 4px;
  flex-wrap: wrap;
}

.brand {
  font-style: italic;
  font-weight: 700;
  font-size: 16px;
}

.model {
  font-weight: 900;
  letter-spacing: 1px;
  font-size: 24px;
}

.sub {
  font-size: 13px;
  font-weight: 700;
  opacity: 0.8;
}

.side-volume {
  position: absolute;
  left: -150px;
  top: 120px;
  width: 130px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #d8d8d8, #bdbdbd);
  border: 4px solid #8e8e8e;
  border-radius: 10px;
  box-shadow:
    inset 3px 3px 0 #ededed,
    inset -3px -3px 0 #9b9b9b,
    0 6px 12px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.volume-label {
  font-size: 12px;
  font-weight: 900;
  color: #3f3f3f;
  letter-spacing: 1px;
  text-align: center;
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: #6f6f6f;
  border: 2px solid #4f4f4f;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: #efefef;
  border: 3px solid #4f4f4f;
  border-radius: 50%;
  cursor: pointer;
}

.volume-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: #efefef;
  border: 3px solid #4f4f4f;
  border-radius: 50%;
  cursor: pointer;
}

.volume-slider::-moz-range-track {
  height: 8px;
  background: #6f6f6f;
  border: 2px solid #4f4f4f;
  border-radius: 999px;
}

.screen-shell {
  background: #555;
  border-radius: 10px;
  padding: 12px 12px 16px;
  position: relative;
  border: 6px solid #666;
}

.power-led {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #b33;
  left: 10px;
  top: 12px;
  box-shadow: 0 0 10px rgba(255, 80, 80, 0.7);
}

.screen-label {
  color: #c7c7c7;
  font-size: 11px;
  letter-spacing: 1px;
  text-align: center;
  margin-bottom: 10px;
  font-weight: 700;
}

.screen {
  background: var(--screen-bg);
  border: 5px solid #2b2b2b;
  min-height: 720px;
  padding: 18px 16px 16px;
  box-shadow: inset 0 0 0 3px #7d8f45;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 18px;
}

/* TOPO */
.battlefield {
  display: grid;
  grid-template-columns: 320px 1fr;
  align-items: start;
  min-height: var(--battlefield-min-height);
  gap: 12px;
}

.enemy-hud {
  width: 320px;
}

.enemy-side {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: var(--enemy-side-min-height);
  width: var(--enemy-side-width);
  overflow: visible;
  padding-top: 6px;
}

.sprite-button {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.sprite-button:disabled {
  cursor: not-allowed;
}

.charmander {
  width: var(--enemy-sprite-base-width);
  max-width: none;
  display: block;
  user-select: none;
  image-rendering: pixelated;
  transform:
    translate(var(--enemy-sprite-x), var(--enemy-sprite-y))
    scale(var(--enemy-sprite-scale));
  transform-origin: center center;
  transition: transform 0.08s ease;
}

.sprite-button:hover .charmander {
  transform:
    translate(var(--enemy-sprite-x), calc(var(--enemy-sprite-y) - 2px))
    scale(calc(var(--enemy-sprite-scale) + 0.04));
}

/* MEIO */
.player-row {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--player-row-margin-top);
}

.player-team-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: var(--player-gap);
  width: 100%;
}

.player-sprite-wrap {
  width: var(--player-sprite-wrap-width);
  min-height: var(--player-sprite-wrap-height);
  display: flex;
  justify-content: center;
  align-items: flex-end;
  overflow: visible;
}

.player-pokemon-img {
  width: var(--player-sprite-base-width);
  max-width: none;
  display: block;
  image-rendering: pixelated;
  transform:
    translate(var(--player-sprite-x), var(--player-sprite-y))
    scale(var(--player-sprite-scale));
  transform-origin: center bottom;
}

.player-hud {
  width: var(--player-hud-width);
}

.charmander.hit,
.player-pokemon-img.hit {
  animation: hitShake 0.28s steps(2);
}

.hud-box {
  background: var(--panel);
  border: 4px solid var(--screen-dark);
  box-shadow: 6px 6px 0 var(--shadow);
  padding: 12px 12px 10px;
  color: var(--screen-dark);
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
  text-transform: uppercase;
  font-weight: 900;
  font-size: 22px;
  line-height: 1.1;
}

.pokemon-name {
  max-width: 190px;
  word-break: break-word;
}

.hp-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hp-label {
  font-size: 18px;
  font-weight: 900;
}

.hp-bar {
  flex: 1;
  height: 16px;
  background: #b5c78b;
  border: 3px solid var(--screen-dark);
  overflow: hidden;
}

.hp-fill {
  width: 100%;
  height: 100%;
  background: var(--screen-mid);
  transition: width 0.25s linear;
}

.hud-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.hp-numbers {
  font-size: 22px;
  font-weight: 900;
}

.status-line {
  font-size: 18px;
  font-weight: 900;
  text-transform: uppercase;
}

.status-line.burn {
  color: var(--burn);
}

.status-line.sleep {
  color: var(--sleep);
}

/* BAIXO */
.bottom-ui {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 14px;
}

.dialog-box,
.menu-box {
  background: var(--panel);
  border: 4px solid var(--screen-dark);
  box-shadow: 6px 6px 0 var(--shadow);
}

.dialog-box {
  padding: 12px;
}

.turn-text {
  font-size: 20px;
  font-weight: 900;
  color: var(--screen-dark);
  margin-bottom: 8px;
  text-transform: uppercase;
}

.message-box {
  min-height: 118px;
  border: 4px solid var(--screen-dark);
  background: var(--panel-light);
  color: var(--screen-dark);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 26px;
  line-height: 1.2;
  font-weight: 700;
}

.arrow {
  flex: 0 0 auto;
}

.message-content {
  display: inline-block;
}

.menu-box {
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-content: start;
}

.menu-btn {
  min-height: 70px;
  background: var(--panel-light);
  border: 4px solid var(--screen-dark);
  color: var(--screen-dark);
  font-size: 22px;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--shadow);
}

.menu-btn:hover:not(:disabled) {
  transform: translate(-1px, -1px);
}

.menu-btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--shadow);
}

.menu-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.device-bottom {
  height: 42px;
  position: relative;
}

.speaker {
  position: absolute;
  width: 120px;
  height: 8px;
  border-radius: 999px;
  background: #7b7b7b;
  bottom: 8px;
}

.speaker-left {
  left: 38px;
  transform: rotate(-18deg);
  box-shadow:
    0 -12px 0 #7b7b7b,
    0 -24px 0 #7b7b7b,
    0 -36px 0 #7b7b7b;
}

@keyframes hitShake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  50% { transform: translateX(10px); }
  75% { transform: translateX(-6px); }
  100% { transform: translateX(0); }
}

@media (max-width: 1100px) {
  .side-volume {
    left: -138px;
    top: 118px;
    width: 120px;
  }
}

@media (max-width: 900px) {
  :root {
    --enemy-sprite-base-width: 120px;
    --enemy-sprite-scale: 1.4;
    --enemy-sprite-x: 0px;
    --enemy-sprite-y: -6px;
    --enemy-side-width: 100%;

    --player-sprite-base-width: 120px;
    --player-sprite-scale: 1.2;
    --player-sprite-x: 0px;
    --player-sprite-y: 0px;
    --player-sprite-wrap-width: 170px;
    --player-sprite-wrap-height: 130px;

    --player-row-margin-top: -20px;
    --player-gap: 12px;
    --player-hud-width: 100%;
  }

  body {
    padding: 12px;
  }

  .device {
    padding: 14px 14px 24px;
  }

  .screen {
    min-height: auto;
    grid-template-rows: auto auto auto;
  }

  .battlefield {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .enemy-hud {
    width: 100%;
  }

  .enemy-side {
    justify-content: center;
  }

  .player-row {
    justify-content: center;
  }

  .player-team-wrap {
    flex-wrap: wrap;
    justify-content: center;
  }

  .bottom-ui {
    grid-template-columns: 1fr;
  }

  .message-box {
    font-size: 22px;
    min-height: 100px;
  }

  .menu-btn {
    font-size: 18px;
    min-height: 58px;
  }

  .hud-top {
    font-size: 20px;
  }

  .hp-numbers,
  .status-line {
    font-size: 16px;
  }

  .side-volume {
    position: static;
    width: 100%;
    flex-direction: row;
    justify-content: center;
    margin-bottom: 12px;
  }

  .volume-slider {
    width: 180px;
    height: 8px;
  }
}