:root {
  color-scheme: dark;
  --ink: #f7f0dc;
  --muted: #c8c2ad;
  --panel: rgba(16, 20, 18, 0.72);
  --line: rgba(247, 240, 220, 0.22);
  --accent: #f0c84b;
  --danger: #d74632;
  --field: #233a31;
  --shadow: rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }

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

body {
  display: grid;
  place-items: center;
  min-height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 16%, rgba(240, 200, 75, 0.2), transparent 30%),
    linear-gradient(145deg, #16211c 0%, #314c3d 42%, #111716 100%);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
}

.game-shell {
  position: relative;
  width: min(100vw, 1200px);
  height: min(100vh, 675px);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #111;
  box-shadow: 0 30px 90px var(--shadow);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
}

/* ── Menu ── */
.menu {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 14px;
  padding: clamp(20px, 5vw, 72px);
  background:
    linear-gradient(90deg, rgba(10, 14, 13, 0.88), rgba(10, 14, 13, 0.36) 58%, transparent),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.035) 0 1px, transparent 1px 80px);
  overflow-y: auto;
}

.brand { color: var(--accent); font-size: 0.9rem; letter-spacing: 0.16em; text-transform: uppercase; }
.season-title {
  width: min(620px, 100%);
  text-align: center;
  color: var(--ink);
  font: 900 clamp(1.2rem, 4vw, 2.2rem)/1 Verdana, sans-serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-shadow: 0 8px 26px rgba(240,200,75,0.18);
}
.credit { margin-top: -6px; color: var(--muted); font: 700 0.9rem/1 Verdana, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; }
.credit span { color: var(--accent); }

h1 { max-width: 620px; margin: 0; font-size: clamp(2.4rem, 8vw, 6rem); line-height: 0.9; }
h2 { margin: 0 0 10px; font-size: 1.3rem; }
h3 { margin: 0 0 8px; color: var(--accent); font: 700 0.78rem/1 Verdana, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; }

p { max-width: 430px; margin: 0; color: var(--muted); font: 1rem/1.55 Verdana, sans-serif; }

button {
  border: 1px solid rgba(0,0,0,0.45);
  border-radius: 6px;
  padding: 12px 18px;
  background: var(--accent);
  color: #171510;
  cursor: pointer;
  font: 700 0.9rem/1 Verdana, sans-serif;
  box-shadow: 0 10px 24px rgba(0,0,0,0.28);
}
button:hover { filter: brightness(1.08); }
button.secondary { background: transparent; color: var(--ink); border-color: var(--line); }
button.small { padding: 7px 12px; font-size: 0.75rem; }

.menu-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  max-width: 600px;
}

.mode-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.account-btn { margin-left: auto; }

.mode-actions, .multiplayer-fields { display: flex; flex-wrap: wrap; gap: 10px; max-width: 560px; }

.level-select {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font: 700 0.68rem/1 Verdana, sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.level-select select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: rgba(255,255,255,0.08);
  color: var(--ink);
  font: 0.9rem/1 Verdana, sans-serif;
}

.multiplayer-fields label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font: 700 0.68rem/1 Verdana, sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.multiplayer-fields input {
  width: min(42vw, 230px);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: rgba(255,255,255,0.08);
  color: var(--ink);
  font: 0.9rem/1 Verdana, sans-serif;
}

.keys {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 560px;
  font: 0.72rem/1 Verdana, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.keys span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(255,255,255,0.06);
}

/* ── Zero Hour ── */
.zero-hour-panel { width: min(100%, 900px); }

.zero-topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.zero-summary {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-family: Verdana, sans-serif;
}
.zero-summary strong { color: var(--accent); font-size: 1.15rem; }

.zh-equip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}
.equip-slot {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.05);
  min-width: 110px;
  font-family: Verdana, sans-serif;
}
button.equip-slot {
  text-align: left;
  cursor: pointer;
  color: inherit;
}
button.equip-slot:hover {
  border-color: var(--accent);
  background: rgba(240,200,75,0.12);
}
.equip-label { display: block; color: var(--muted); font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase; }
.equip-value { display: block; color: var(--ink); font-size: 0.82rem; margin-top: 3px; }

/* ── Modals ── */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}
.modal-backdrop[hidden] { display: none; }

