﻿.quest-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto 48px;
}

.quest-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin: 26px 0 22px;
  padding: 28px;
  border: 3px solid #ffffff;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 88% 22%, #fff4bd 0 34px, transparent 35px),
    linear-gradient(45deg, rgba(216, 220, 255, 0.32) 25%, transparent 25% 75%, rgba(216, 220, 255, 0.32) 75%),
    #fffefe;
  background-size: auto, 34px 34px, auto;
  box-shadow: 0 0 0 8px #6f86c8, 10px 10px 0 rgba(111, 134, 200, 0.24);
}

.quest-hero h1 {
  margin: 0;
  font-size: clamp(2.2rem, 8vw, 4.8rem);
  line-height: 0.95;
}

.quest-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
  align-items: start;
}

.quest-stage-wrap,
.quest-panel,
.touch-controls {
  border: 3px solid #ffffff;
  border-radius: var(--radius);
  background: #fffefe;
  box-shadow: 0 0 0 7px #9fc8ee, 8px 8px 0 rgba(111, 134, 200, 0.22);
}

.quest-stage-wrap {
  overflow: hidden;
  padding: 12px;
}

#quest-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  height: auto;
  border: 2px solid #6f86c8;
  border-radius: 12px;
  background: #d8dcff;
  image-rendering: auto;
}

.quest-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.quest-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 2px dashed rgba(111, 134, 200, 0.28);
}

.quest-stat-row span,
.quest-controls-copy span {
  color: var(--muted);
  font-weight: 800;
}

.quest-status {
  margin: 0;
  color: var(--text);
  line-height: 1.5;
}

.quest-controls-copy {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  padding: 12px;
  border-radius: 12px;
  background: #fff7fb;
}

.touch-controls {
  display: none;
  grid-template-columns: 1fr auto;
  gap: 18px;
  margin-top: 18px;
  padding: 16px;
}

.touch-dpad {
  display: grid;
  grid-template-columns: repeat(3, minmax(64px, 1fr));
  grid-template-areas:
    ". up ."
    "left down right";
  gap: 10px;
}

.touch-dpad button,
.touch-attack {
  min-height: 56px;
  border: 3px solid #ffffff;
  border-radius: 18px;
  background: #d8dcff;
  color: #52649d;
  font-weight: 900;
  box-shadow: 0 0 0 4px #6f86c8, 4px 4px 0 rgba(111, 134, 200, 0.22);
}

.touch-dpad [data-hold="up"] { grid-area: up; }
.touch-dpad [data-hold="left"] { grid-area: left; }
.touch-dpad [data-hold="down"] { grid-area: down; }
.touch-dpad [data-hold="right"] { grid-area: right; }

.touch-attack {
  width: 78px;
  min-height: 78px;
  align-self: center;
  border-radius: 50%;
  background: #ffb7d3;
  color: #8a3f63;
}

@media (max-width: 860px) {
  .quest-layout {
    grid-template-columns: 1fr;
  }

  .quest-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quest-status,
  .quest-controls-copy,
  #restart-game {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .quest-shell {
    width: min(100% - 24px, 1120px);
  }

  .quest-hero {
    align-items: flex-start;
    flex-direction: column;
    padding: 22px;
  }

  .quest-stage-wrap {
    padding: 8px;
  }

  .quest-panel {
    grid-template-columns: 1fr;
  }

  .touch-controls {
    display: grid;
  }
}

@media (max-width: 420px) {
  .touch-controls {
    grid-template-columns: 1fr;
  }

  .touch-attack {
    justify-self: center;
  }
}
