* {
  margin: 0;
  padding: 0;
}

:root {
  --game-width: 1200px;
  --game-height: 900px;
  --slot-bg: #222;
  --slot-border: #555;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: #1a1a1a;
  font-family: 'Oxanium', Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

#game-container {
  position: relative;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

#game-canvas {
  display: block;
  background: #111;
  /* Fixed pixel size - prevents 4K from scaling canvas and tanking performance */
  width: var(--game-width);
  height: var(--game-height);
  cursor: none;
}

#ship-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--game-width);
  height: var(--game-height);
  pointer-events: none;
  z-index: 2;
}

#ui-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--game-width);
  height: var(--game-height);
  pointer-events: none;
  /* Above shop/warp blur overlays; below hotbar/drop zones */
  z-index: 14;
}

#game-ui {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 15px;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 12px;
}

#game-ui a {
  color: #6af;
  text-decoration: none;
}

#game-ui a:hover {
  text-decoration: underline;
}

#game-ui span {
  color: #666;
}

#game-ui label {
  color: #ccc;
  display: flex;
  align-items: center;
  gap: 6px;
}

#game-ui select {
  background: #333;
  color: #fff;
  border: 1px solid #555;
  padding: 2px 6px;
  font-size: 12px;
}

#start-menu-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--game-width);
  height: var(--game-height);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: grayscale(1) blur(2px);
  -webkit-backdrop-filter: grayscale(1) blur(2px);
  z-index: 20;
  pointer-events: auto;
  cursor: pointer;
  box-sizing: border-box;
}

#start-menu {
  background: rgba(20, 20, 20, 0.9);
  border: 1px solid #777;
  border-radius: 10px;
  padding: 18px 22px;
  text-align: center;
}

#start-menu .start-title {
  color: #fff;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 20px;
  letter-spacing: 0.5px;
}

/* ── Main Menu ── */
#main-menu-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--game-width);
  height: var(--game-height);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  pointer-events: auto;
  box-sizing: border-box;
}

#main-menu-starfield-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
}

#main-menu {
  position: relative;
  z-index: 1;
  width: min(680px, calc(var(--game-width) - 100px));
  background: rgba(20, 20, 20, 0.92);
  border: 1px solid #777;
  border-radius: 10px;
  padding: 40px 44px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

#main-menu .main-menu-kicker {
  color: #bbb;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

#main-menu .main-menu-title {
  color: #fff;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 58px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 2px;
  margin: 0;
}

#main-menu-start-btn,
#main-menu-load-btn {
  min-width: 180px;
  background: #2f2f2f;
  color: #eee;
  border: 1px solid #666;
  border-radius: 8px;
  padding: 12px 30px;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 17px;
  letter-spacing: 0.5px;
  cursor: pointer;
}

#main-menu-start-btn:hover,
#main-menu-load-btn:hover {
  background: #444;
}

#save-browser-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--game-width);
  height: var(--game-height);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  z-index: 35;
  pointer-events: auto;
}

#save-browser-menu {
  width: min(760px, calc(var(--game-width) - 80px));
  max-height: min(620px, calc(var(--game-height) - 80px));
  background: rgba(20, 20, 20, 0.95);
  border: 1px solid #777;
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#save-browser-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
  font-size: 20px;
}

#save-browser-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

#save-browser-empty {
  color: #bbb;
  font-size: 14px;
}

.save-entry-btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid #666;
  border-radius: 8px;
  background: #2f2f2f;
  color: #eee;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.save-entry-btn:hover {
  background: #444;
}

.save-entry-meta {
  color: #fff;
  font-size: 13px;
}

.save-entry-detail {
  color: #c8c8c8;
  font-size: 12px;
}

/* ── Intro Cutscene ── */
#intro-cutscene-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--game-width);
  height: var(--game-height);
  z-index: 25;
  display: flex;
  flex-direction: column;
  background: #050510;
  overflow: hidden;
  box-sizing: border-box;
  transform-origin: center center;
  will-change: opacity, transform;
}

#intro-cutscene-overlay.fade-out {
  animation: cutsceneFadeOut 1.2s ease-in forwards;
}

