:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #16130e;
  color: #f8efe0;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 12%, rgba(255, 207, 115, 0.14), transparent 28rem),
    linear-gradient(135deg, #17130d, #302516 46%, #0f1413);
}

.shell {
  width: min(100vw, 1220px);
  padding: 16px;
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 800px);
  gap: 18px;
  align-items: start;
  justify-content: center;
  min-height: calc(100vh - 32px);
}

.game-frame {
  display: grid;
  gap: 12px;
  place-items: center;
}

.game-panel {
  width: min(100%, 800px);
}

.hud {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  color: #fff7dc;
}

.hud-item,
.hud-message {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 237, 190, 0.22);
  background: rgba(32, 22, 13, 0.86);
  font-size: 16px;
  line-height: 1.2;
}

.hud-hp {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}

.hp-track {
  display: block;
  height: 14px;
  overflow: hidden;
  background: #4a261d;
}

.hp-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: #55b96d;
}

.hud-message {
  grid-column: 1 / -1;
  color: #ffe4a5;
  text-align: center;
}

#game {
  width: 100%;
  aspect-ratio: 1;
}

#game canvas {
  display: block;
  width: 100% !important;
  height: auto !important;
  border: 1px solid rgba(255, 237, 190, 0.24);
  box-shadow: 0 18px 56px rgba(0, 0, 0, 0.42);
}

#hud-overlay {
  position: fixed;
  inset: 0;
  display: none;
  height: 100dvh;
  pointer-events: none;
  z-index: 100;
  user-select: none;
  -webkit-user-select: none;
}

#dpad {
  position: absolute;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: calc(16px + env(safe-area-inset-left));
  display: grid;
  grid-template-areas:
    ". up ."
    "left center right"
    ". down .";
  place-items: center;
  width: 120px;
  height: 120px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  opacity: 0.65;
  pointer-events: all;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.dpad-arrow {
  color: rgba(255, 255, 255, 0.6);
  font-size: 20px;
  line-height: 1;
  opacity: 0.82;
  transition: color 0.05s, opacity 0.05s, transform 0.05s;
}

.dpad-arrow.active {
  color: #ffffff;
  opacity: 1;
  transform: scale(1.16);
}

#dpad-up {
  grid-area: up;
}

#dpad-left {
  grid-area: left;
}

#dpad-right {
  grid-area: right;
}

#dpad-down {
  grid-area: down;
}

#dpad-center {
  grid-area: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

#btn-attack {
  position: absolute;
  right: calc(24px + env(safe-area-inset-right));
  bottom: calc(24px + env(safe-area-inset-bottom));
  width: 80px;
  height: 80px;
  border: 2px solid rgba(255, 120, 120, 0.5);
  border-radius: 50%;
  background: rgba(220, 80, 80, 0.65);
  color: #ffffff;
  font: inherit;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  pointer-events: all;
  touch-action: none;
  transition: transform 0.08s, background 0.08s;
  -webkit-tap-highlight-color: transparent;
}

#btn-attack.pressed,
#btn-attack:active {
  background: rgba(220, 80, 80, 1);
  transform: scale(0.88);
}

html.has-touch-controls,
body.has-touch-controls {
  overscroll-behavior: none;
}

html.has-touch-controls .shell,
body.has-touch-controls .shell {
  padding-bottom: calc(156px + env(safe-area-inset-bottom));
}

html.has-touch-controls .play-layout,
body.has-touch-controls .play-layout {
  min-height: auto;
}

html.has-touch-controls #hud-overlay,
body.has-touch-controls #hud-overlay {
  display: block;
}

html.has-touch-controls #game,
html.has-touch-controls #game canvas,
body.has-touch-controls #game,
body.has-touch-controls #game canvas {
  touch-action: none;
}

.feedback-toggle-row {
  width: min(100%, 800px);
}

.feedback-toggle-button {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(255, 237, 190, 0.28);
  border-radius: 8px;
  background: #13231f;
  color: #baf7df;
  font: inherit;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.feedback-toggle-button:hover,
.feedback-toggle-button:focus-visible {
  border-color: #baf7df;
  outline: none;
}

.feedback-panel {
  display: grid;
  gap: 14px;
  width: min(100%, 800px);
  padding: 16px;
  border: 1px solid rgba(255, 237, 190, 0.24);
  background: rgba(23, 18, 13, 0.9);
  box-shadow: 0 18px 56px rgba(0, 0, 0, 0.32);
}

.feedback-panel[hidden] {
  display: none;
}

.feedback-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.feedback-header h1,
.request-list-panel h2 {
  margin: 0;
  color: #fff7dc;
  font-size: 20px;
  font-weight: 750;
  line-height: 1.15;
}

.lock-button {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(132, 215, 185, 0.42);
  border-radius: 8px;
  background: #13231f;
  color: #baf7df;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}

.lock-button:hover,
.lock-button:focus-visible,
.submit-button:hover,
.submit-button:focus-visible {
  border-color: #baf7df;
  outline: none;
}

.feedback-form {
  display: grid;
  gap: 9px;
}

.feedback-form label {
  color: #f8efe0;
  font-size: 14px;
  font-weight: 700;
}

.feedback-form input,
.feedback-form textarea {
  width: 100%;
  border: 1px solid rgba(255, 237, 190, 0.26);
  border-radius: 6px;
  background: rgba(12, 14, 13, 0.88);
  color: #fff7dc;
  font: inherit;
  line-height: 1.35;
}

.feedback-form input {
  min-height: 42px;
  padding: 9px 10px;
}

.feedback-form textarea {
  min-height: 132px;
  padding: 10px;
  resize: vertical;
}

.feedback-form input:focus,
.feedback-form textarea:focus {
  border-color: #84d7b9;
  outline: 2px solid rgba(132, 215, 185, 0.2);
}

.submit-button {
  min-height: 42px;
  border: 1px solid rgba(255, 237, 190, 0.24);
  border-radius: 8px;
  background: #d9b16f;
  color: #19130c;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.submit-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.feedback-status {
  min-height: 22px;
  margin: 0;
  color: #ffe4a5;
  font-size: 14px;
  line-height: 1.35;
}

.feedback-status.is-error {
  color: #ffb0a4;
}

.request-list-panel {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

.request-list-panel[hidden] {
  display: none;
}

.request-list {
  display: grid;
  gap: 8px;
  max-height: 340px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.request-list li {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid rgba(255, 237, 190, 0.2);
  border-radius: 8px;
  background: rgba(32, 22, 13, 0.72);
}

.request-meta {
  color: #baf7df;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.25;
}

.request-text {
  margin: 0;
  color: #fff7dc;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

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

@media (hover: hover) and (pointer: fine) {
  html:not(.has-touch-controls) body:not(.has-touch-controls) #dpad,
  html:not(.has-touch-controls) body:not(.has-touch-controls) #btn-attack {
    display: none;
  }
}

html.has-touch-controls #dpad,
body.has-touch-controls #dpad {
  display: grid;
}

html.has-touch-controls #btn-attack,
body.has-touch-controls #btn-attack {
  display: block;
}

@media (orientation: landscape) and (hover: none), (orientation: landscape) and (pointer: coarse) {
  html.has-touch-controls .shell,
  body.has-touch-controls .shell {
    padding-bottom: calc(25dvh + env(safe-area-inset-bottom));
  }

  html.has-touch-controls #game,
  body.has-touch-controls #game {
    width: min(100%, 800px, max(96px, calc(100dvh - 250px)));
    margin-inline: auto;
  }
}
