:root {
  color-scheme: light;
  --ink: #33281e;
  --muted: #746554;
  --paper: #f6e8c8;
  --rose: #a94d45;
  --teal: #4f8576;
  --gold: #c79645;
  --leaf: #667c4c;
  --night: #2f3944;
  --shadow: rgba(47, 34, 21, 0.22);
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  place-items: center;
  overflow-x: hidden;
  background:
    repeating-linear-gradient(90deg, rgba(91, 66, 40, 0.035) 0 1px, transparent 1px 7px),
    radial-gradient(circle at 18% 15%, rgba(205, 154, 74, 0.28), transparent 30%),
    linear-gradient(135deg, #d9b98a 0%, #f5e6c6 46%, #9ab2a5 100%);
  color: var(--ink);
  font-family:
    "Trebuchet MS",
    "Noto Sans KR",
    system-ui,
    sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  width: min(100%, 1180px);
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.game-card {
  position: relative;
  width: min(100%, 1040px);
  height: min(720px, calc(100vh - 48px));
  min-height: 560px;
  overflow: hidden;
  border: 4px solid rgba(66, 46, 29, 0.5);
  border-radius: 8px;
  background: var(--paper);
  box-shadow:
    0 24px 70px var(--shadow),
    inset 0 0 0 8px rgba(255, 246, 220, 0.52),
    inset 0 0 70px rgba(95, 59, 31, 0.16);
}

.game-card.is-shaking {
  animation: arena-shake 430ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #f3e0b8;
}

.hud {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 10px;
  pointer-events: none;
}

.hud-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  padding: 10px 13px;
  border: 2px solid rgba(50, 40, 31, 0.26);
  border-radius: 8px;
  background:
    repeating-linear-gradient(0deg, rgba(89, 63, 38, 0.035) 0 1px, transparent 1px 5px),
    rgba(248, 232, 198, 0.86);
  box-shadow: 0 8px 0 rgba(117, 83, 48, 0.14);
  backdrop-filter: blur(8px);
}

.hud-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

.hud strong {
  color: var(--night);
  font-size: 24px;
  line-height: 1;
}

.life-icons {
  display: flex;
  gap: 7px;
  align-items: center;
}

.heart {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 2px 0 rgba(50, 40, 31, 0.18));
}

.heart.is-empty {
  opacity: 0.28;
  filter: grayscale(0.8);
}

.icon-button {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border: 2px solid rgba(50, 40, 31, 0.28);
  border-radius: 50%;
  background: rgba(247, 232, 198, 0.88);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 7px 0 rgba(72, 53, 37, 0.16);
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
  z-index: 8;
}

.icon-button:hover {
  transform: translateY(-2px);
  background: #fff7df;
  box-shadow: 0 9px 0 rgba(72, 53, 37, 0.14);
}

.icon-button:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 rgba(72, 53, 37, 0.18);
}

.overlay-panel {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background:
    repeating-linear-gradient(90deg, rgba(91, 66, 40, 0.035) 0 1px, transparent 1px 8px),
    rgba(242, 222, 180, 0.72);
  backdrop-filter: blur(4px);
}

.overlay-panel.is-visible {
  display: flex;
}

.panel-inner {
  width: min(560px, 100%);
  padding: 34px;
  border: 3px solid rgba(50, 40, 31, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 247, 223, 0.9), rgba(234, 206, 157, 0.9)),
    var(--paper);
  text-align: center;
  box-shadow: 0 18px 0 rgba(95, 64, 38, 0.12);
}

.eyebrow {
  margin: 0 0 10px;
  color: #6b4f32;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2 {
  margin: 0;
  color: #3f2e22;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 900;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(44px, 7vw, 78px);
  line-height: 0.95;
}

h2 {
  font-size: clamp(36px, 6vw, 58px);
}

.panel-copy {
  width: min(430px, 100%);
  margin: 18px auto 26px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  padding: 0 22px;
  border: 2px solid rgba(45, 35, 27, 0.34);
  border-radius: 8px;
  color: #2e241c;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 8px 0 rgba(69, 50, 35, 0.22);
  transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}

.primary-button {
  background: linear-gradient(180deg, #e8c574, #bd8741);
}

.secondary-button {
  background: linear-gradient(180deg, #fff6dc, #d6c39a);
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-2px);
  filter: saturate(1.06);
  box-shadow: 0 10px 0 rgba(69, 50, 35, 0.18);
}

.primary-button:active,
.secondary-button:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 rgba(69, 50, 35, 0.2);
}

.result-inner {
  max-height: calc(100vh - 76px);
  overflow: auto;
}

.result-score {
  display: grid;
  gap: 2px;
  width: min(260px, 100%);
  margin: 18px auto 20px;
  padding: 14px;
  border: 2px solid rgba(50, 40, 31, 0.18);
  border-radius: 8px;
  background: rgba(255, 245, 219, 0.62);
}

.result-score span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.result-score strong {
  color: var(--rose);
  font-size: 42px;
  line-height: 1;
}

.loot-wrap h3 {
  margin: 0 0 12px;
  color: var(--night);
  font-size: 18px;
}

.loot-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 190px;
  margin: 0;
  padding: 0 2px;
  list-style: none;
  overflow: auto;
}

.loot-list li {
  min-width: 0;
  padding: 10px 12px;
  border: 2px solid rgba(50, 40, 31, 0.14);
  border-radius: 8px;
  background: rgba(255, 245, 219, 0.76);
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.loot-list .empty {
  grid-column: 1 / -1;
  color: var(--muted);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}

@keyframes arena-shake {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  16% {
    transform: translate3d(-8px, 4px, 0);
  }
  32% {
    transform: translate3d(7px, -3px, 0);
  }
  48% {
    transform: translate3d(-5px, -5px, 0);
  }
  64% {
    transform: translate3d(5px, 3px, 0);
  }
  82% {
    transform: translate3d(-2px, 2px, 0);
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
  }

  .game-card {
    height: calc(100vh - 24px);
    min-height: 520px;
  }

  .hud {
    grid-template-columns: 1fr 1fr;
    left: 10px;
    right: 10px;
    bottom: 10px;
  }

  .hud-block {
    padding: 9px 10px;
  }

  .hud-block:last-child {
    grid-column: 1 / -1;
  }

  .panel-inner {
    padding: 25px 18px;
  }

  .loot-list {
    grid-template-columns: 1fr;
  }
}