@keyframes cutsceneFadeOut {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

#intro-dialogue-box {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  height: 115px;
  padding: 8px 20px 8px;
  box-sizing: border-box;
  background: rgba(5, 10, 18, 0.92);
  border-bottom: 1px solid rgba(0, 255, 140, 0.25);
  box-shadow: 0 2px 20px rgba(0, 255, 140, 0.06);
  font-family: 'Oxanium', Arial, sans-serif;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#intro-dialogue-header {
  font-size: 10px;
  color: rgba(0, 255, 140, 0.35);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 2px;
}

#intro-dialogue-text {
  font-size: 15px;
  color: #00ff8c;
  line-height: 1.35;
  white-space: pre-wrap;
  text-shadow: 0 0 6px rgba(0, 255, 140, 0.4);
  overflow-y: auto;
  padding-right: 4px;
}

#intro-dialogue-text .cursor-blink {
  display: inline-block;
  width: 8px;
  height: 15px;
  background: #00ff8c;
  vertical-align: text-bottom;
  animation: cursorBlink 0.6s step-end infinite;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

#intro-map-canvas {
  flex: 1;
  width: 100%;
  display: block;
}

#intro-skip-hint {
  position: absolute;
  bottom: 12px;
  right: 16px;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.3);
  z-index: 3;
  pointer-events: none;
  letter-spacing: 0.5px;
}

#mothership-intro-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--game-width);
  height: var(--game-height);
  z-index: 26;
  pointer-events: none;
}

#mothership-intro-dialogue-box {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 115px;
  padding: 8px 20px 8px;
  box-sizing: border-box;
  background: rgba(5, 10, 18, 0.92);
  border-bottom: 1px solid rgba(0, 255, 140, 0.25);
  box-shadow: 0 2px 20px rgba(0, 255, 140, 0.06);
  font-family: 'Oxanium', Arial, sans-serif;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#mothership-intro-dialogue-header {
  font-size: 10px;
  color: rgba(0, 255, 140, 0.35);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 2px;
}

#mothership-intro-dialogue-text {
  font-size: 15px;
  color: #00ff8c;
  line-height: 1.35;
  white-space: pre-wrap;
  text-shadow: 0 0 6px rgba(0, 255, 140, 0.4);
  overflow-y: auto;
  padding-right: 4px;
}

#pause-menu-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--game-width);
  height: var(--game-height);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: grayscale(1) blur(2px);
  -webkit-backdrop-filter: grayscale(1) blur(2px);
  z-index: 31;
  pointer-events: auto;
  box-sizing: border-box;
}

#pause-menu {
  background: rgba(20, 20, 20, 0.92);
  border: 1px solid #777;
  border-radius: 10px;
  padding: 22px 24px;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#pause-menu .pause-title {
  color: #fff;
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.5px;
}

#pause-menu .pause-volume-label {
  color: #bbb;
  font-size: 13px;
}

#pause-menu .pause-volume-slider {
  width: 100%;
  cursor: pointer;
}

#pause-menu .pause-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

#pause-menu #pause-actions-confirm {
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#pause-menu .pause-confirm-text {
  color: #ccc;
  font-size: 13px;
}

#pause-menu .pause-confirm-btns {
  display: flex;
  gap: 10px;
}

#pause-menu button {
  padding: 10px 16px;
  border-radius: 8px;
  background: #2f2f2f;
  border: 1px solid #666;
  color: #eee;
  cursor: pointer;
}

#pause-menu button:hover {
  background: #444;
}

#death-menu-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--game-width);
  height: var(--game-height);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: grayscale(1) blur(2px);
  -webkit-backdrop-filter: grayscale(1) blur(2px);
  z-index: 30;
  pointer-events: auto;
  box-sizing: border-box;
}

#death-menu {
  background: rgba(20, 20, 20, 0.92);
  border: 1px solid #777;
  border-radius: 10px;
  padding: 22px 26px;
  text-align: center;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#death-menu .death-title {
  color: #fff;
  font-size: 24px;
  letter-spacing: 0.5px;
  font-weight: 600;
}

#death-menu .death-subtitle {
  color: #ccc;
  font-size: 14px;
}

#death-menu .death-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

#death-menu button {
  padding: 10px 16px;
  border-radius: 8px;
  background: #2f2f2f;
  border: 1px solid #666;
  color: #eee;
  cursor: pointer;
}

#death-menu button:hover {
  background: #444;
}

