* { box-sizing: border-box; }

body {
  margin: 0;
  overflow: hidden;
  min-height: 100vh;
  font-family: Arial, "Malgun Gothic", sans-serif;
  color: #f8fbff;
  background:
    radial-gradient(circle at 18% 12%, rgba(46, 196, 182, 0.16), transparent 25%),
    radial-gradient(circle at 82% 18%, rgba(255, 209, 102, 0.12), transparent 24%),
    linear-gradient(135deg, #0f1722 0%, #141b2c 55%, #101827 100%);
}

canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  cursor: crosshair;
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.panel {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(10, 16, 28, 0.84);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(12px);
}

.lobby-screen {
  inset: 0;
  width: 100vw;
  max-height: none;
  height: 100vh;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 20% 34%, rgba(255, 255, 255, 0.18), transparent 18%),
    radial-gradient(circle at 78% 42%, rgba(255, 255, 255, 0.12), transparent 20%),
    repeating-radial-gradient(circle at 16px 16px, rgba(255, 197, 69, 0.34) 0 2px, transparent 3px 18px),
    linear-gradient(180deg, #ff9f1c 0%, #ff8a00 60%, #f27500 100%);
  box-shadow: none;
  transform: none;
  top: 0;
  left: 0;
}

.lobby-top {
  display: grid;
  grid-template-columns: 1.4fr 0.75fr 0.75fr 0.75fr;
  gap: 8px;
  padding: 8px;
  color: #f8fbff;
  background: #151923;
  border-bottom: 4px solid #070910;
}

.resource {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 5px 8px;
  border-radius: 6px;
  background: #0b0f18;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08);
  font-weight: 900;
}

.avatar,
.resource-icon,
.side-icon,
.boss-icon,
.tab-icon {
  display: grid;
  place-items: center;
  border: 3px solid #111827;
  border-radius: 8px;
  color: #111827;
  background: #70d6ff;
  font-weight: 900;
  text-shadow: none;
}

.avatar {
  width: 42px;
  height: 42px;
  background: #f8fbff;
}

.resource-icon {
  width: 28px;
  height: 28px;
  border-width: 2px;
  background: #ffd166;
}

.player-block {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 8px;
  align-items: center;
}

.player-name {
  overflow: hidden;
  color: white;
  font-size: 15px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.level-bar {
  height: 10px;
  margin-top: 3px;
  border: 2px solid #05070c;
  border-radius: 999px;
  background: #2a3143;
}

.level-fill {
  width: 62%;
  height: 100%;
  border-radius: inherit;
  background: #8bdc35;
}

.lobby-body {
  position: relative;
  height: calc(100vh - 58px);
  padding: 24px 88px 94px;
}

.side-menu {
  position: absolute;
  top: 46px;
  display: grid;
  gap: 12px;
}

.side-menu.left { left: 12px; }
.side-menu.right { right: 12px; }

.side-icon {
  position: relative;
  width: 58px;
  height: 58px;
  background: #f8fbff;
  font-size: 23px;
  box-shadow: 0 4px 0 #313847;
}

.side-icon::after,
.tab-icon.alert::after {
  content: "!";
  position: absolute;
  top: -10px;
  right: -8px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 2px solid white;
  border-radius: 50%;
  color: white;
  background: #ff2d55;
  font-size: 14px;
}

.mission-card {
  width: min(860px, calc(100vw - 178px));
  margin: 0 auto;
  padding: 12px 14px;
  border: 4px solid #172033;
  border-radius: 10px;
  color: #101827;
  background: #66e1ff;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
}

.game-brief {
  width: min(860px, calc(100vw - 178px));
  margin: 10px auto 0;
  padding: 10px 12px;
  border: 3px solid #172033;
  border-radius: 8px;
  color: #111827;
  background: rgba(255, 255, 255, 0.92);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
  text-align: left;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}

.game-brief strong {
  display: block;
  margin-bottom: 3px;
  font-size: 16px;
}

.system-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: min(980px, calc(100vw - 178px));
  margin: 10px auto 0;
  pointer-events: auto;
}

.system-action {
  display: grid;
  gap: 4px;
  min-height: 72px;
  padding: 8px;
  border: 3px solid #172033;
  border-radius: 8px;
  color: #111827;
  background: rgba(255, 244, 214, 0.96);
  text-align: left;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}

.system-action strong {
  font-size: 13px;
  line-height: 1.1;
}

.system-action span {
  font-size: 11px;
  line-height: 1.25;
  opacity: 0.82;
}

.system-action:disabled,
.system-action.claimed {
  cursor: not-allowed;
  filter: grayscale(0.45);
  opacity: 0.62;
}

.system-status {
  width: min(860px, calc(100vw - 178px));
  min-height: 22px;
  margin: 8px auto 0;
  color: #fff4d6;
  font-size: 13px;
  font-weight: 900;
  text-shadow: 0 2px 0 #6f2f00;
}

.equipment-drawer {
  position: absolute;
  top: 50%;
  left: 82px;
  z-index: 4;
  display: none;
  width: min(360px, calc(100vw - 170px));
  max-height: 58vh;
  overflow: auto;
  padding: 12px;
  border: 4px solid #172033;
  border-radius: 8px;
  color: #111827;
  background: rgba(255, 255, 255, 0.94);
  text-align: left;
  transform: translateY(-50%);
  pointer-events: auto;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.32);
}