.modal-box {
  background: #0e1410;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 24px;
  width: min(92vw, 400px);
  max-height: 90vh;
  overflow-y: auto;
  font-family: Verdana, sans-serif;
}
.modal-box.wide { width: min(97vw, 900px); }

.modal-fields { display: grid; gap: 10px; margin: 14px 0; }
.modal-fields input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.08);
  color: var(--ink);
  font: 0.9rem/1 Verdana, sans-serif;
}
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.account-status { color: var(--accent); font-size: 0.85rem; margin-bottom: 8px; }

/* Shop modal */
.shop-header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.shop-header h2 { margin: 0; }

.shop-layout {
  display: grid;
  grid-template-columns: 170px minmax(0, 1.35fr) minmax(220px, 0.75fr);
  gap: 14px;
  max-height: min(62vh, 500px);
  overflow-y: auto;
}
.shop-category-list {
  display: grid;
  gap: 8px;
  align-content: start;
}
.shop-category {
  width: 100%;
  text-align: left;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  font: 0.78rem/1.2 Verdana, sans-serif;
}
.shop-category:hover,
.shop-category.active {
  border-color: var(--accent);
  background: rgba(240,200,75,0.14);
  color: var(--ink);
}
.shop-active-panel,
.shop-inventory-panel {
  min-width: 0;
}
.shop-list, .inventory-list { display: grid; gap: 8px; }

.shop-item, .inventory-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  font: 0.76rem/1.4 Verdana, sans-serif;
  position: relative;
  overflow: hidden;
}
.shop-item strong, .inventory-item strong { display: block; color: var(--ink); margin-bottom: 4px; font-size: 0.8rem; }
.shop-item .item-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.shop-item button { width: 100%; margin-top: 6px; padding: 8px; font-size: 0.74rem; }
.shop-item .mod-actions button { width: auto; flex: 1 1 130px; }
.shop-item button:disabled { opacity: 0.45; cursor: not-allowed; }
.shop-item button.equip-btn { background: #233a31; color: var(--ink); border-color: var(--line); }
.shop-item button.equip-btn.equipped { background: var(--accent); color: #171510; }

.special-item-heart-africa {
  border-color: rgba(255, 62, 96, 0.75) !important;
  background:
    radial-gradient(circle at 84% 18%, rgba(255, 62, 96, 0.34), transparent 24px),
    linear-gradient(135deg, rgba(255, 62, 96, 0.12), rgba(240, 200, 75, 0.10)),
    rgba(255,255,255,0.05);
  box-shadow: 0 0 18px rgba(255, 62, 96, 0.22), inset 0 0 12px rgba(240, 200, 75, 0.12);
}
.special-item-heart-africa::before {
  content: "♥";
  position: absolute;
  top: 5px;
  right: 7px;
  z-index: 1;
  color: #ff3e60;
  font: 700 1rem/1 Georgia, "Times New Roman", serif;
  text-shadow: 0 0 10px rgba(255, 62, 96, 0.9), 0 0 18px rgba(240, 200, 75, 0.55);
  animation: heartAfricaPulse 1.25s ease-in-out infinite;
  pointer-events: none;
}
.special-item-heart-africa::after {
  content: "";
  position: absolute;
  inset: -50% -70%;
  z-index: 0;
  background: linear-gradient(115deg, transparent 40%, rgba(255,255,255,0.42) 48%, transparent 56%);
  animation: heartAfricaShine 2.6s linear infinite;
  pointer-events: none;
}
.special-item-heart-africa > * {
  position: relative;
  z-index: 1;
}
@keyframes heartAfricaPulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.28); filter: brightness(1.35); }
}
@keyframes heartAfricaShine {
  0% { transform: translateX(-35%) rotate(0deg); opacity: 0; }
  22% { opacity: 0.75; }
  45%, 100% { transform: translateX(35%) rotate(0deg); opacity: 0; }
}

.login-hint, .panel-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font: 0.72rem/1.45 Verdana, sans-serif;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.panel-header h2 { margin: 0; }
.slot-count { color: var(--accent); font: 700 0.85rem Verdana, sans-serif; }