#warp-menu-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--game-width);
  height: var(--game-height);
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

#warp-menu {
  background: #2a2a2a;
  padding: 24px;
  border-radius: 8px;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  border: 1px solid #555;
}

#warp-menu p {
  margin: 0;
  color: #eee;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 14px;
}

#warp-menu button {
  padding: 8px 16px;
  margin: 0 4px;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid #666;
  border-radius: 4px;
  background: #444;
  color: #fff;
}

#warp-menu button:hover:not(:disabled) {
  background: #555;
}

#warp-menu button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#warp-menu .warp-req-met {
  color: #8c8;
}

#warp-menu .warp-req-missing {
  color: #c66;
}

#crafting-menu-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--game-width);
  height: var(--game-height);
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  z-index: 10;
  pointer-events: auto;
  cursor: default;
}

#crafting-menu {
  background: rgba(30, 30, 30, 0.95);
  padding: 20px;
  border-radius: 8px;
  min-width: 500px;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 1px solid #666;
  pointer-events: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

#crafting-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#crafting-header span {
  color: #eee;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 18px;
}

#crafting-header button {
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid #666;
  border-radius: 4px;
  background: #444;
  color: #fff;
}

#crafting-main {
  display: flex;
  gap: 20px;
  flex: 1;
}

#crafting-recipes-list {
  width: 200px;
  background: #222;
  border: 1px solid #444;
  padding: 10px;
  overflow-y: auto;
  max-height: 300px;
}

.recipe-item {
  padding: 8px;
  background: #333;
  margin-bottom: 6px;
  border-radius: 4px;
  font-size: 12px;
  color: #ccc;
  cursor: pointer;
}

.recipe-item:hover {
  background: #444;
  color: #fff;
}

.recipe-item.recipe-warp-key {
  position: relative;
  border: 1px solid rgba(255, 226, 120, 0.5);
  animation: recipe-warp-key-glow 1.5s ease-in-out infinite;
}

@keyframes recipe-warp-key-glow {
  0%, 100% { box-shadow: 0 0 12px rgba(255, 204, 64, 0.35), 0 0 24px rgba(255, 204, 64, 0.12); }
  50% { box-shadow: 0 0 16px rgba(255, 204, 64, 0.5), 0 0 32px rgba(255, 204, 64, 0.2); }
}

#crafting-work-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: #252525;
  border-radius: 4px;
}

#crafting-input-grid {
  display: grid;
  grid-template-columns: repeat(3, 50px);
  gap: 4px;
}

.crafting-slot {
  width: 50px;
  height: 50px;
  background: #1a1a1a;
  border: 1px solid #555;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.crafting-slot.has-item {
  cursor: grab;
}

.crafting-arrow {
  font-size: 24px;
  color: #888;
  margin: 10px 0;
}

#craft-btn {
  margin-top: auto;
  width: 100%;
  padding: 10px;
  background: #3a6ea5;
  border: none;
  color: white;
  border-radius: 4px;
  cursor: pointer;
}

#craft-btn:disabled {
  background: #444;
  cursor: not-allowed;
  opacity: 0.5;
}

/* --- Refinery Menu --- */
#refinery-menu-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--game-width);
  height: var(--game-height);
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  z-index: 10;
  pointer-events: auto;
  cursor: default;
}

#refinery-menu {
  background: rgba(30, 30, 30, 0.95);
  padding: 20px;
  border-radius: 8px;
  min-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 1px solid #666;
  pointer-events: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

#refinery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#refinery-header span {
  color: #eee;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 18px;
}

#refinery-header button {
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid #666;
  border-radius: 4px;
  background: #444;
  color: #fff;
}

#refinery-accepted-label {
  color: #aaa;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 12px;
}

#refinery-main {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
}

#refinery-input-area,
#refinery-output-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.refinery-section-title {
  color: #bbb;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 12px;
  text-transform: uppercase;
}

#refinery-input-grid,
#refinery-output-grid {
  display: grid;
  grid-template-columns: repeat(2, 50px);
  gap: 4px;
}

#refine-btn {
  width: 100%;
  padding: 10px;
  background: #6a8a3a;
  border: none;
  color: white;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 14px;
}

#refine-btn:disabled {
  background: #444;
  cursor: not-allowed;
  opacity: 0.5;
}