.equipment-drawer.open { display: block; }

.equipment-drawer h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

.equipment-drawer p {
  margin-bottom: 8px;
  color: #374151;
  font-size: 12px;
  line-height: 1.35;
}

.equipment-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0;
}

.equipment-controls button,
.equip-button {
  min-height: 36px;
  padding: 8px 9px;
  border-radius: 6px;
  font-size: 13px;
}

.weapon-inventory {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin-top: 8px;
}

.inventory-weapon {
  min-height: 58px;
  padding: 8px;
  border: 2px solid rgba(17, 24, 39, 0.15);
  border-radius: 8px;
  color: #111827;
  background: #e9f2ff;
  text-align: left;
}

.inventory-weapon.selected {
  border-color: #ff9f1c;
  background: #fff4d6;
}

.inventory-weapon.equipped {
  box-shadow: inset 0 0 0 2px #2ec4b6;
}

.inventory-weapon span {
  display: block;
  margin-top: 4px;
  color: #4b5563;
  font-size: 11px;
}

.mission-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: center;
}

.season-badge {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  clip-path: polygon(50% 0, 92% 24%, 92% 76%, 50% 100%, 8% 76%, 8% 24%);
  background: #ffd166;
  font-weight: 900;
}

.mission-progress {
  height: 24px;
  border: 4px solid #1b2435;
  border-radius: 4px;
  background: #303a50;
  color: white;
  line-height: 16px;
  font-weight: 900;
}

.challenge-title {
  margin-top: 26px;
  color: white;
  font-size: clamp(34px, 7vw, 58px);
  line-height: 1;
  text-shadow: 0 4px 0 #6f2f00, 0 0 3px #6f2f00;
}

.challenge-subtitle {
  margin-top: 8px;
  color: #fff4d6;
  font-size: clamp(16px, 3vw, 24px);
  font-weight: 900;
  text-shadow: 0 2px 0 #6f2f00;
}

.center-weapons {
  position: relative;
  display: grid;
  place-items: center;
  width: min(460px, 62vw);
  height: min(270px, 32vh);
  margin: 10px auto 0;
}

.big-guns {
  position: relative;
  width: min(360px, 55vw);
  height: 190px;
}

.big-gun {
  position: absolute;
  bottom: 18px;
  width: 115px;
  height: 176px;
  border: 5px solid #141923;
  border-radius: 20px 20px 16px 16px;
  background: linear-gradient(90deg, #384862, #c6d1e5 40%, #7e8ca4);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.28);
  transform-origin: bottom center;
}

.big-gun.left {
  left: 80px;
  transform: rotate(-30deg);
}

.big-gun.right {
  right: 80px;
  transform: rotate(30deg);
}

.big-gun::before {
  content: "";
  position: absolute;
  top: 20px;
  left: 20px;
  width: 72px;
  height: 95px;
  border: 4px solid #141923;
  border-radius: 10px;
  background: repeating-linear-gradient(180deg, #dfe7f4 0 16px, #58677f 17px 28px);
}

.speech {
  position: absolute;
  bottom: 10px;
  left: 50%;
  width: min(330px, 76vw);
  padding: 10px 12px;
  border: 4px solid #343b47;
  border-radius: 8px;
  color: #1f2937;
  background: #dce3ec;
  font-weight: 900;
  transform: translateX(-50%);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}

.boss-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 18px;
  width: min(860px, calc(100vw - 120px));
  margin: 14px auto 0;
}

.boss-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  color: white;
  font-weight: 900;
  text-shadow: 0 2px 0 #111827;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.boss-card:hover {
  transform: translateY(-3px);
  filter: brightness(1.08);
}

