:root {
  color-scheme: dark;
  --bg: #090d10;
  --floor: #172126;
  --floor-2: #1f2b2e;
  --wall: #2a2c36;
  --ink: #f6f1df;
  --muted: #aebbb6;
  --line: rgba(255, 255, 255, 0.14);
  --panel: rgba(15, 20, 24, 0.88);
  --panel-strong: rgba(9, 12, 15, 0.96);
  --teal: #40d6b5;
  --amber: #f1ba48;
  --coral: #f36f5d;
  --green: #7bd672;
  --violet: #b58cff;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
}

button {
  font: inherit;
}

.app {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  background:
    radial-gradient(circle at 18% 24%, rgba(64, 214, 181, 0.12), transparent 28%),
    radial-gradient(circle at 82% 78%, rgba(241, 186, 72, 0.10), transparent 30%),
    var(--bg);
}

.board-wrap {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: clamp(10px, 2vw, 22px);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 1200px;
  max-height: 920px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #050708;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  cursor: pointer;
}

.panel {
  min-width: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  gap: 14px;
  padding: 18px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(12px);
}

.title-block p,
.eyebrow {
  margin: 0 0 6px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.title-block h1,
.modal-panel h2 {
  margin: 0;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 0.96;
  letter-spacing: 0;
}

.meters,
.stat-grid,
.actions,
.log {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.meters {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.meter {
  display: grid;
  grid-template-columns: 28px 1fr 56px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.meter-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07);
}

.meter-fill {
  width: 100%;
  height: 100%;
  transform-origin: left center;
  transition: transform 120ms ease-out;
}

.meter-fill.hp {
  background: linear-gradient(90deg, var(--coral), #ffd166);
}

.meter-fill.xp {
  background: linear-gradient(90deg, var(--teal), #8be9fd);
}

.meter b {
  color: var(--ink);
  text-align: right;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
}

.stat-grid div {
  min-height: 58px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 10px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stat-grid div:nth-child(2n) {
  border-right: 0;
}

.stat-grid div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.stat-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.stat-grid b {
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
}

.actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
}

.actions button,
.primary-button,
.upgrade-button {
  border: 0;
  border-radius: 8px;
  color: #071112;
  cursor: pointer;
  font-weight: 900;
  transition:
    transform 120ms ease,
    filter 120ms ease;
}

.actions button {
  min-height: 44px;
  background: linear-gradient(135deg, var(--teal), #a9d66d);
}

.actions button:nth-child(2) {
  background: linear-gradient(135deg, var(--violet), #8be9fd);
}

.actions button:nth-child(3) {
  background: linear-gradient(135deg, var(--amber), #f6d365);
}

.actions button:hover,
.primary-button:hover,
.upgrade-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.actions button:disabled {
  cursor: not-allowed;
  filter: saturate(0.4) brightness(0.65);
  transform: none;
}

.log {
  min-height: 0;
  overflow: hidden;
  padding: 10px;
}

#logList {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: end;
  gap: 8px;
}

#logList p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

#logList p:first-child {
  color: var(--ink);
}

.modal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 8, 10, 0.62);
  backdrop-filter: blur(8px);
}

.modal.hidden,
.hidden {
  display: none;
}

.modal-panel {
  width: min(680px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
  padding: clamp(20px, 4vw, 34px);
  text-align: center;
}

.intro {
  max-width: 42rem;
  margin: 14px auto 22px;
  color: var(--muted);
  font-size: clamp(15px, 2.2vw, 18px);
  line-height: 1.5;
}

.primary-button {
  min-width: 168px;
  min-height: 48px;
  padding: 12px 22px;
  background: linear-gradient(135deg, var(--teal), var(--amber));
  box-shadow: 0 14px 38px rgba(64, 214, 181, 0.2);
}

.control-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}

.control-strip span {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.upgrade-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.upgrade-button {
  min-height: 144px;
  padding: 16px;
  background: linear-gradient(150deg, rgba(64, 214, 181, 0.98), rgba(241, 186, 72, 0.98));
  text-align: left;
}

.upgrade-button:nth-child(2) {
  background: linear-gradient(150deg, rgba(181, 140, 255, 0.98), rgba(139, 233, 253, 0.98));
}

.upgrade-button:nth-child(3) {
  background: linear-gradient(150deg, rgba(241, 186, 72, 0.98), rgba(243, 111, 93, 0.98));
}

.upgrade-button strong,
.upgrade-button span {
  display: block;
}

.upgrade-button strong {
  margin-bottom: 8px;
  font-size: 17px;
  line-height: 1.2;
}

.upgrade-button span {
  color: rgba(7, 17, 18, 0.78);
  font-size: 13px;
  line-height: 1.35;
}

@media (max-width: 860px) {
  html,
  body {
    overflow: auto;
  }

  .app {
    min-height: 100vh;
    height: auto;
    grid-template-columns: 1fr;
  }

  .board-wrap {
    height: min(72vh, 720px);
  }

  .panel {
    height: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .upgrade-grid {
    grid-template-columns: 1fr;
  }

  .upgrade-button {
    min-height: 108px;
  }
}