#shipyard-menu-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--game-width);
  height: var(--game-height);
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  z-index: 10;
  pointer-events: auto;
  cursor: default;
}

#shipyard-menu {
  background: rgba(30, 30, 30, 0.95);
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid #555;
  pointer-events: auto;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.6);
  max-width: 900px;
  max-height: 800px;
  overflow-y: auto;
}

#shipyard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#shipyard-header span {
  color: #eee;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 16px;
}

#shipyard-header button {
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid #666;
  border-radius: 4px;
  background: #444;
  color: #fff;
}

#shipyard-header button:hover {
  background: #555;
}

.shipyard-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

#shipyard-credits {
  color: #aaa;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 12px;
}

.shipyard-section-label {
  color: #888;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.shipyard-cards {
  display: flex;
  flex-direction: row;
  gap: 8px;
  flex-wrap: wrap;
}

.shipyard-card {
  display: flex;
  flex-direction: column;
  width: 221px;
  background: #1e1e1e;
  border: 1px solid #444;
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.shipyard-card:hover {
  border-color: #777;
}

.shipyard-card.current {
  border-color: #5a5;
}

.shipyard-card-content-row {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.shipyard-card-body {
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 0 0 auto;
  justify-content: center;
  min-width: 0;
}

.shipyard-card-preview {
  width: 96px;
  height: 64px;
  flex-shrink: 0;
  background: transparent;
  position: relative;
  overflow: hidden;
}

.shipyard-card-preview canvas {
  width: 96px;
  height: 64px;
  display: block;
}

.shipyard-card-title-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 6px;
  padding: 6px 8px 2px;
  width: 100%;
  box-sizing: border-box;
}

.shipyard-card-name {
  color: #fff;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.shipyard-card-desc {
  color: #888;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 11px;
  line-height: 1.2;
  flex: 1;
  min-width: 0;
  min-height: calc(1.2em * 3);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.shipyard-card-stats {
  display: grid;
  grid-template-columns: max-content max-content;
  gap: 0 1px;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 11px;
  color: #aaa;
  margin-top: 0;
  justify-content: start;
}

.shipyard-stat-label {
  color: #666;
}

.shipyard-stat-value {
  color: #ccc;
  text-align: left;
}

.shipyard-card-action {
  margin-top: 2px;
}

.shipyard-card-btn {
  width: 100%;
  padding: 4px 6px;
  border: none;
  border-radius: 4px;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.shipyard-card-btn.buy {
  background: #3a6ea5;
  color: #fff;
}

.shipyard-card-btn.buy:hover:not(:disabled) {
  background: #4a8ed5;
}

.shipyard-card-btn.buy:disabled {
  background: #333;
  color: #666;
  cursor: not-allowed;
}

.shipyard-card-btn.swap {
  background: #3a5a3a;
  color: #cfc;
}

.shipyard-card-btn.swap:hover {
  background: #4a7a4a;
}

.shipyard-card-btn.current-ship {
  background: #2a2a2a;
  color: #5a5;
  cursor: default;
  border: 1px solid #3a3a3a;
}

.shipyard-drone-controls {
  border: 1px solid #444;
  border-radius: 4px;
  padding: 6px 8px;
  background: rgba(20, 20, 20, 0.9);
  display: flex;
  align-items: center;
  gap: 8px;
}

.shipyard-drone-title {
  color: #dbeeff;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.shipyard-drone-status {
  color: #9fb5c9;
  font-size: 10px;
  flex: 1;
}

.shipyard-drone-buy-btn {
  border: 1px solid #4f6c86;
  background: #34516a;
  color: #fff;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 10px;
  cursor: pointer;
}

.shipyard-drone-buy-btn:hover:not(:disabled) {
  background: #406789;
}

.shipyard-drone-buy-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#shop-menu-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--game-width);
  height: var(--game-height);
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  z-index: 10;
  pointer-events: auto;
  cursor: default;
}

#shop-item-tooltip {
  position: absolute;
  background: rgba(20, 20, 20, 0.95);
  border: 1px solid #888;
  border-radius: 6px;
  padding: 8px 12px;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 12px;
  color: #fff;
  z-index: 100;
  pointer-events: none;
  max-width: 220px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

#shop-item-tooltip .tooltip-name {
  font-weight: bold;
  font-size: 13px;
  color: #ffcc44;
  margin-bottom: 4px;
}

#shop-item-tooltip .tooltip-price {
  color: #88ff88;
  margin-bottom: 6px;
}