.boss-card.locked {
  cursor: not-allowed;
  opacity: 0.62;
}

.boss-card.locked:hover {
  transform: none;
  filter: none;
}

.boss-card.selected .boss-icon {
  outline: 4px solid #ffd166;
  outline-offset: 3px;
}

.boss-icon {
  width: 68px;
  height: 58px;
  background: linear-gradient(180deg, #dce3ec, #6c7b95);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
}

.start-challenge {
  margin-top: 14px;
  min-width: min(360px, 76vw);
  border: 4px solid #172033;
  border-radius: 2px;
  background: #ffd126;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.36);
  font-size: clamp(24px, 5vw, 36px);
  text-shadow: 0 2px 0 white;
}

.uses-left {
  margin-top: 8px;
  color: white;
  font-size: 17px;
  font-weight: 900;
  text-shadow: 0 2px 0 #6f2f00;
}

.bottom-tabs {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: 82px;
  border-top: 5px solid #131923;
  background: #222936;
}

.tab {
  position: relative;
  display: grid;
  place-items: center;
  border-right: 3px solid #10151e;
  color: white;
  font-size: 14px;
  font-weight: 900;
  text-shadow: 0 2px 0 black;
}

.tab.active {
  color: #111827;
  background: #ffd126;
  text-shadow: 0 2px 0 white;
}

.tab-icon {
  width: 44px;
  height: 34px;
  margin-bottom: 2px;
  background: #f8fbff;
}

.topbar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: grid;
  grid-template-columns: minmax(300px, 540px) minmax(260px, 390px);
  gap: 12px;
  align-items: start;
  justify-content: space-between;
}

.stats, .arsenal { padding: 12px; }

h1, h2, h3, p { margin: 0; }

.title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.topbar .panel {
  pointer-events: auto;
}

h1 {
  font-size: clamp(23px, 4vw, 34px);
  line-height: 1;
  letter-spacing: 0;
}

.badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 6px;
  color: #121827;
  font-size: 13px;
  font-weight: 900;
  background: #ffd166;
}

.save-wrap {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.save-button {
  min-height: 30px;
  padding: 6px 9px;
  border-radius: 6px;
  font-size: 13px;
}

.main-save-row {
  justify-content: center;
  width: min(620px, calc(100vw - 210px));
  margin: 8px auto 0;
  pointer-events: auto;
}

.main-save-row .save-button {
  min-width: 180px;
  min-height: 42px;
  padding: 8px 18px;
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.28);
}

.save-status {
  min-width: 52px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  font-weight: 800;
  text-align: left;
}

.meters {
  display: grid;
  gap: 8px;
}

.meter {
  overflow: hidden;
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
}

.fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 0.12s linear;
}