.raid-equip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.slot-cell {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  padding: 6px;
  font: 0.68rem/1.25 Verdana, sans-serif;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  min-height: 64px;
}
.slot-cell.empty { cursor: default; color: var(--muted); justify-content: center; align-items: center; }
.slot-cell:hover:not(.empty) { border-color: var(--accent); background: rgba(240,200,75,0.12); }
.slot-cell strong { font-size: 0.7rem; word-break: break-word; }
.slot-cell span { color: var(--muted); font-size: 0.62rem; }
.slot-cell .slot-tooltip {
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  background: #0a100d;
  border: 1px solid var(--line);
  padding: 6px 8px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 5;
  font-size: 0.65rem;
  color: var(--accent);
  pointer-events: none;
}
.slot-cell:hover .slot-tooltip { display: block; }

.loot-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.loot-panels h3 { margin: 0 0 8px; }

.storage-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); }
.setout-loadout, .setout-sections { display: grid; gap: 12px; }
.setout-loadout { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.setout-sections { grid-template-columns: minmax(300px, 1.1fr) minmax(260px, 0.9fr); margin-top: 12px; align-items: start; }
.setout-sections h3 { margin: 0 0 8px; }
.sell-item, .stash-deposit-item {
  cursor: pointer;
}
.sell-item:hover, .stash-deposit-item:hover {
  border-color: var(--accent);
  background: rgba(240,200,75,0.1);
}
.quit-button.hidden-btn { display: none !important; }

@media (max-width: 720px) {
  .storage-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .setout-loadout { grid-template-columns: 1fr; }
  .setout-sections { grid-template-columns: 1fr; }
}

/* ── HUD ── */
.hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 30;
  display: none;
  justify-content: space-between;
  pointer-events: none;
  font-family: Verdana, sans-serif;
  gap: 6px;
}
.hud.active { display: flex; }
.hud div {
  min-width: 80px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  background: var(--panel);
  backdrop-filter: blur(10px);
}
.hud-gear { min-width: 120px !important; }
.quit-button {
  align-self: stretch;
  min-width: 80px;
  padding: 7px 10px;
  background: rgba(215, 70, 50, 0.82);
  color: var(--ink);
  border-color: rgba(247,240,220,0.28);
  pointer-events: auto;
}
.label { display: block; color: var(--muted); font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; }
.hud strong { display: block; margin-top: 3px; font-size: 1.15rem; }

/* ── Message ── */
.message {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--panel);
  color: var(--ink);
  font: 700 0.88rem/1 Verdana, sans-serif;
  white-space: nowrap;
  pointer-events: none;
}

/* ── Touch controls ── */
.touch-controls {
  position: absolute;
  inset: auto 0 0;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 18px 18px;
  pointer-events: none;
}
.joystick {
  width: 130px;
  height: 130px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: rgba(16,20,18,0.5);
  pointer-events: auto;
  touch-action: none;
}
.joystick-knob {
  width: 52px;
  height: 52px;
  margin: 37px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(0,0,0,0.35);
}
.touch-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; pointer-events: auto; }
.touch-button {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  padding: 0;
  background: rgba(247,240,220,0.16);
  color: var(--ink);
  border-color: var(--line);
  backdrop-filter: blur(10px);
  touch-action: none;
  font-size: 0.72rem;
}
.touch-button.shoot { width: 100px; height: 100px; background: var(--accent); color: #171510; grid-column: 3; grid-row: 1 / 3; align-self: center; }
.touch-button.reload { background: rgba(215,70,50,0.72); color: var(--ink); border-color: rgba(247,240,220,0.28); font-size: 0.68rem; }
.touch-button.ads { background: rgba(60,100,180,0.72); color: var(--ink); }
.touch-button.open { background: rgba(240,200,75,0.22); color: var(--ink); border-color: rgba(240,200,75,0.58); }

@media (max-width: 720px) {
  body { place-items: stretch; }
  .game-shell { width: 100vw; height: 100vh; aspect-ratio: auto; }
  .hud { top: 8px; left: 8px; right: 8px; }
  .hud div { min-width: 0; flex: 1; }
  .hud.active ~ .touch-controls { display: flex; }
  .shop-layout { grid-template-columns: 1fr; }
  .shop-category-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .shop-category { text-align: center; padding: 10px 8px; }
  h1 { font-size: clamp(2rem, 10vw, 4rem); }
}

@media (pointer: coarse) {
  .hud.active ~ .touch-controls { display: flex; }
}