#shop-item-tooltip .tooltip-usage {
  color: #aaa;
  font-size: 11px;
  line-height: 1.4;
}

#hotbar-item-tooltip {
  position: absolute;
  background: rgba(20, 20, 20, 0.65);
  border: 1px solid rgba(136, 136, 136, 0.7);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 12px;
  color: #fff;
  z-index: 100;
  pointer-events: none;
  max-width: 220px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

#hotbar-item-tooltip .tooltip-name {
  font-weight: bold;
  font-size: 13px;
  color: #ffcc44;
  margin-bottom: 4px;
}

#hotbar-item-tooltip .tooltip-price {
  color: #88ff88;
  margin-bottom: 6px;
}

#hotbar-item-tooltip .tooltip-usage {
  color: #aaa;
  font-size: 11px;
  line-height: 1.4;
}

#shop-menu {
  background: rgba(30, 30, 30, 0.95);
  padding: 20px;
  border-radius: 8px;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 1px solid #666;
  pointer-events: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

#shop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#shop-header span {
  color: #eee;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 18px;
}

.shop-title-row {
  display: flex;
  align-items: center;
  gap: 24px;
}

#shop-credits-display {
  color: #eee;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 18px;
}

#shop-main {
  display: flex;
  flex-direction: row;
  gap: 24px;
  align-items: flex-start;
}

#shop-buy-area,
#shop-sell-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shop-section-title {
  color: #bbb;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 12px;
  text-transform: uppercase;
}

#shop-buy-slots,
#shop-sell-slots {
  display: grid;
  grid-template-columns: repeat(6, 40px);
  gap: 0;
}

.shop-buy-slot {
  width: 40px;
  height: 40px;
  box-sizing: border-box;
  border: 1px solid var(--slot-border);
  background: var(--slot-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 12px;
  position: relative;
  user-select: none;
  overflow: hidden;
}

.shop-buy-slot.has-item {
  cursor: grab;
}

.shop-buy-slot.has-item:active {
  cursor: grabbing;
}

#shop-price-list {
  margin-top: 8px;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 11px;
  color: #ccc;
}

#shop-price-list .price-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}

#shop-price-list .price-label {
  color: #aaa;
}

#shop-price-list .price-value {
  color: #9c9;
}

/* Generic slot child elements */
.slot-icon {
  margin-top: -4px;
}

.slot-icon-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.slot-icon-ore-wrap {
  position: relative;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slot-icon-ore-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 0;
}

.slot-icon-ore-letter {
  position: relative;
  z-index: 1;
  font-size: 12px;
  color: #fff;
  text-shadow: 0 0 2px #000, 0 1px 2px #000;
  pointer-events: none;
}

.slot-energy {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: #aaffaa;
}

.slot-bar {
  position: absolute;
  right: 3px;
  top: 3px;
  width: 5px;
  height: 32px;
  background: #333;
}

.slot-bar-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
}

.slot-qty {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 10px;
  color: #aaa;
}

.slot-tier {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: #888;
  pointer-events: none;
}

.slot-num {
  position: absolute;
  top: 2px;
  left: 2px;
  font-size: 10px;
  color: #666;
}

/* Main Hotbar Slots */
.slot {
  width: 40px;
  height: 40px;
  box-sizing: border-box;
  border: 1px solid var(--slot-border);
  background: var(--slot-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 12px;
  position: relative;
  user-select: none;
  overflow: hidden;
  cursor: pointer;
}

.slot.selected {
  border: 2px solid #fff;
  background: #444;
}

.slot.has-item {
  cursor: grab;
}

.slot.has-item:active {
  cursor: grabbing;
}

/* Sell Slots */
.shop-sell-slot {
  width: 40px;
  height: 40px;
  box-sizing: border-box;
  border: 1px solid var(--slot-border);
  background: var(--slot-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 12px;
  position: relative;
  user-select: none;
  overflow: hidden;
}

.shop-sell-slot.has-item {
  cursor: grab;
}

.shop-sell-slot.has-item:active {
  cursor: grabbing;
}

.shop-sell-slot.droppable {
  border-color: #6a6;
  background: #2a3a2a;
}

#shop-sell-total {
  color: #9c9;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 14px;
  margin-top: 4px;
}

#shop-menu button {
  padding: 8px 16px;
  margin: 0 4px;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid #666;
  border-radius: 4px;
  background: #444;
  color: #fff;
}