.hp { background: linear-gradient(90deg, #ff4d6d, #ff9f1c); }
.gem { background: linear-gradient(90deg, #2ec4b6, #70d6ff); }

.readouts {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
}

.readouts div {
  min-width: 0;
  padding: 7px 6px;
  border-radius: 6px;
  text-align: center;
  background: rgba(255, 255, 255, 0.09);
}

.readouts strong {
  display: block;
  margin-top: 3px;
  color: #fff;
  font-size: 16px;
}

.arsenal h2 {
  margin-bottom: 10px;
  font-size: 16px;
}

.weapon-slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.owned-weapon {
  min-height: 64px;
  padding: 8px;
  border-radius: 8px;
  color: #121827;
  background: #e9f2ff;
  font-weight: 900;
}

.owned-weapon span {
  display: block;
  margin-top: 5px;
  color: #433a10;
  font-size: 12px;
}

.owned-weapon.empty {
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.36);
  border: 1px dashed rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
}

.help {
  position: absolute;
  left: 16px;
  bottom: 16px;
  max-width: min(610px, calc(100vw - 32px));
  padding: 10px 12px;
  color: rgba(255, 255, 255, 0.84);
  font-size: 14px;
  line-height: 1.45;
}

.center-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 22px;
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

.center-panel h2 {
  margin-bottom: 10px;
  font-size: clamp(28px, 6vw, 42px);
  line-height: 1.05;
}

.center-panel p {
  margin: 8px 0;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.45;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 11px 15px;
  color: #121827;
  font-size: 16px;
  font-weight: 900;
  background: #ffd166;
  cursor: pointer;
}

.primary-button { margin-top: 14px; }

.ending-panel {
  overflow: hidden;
  border-color: rgba(255, 209, 102, 0.5);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 209, 102, 0.2), transparent 36%),
    rgba(10, 16, 28, 0.92);
}

.ending-panel::before {
  content: "";
  position: absolute;
  inset: -30% -10% auto;
  height: 180px;
  background: radial-gradient(circle, rgba(255, 159, 28, 0.28), transparent 64%);
  pointer-events: none;
}

.ending-kicker {
  position: relative;
  color: #ffd166;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}

.ending-stats {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0 4px;
}

.ending-stats div {
  min-height: 74px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
}

.ending-stats span,
.ending-stats strong {
  display: block;
}

.ending-stats span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 800;
}

.ending-stats strong {
  margin-top: 8px;
  color: #fff;
  font-size: clamp(20px, 4vw, 30px);
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 16px 0 4px;
}

.stage-card {
  min-height: 96px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: #f8fbff;
  background: rgba(255, 255, 255, 0.08);
}

.stage-card.active {
  color: #121827;
  background: #70d6ff;
}

.stage-card strong, .stage-card span {
  display: block;
}

.stage-card span {
  margin-top: 7px;
  font-size: 12px;
}

.puzzle-target {
  display: inline-block;
  margin-top: 6px;
  padding: 5px 9px;
  border-radius: 6px;
  color: #121827;
  font-weight: 900;
  background: #70d6ff;
}

.puzzle-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(48px, 78px));
  justify-content: center;
  gap: 8px;
  margin: 16px auto 12px;
}

.tile {
  display: grid;
  place-items: center;
  min-height: 54px;
  aspect-ratio: 1;
  border-radius: 8px;
  color: #121827;
  font-size: clamp(20px, 5vw, 32px);
  font-weight: 900;
  background: #e9f2ff;
}

.tile.empty {
  color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
}

.puzzle-controls {
  display: grid;
  grid-template-columns: repeat(3, 54px);
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.puzzle-controls button {
  min-height: 44px;
  padding: 8px;
  font-size: 20px;
}

.weapon-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.weapon-card {
  display: grid;
  gap: 8px;
  min-height: 184px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: #f8fbff;
  text-align: left;
  background: rgba(255, 255, 255, 0.08);
}

.weapon-card.owned {
  border-color: rgba(255, 209, 102, 0.75);
  background: rgba(255, 209, 102, 0.12);
}

.weapon-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  color: #121827;
  font-size: 24px;
  font-weight: 900;
  background: #70d6ff;
}

.weapon-card strong { font-size: 17px; }

.weapon-card span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  line-height: 1.35;
}

.hidden { display: none; }

@media (max-width: 820px) {
  .topbar { grid-template-columns: 1fr; }
  .readouts { grid-template-columns: repeat(3, 1fr); }
  .stage-grid, .weapon-list { grid-template-columns: 1fr; }
  .ending-stats { grid-template-columns: 1fr; }
  .help { font-size: 12px; }
  .lobby-body { padding: 18px 70px 88px; }
  .mission-card { width: calc(100vw - 156px); }
  .game-brief { width: calc(100vw - 156px); font-size: 12px; }
  .main-save-row { width: calc(100vw - 156px); }
  .system-actions { width: calc(100vw - 156px); grid-template-columns: repeat(2, 1fr); }
  .system-status { width: calc(100vw - 156px); font-size: 12px; }
  .equipment-drawer { left: 70px; width: calc(100vw - 140px); }
  .boss-row { gap: 10px; width: calc(100vw - 104px); }
  .side-icon { width: 50px; height: 50px; }
}