#shop-menu button:hover:not(:disabled) {
  background: #555;
}

#shop-menu button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#oxygen-bar-drop-zone {
  position: absolute;
  left: 1050px;
  bottom: 20px;
  width: 40px;
  height: 60px;
  pointer-events: auto;
  z-index: 15;
  box-sizing: border-box;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}

#oxygen-bar-drop-zone.highlight {
  border-color: #fff;
}

#health-bar-drop-zone {
  position: absolute;
  left: 1150px;
  bottom: 20px;
  width: 40px;
  height: 100px;
  pointer-events: auto;
  z-index: 15;
  box-sizing: border-box;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}

#health-bar-drop-zone.highlight {
  border-color: #fff;
}

#fuel-bar-drop-zone {
  position: absolute;
  left: 1100px;
  bottom: 20px;
  width: 40px;
  height: 50px;
  pointer-events: auto;
  z-index: 15;
  box-sizing: border-box;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}

#fuel-bar-drop-zone.highlight {
  border-color: #fff;
}

#hud-overlay {
  position: absolute;
  /* Hotbar is 360px wide, centered in 1200px = starts at 420px */
  left: 420px;
  bottom: 0;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  z-index: 15;
}

#extended-inventory {
  display: none;
  flex-direction: column;
  align-items: flex-start;
}

.extended-inventory-row {
  display: flex;
  flex-direction: row;
  width: 360px;
  background: rgba(20, 20, 20, 0.75);
  border: 1px solid #444;
}

#extended-inventory-top-row {
  border-bottom: none;
}

#extended-inventory-bottom-row {
  border-bottom: none;
}

#extended-inventory .ext-slot {
  background: #1a1a1a;
  border-color: #444;
}

#extended-inventory.visible {
  display: flex;
}

#hud-bottom-row {
  display: flex;
  flex-direction: row;
}

#hotbar {
  display: flex;
  flex-direction: row;
  gap: 0;
}

#hotbar-inventory-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid #555;
  background: #222;
  color: #ddd;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 12px;
  cursor: pointer;
}

#hotbar-inventory-toggle.is-active {
  background: #3b3b3b;
  color: #fff;
}

#credits {
  width: 80px;
  height: 40px;
  background: #222;
  border: 1px solid #555;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.credits-label {
  color: #ffcc00;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 12px;
}

.credits-value {
  color: #fff;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 14px;
}

#level-select-ui {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  pointer-events: auto;
}

#level-select-ui label {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.level-editor-link {
  margin-left: 0.75em;
}

#level-select {
  background: rgba(20, 20, 30, 0.75);
  color: #ccc;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 12px;
  cursor: pointer;
  outline: none;
}

#level-select:hover {
  border-color: rgba(255, 255, 255, 0.4);
  color: #fff;
}

#level-select:focus {
  border-color: rgba(100, 150, 255, 0.6);
}

#shop-drag-ghost {
  position: fixed;
  width: 40px;
  height: 40px;
  background: rgba(40, 40, 40, 0.8);
  border: 2px solid #aaa;
  color: #fff;
  font-family: 'Oxanium', Arial, sans-serif;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 9999;
}

#shop-drag-ghost img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

#mobile-controls-root {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  display: none;
}

body[data-touch-layout="phone"] #mobile-controls-root,
body[data-touch-layout="tablet"] #mobile-controls-root,
body[data-touch-layout="square"] #mobile-controls-root {
  display: block;
}

#mobile-joystick-zone {
  position: absolute;
  left: 16px;
  bottom: 16px;
  width: 190px;
  height: 190px;
  pointer-events: auto;
  touch-action: none;
}

#mobile-joystick-base,
#mobile-joystick-knob {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: none;
}

#mobile-joystick-base {
  width: 110px;
  height: 110px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: rgba(30, 30, 30, 0.22);
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.35);
}

#mobile-joystick-knob {
  width: 52px;
  height: 52px;
  border: 2px solid rgba(255, 255, 255, 0.62);
  background: rgba(230, 230, 230, 0.22);
}

#mobile-controls-root.joystick-active #mobile-joystick-base,
#mobile-controls-root.joystick-active #mobile-joystick-knob {
  display: block;
}

#mobile-controls-root.menus-active #mobile-joystick-zone,
#mobile-controls-root.menus-active #mobile-brake-btn,
#mobile-controls-root.menus-active #mobile-interact-btn,
#mobile-controls-root.menus-active #mobile-inventory-btn {
  display: none;
}

.mobile-control-btn {
  position: absolute;
  width: 72px;
  height: 72px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: #f2f2f2;
  background: rgba(20, 20, 20, 0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  pointer-events: auto;
  touch-action: none;
  font-size: 13px;
  -webkit-user-select: none;
  user-select: none;
}

.mobile-control-btn:active,
.mobile-control-btn.is-active {
  background: rgba(80, 80, 80, 0.45);
}

#mobile-brake-btn {
  left: 224px;
  bottom: 62px;
}

#mobile-interact-btn {
  right: 106px;
  bottom: 122px;
}

#mobile-pause-btn {
  right: 16px;
  top: 16px;
  width: 64px;
  height: 64px;
}

#mobile-inventory-btn {
  right: 16px;
  bottom: 122px;
  display: none;
}

body[data-touch-layout] #game-canvas {
  cursor: default;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

body[data-touch-layout] .slot,
body[data-touch-layout] .shop-buy-slot,
body[data-touch-layout] .shop-sell-slot,
body[data-touch-layout] .crafting-slot {
  min-width: 48px;
  min-height: 48px;
}

body[data-touch-layout] #level-select-ui {
  font-size: 14px;
  gap: 8px;
}

body[data-touch-layout] #hud-overlay {
  left: 50%;
  transform: translateX(-50%);
}

body[data-touch-layout] #hotbar-inventory-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  font-size: 13px;
}

body[data-touch-layout] #oxygen-bar-drop-zone {
  left: calc(var(--game-width) - 150px);
}

body[data-touch-layout] #fuel-bar-drop-zone {
  left: calc(var(--game-width) - 100px);
}

body[data-touch-layout] #health-bar-drop-zone {
  left: calc(var(--game-width) - 50px);
}

@media (max-width: 900px) {
  body[data-touch-layout] {
    align-items: stretch;
    justify-content: stretch;
    background: #0f0f0f;
  }

  body[data-touch-layout] #game-container {
    width: 100vw;
    height: 100vh;
    box-shadow: none;
  }

  body[data-touch-layout] #game-canvas,
  body[data-touch-layout] #ship-canvas,
  body[data-touch-layout] #ui-canvas,
  body[data-touch-layout] #main-menu-overlay,
  body[data-touch-layout] #save-browser-overlay,
  body[data-touch-layout] #intro-cutscene-overlay,
  body[data-touch-layout] #mothership-intro-overlay,
  body[data-touch-layout] #start-menu-overlay,
  body[data-touch-layout] #pause-menu-overlay,
  body[data-touch-layout] #warp-menu-overlay,
  body[data-touch-layout] #crafting-menu-overlay,
  body[data-touch-layout] #shipyard-menu-overlay,
  body[data-touch-layout] #refinery-menu-overlay,
  body[data-touch-layout] #shop-menu-overlay,
  body[data-touch-layout] #death-menu-overlay {
    width: 100vw;
    height: 100vh;
  }

  body[data-touch-layout] #crafting-menu,
  body[data-touch-layout] #refinery-menu,
  body[data-touch-layout] #shop-menu {
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    overflow: auto;
  }
}

@media (min-width: 901px) and (max-width: 1280px) {
  body[data-touch-layout="tablet"] #mobile-joystick-zone,
  body[data-touch-layout="square"] #mobile-joystick-zone {
    width: 220px;
    height: 220px;
  }

  body[data-touch-layout="tablet"] #mobile-brake-btn,
  body[data-touch-layout="square"] #mobile-brake-btn {
    left: 252px;
    bottom: 72px;
  }

  body[data-touch-layout="tablet"] .mobile-control-btn,
  body[data-touch-layout="square"] .mobile-control-btn {
    width: 80px;
    height: 80px;
  }
}
