* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: #0d1117;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #e6edf3;
  overflow: hidden;
  touch-action: none;
}
#wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
}
#hud {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #161b22 0%, #0d1117 100%);
  border-bottom: 2px solid #30363d;
  font-size: 13px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}
.stat {
  background: #21262d;
  border-radius: 8px;
  padding: 8px 10px;
  border: 1px solid #30363d;
}
.stat b {
  color: #58a6ff;
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.stat span {
  font-size: 18px;
  font-weight: 700;
  color: #f0f6fc;
  line-height: 1.25;
  min-height: 1.2em;
  display: inline-block;
  font-variant-numeric: tabular-nums;
}
.stat-satisfaction .sat-meter {
  height: 8px;
  border-radius: 4px;
  background: #30363d;
  overflow: hidden;
  margin: 4px 0 2px;
  border: 1px solid #484f58;
}
.stat-satisfaction .sat-meter-fill {
  height: 100%;
  width: 50%;
  border-radius: 3px;
  transition: width 0.2s ease, background 0.25s ease;
}
#gameRow {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}
#canvasWrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  max-height: 100%;
  line-height: 0;
}
#canvasWrap #c {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
  background: #1a2f1a;
  cursor: crosshair;
}
#groundUpgradeLayer {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  border-radius: 12px;
  overflow: hidden;
}
/* —— Ground upgrade kiosks (fishing bank + shop floor + display) —— */
.ground-upg {
  position: absolute;
  width: 48px;
  height: 48px;
  pointer-events: auto;
  z-index: 3;
  transition: opacity 0.12s ease, left 0.08s linear, top 0.08s linear;
  transform-origin: center center;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.38));
}
.ground-upg--hidden {
  opacity: 0;
  pointer-events: none !important;
  visibility: hidden;
}
.ground-upg-tile {
  --upg-accent: #58a6ff;
  width: 100%;
  height: 100%;
  border-radius: 9px;
  overflow: hidden;
  background: linear-gradient(160deg, #2b313a 0%, #1c2128 45%, #161b22 100%);
  border: 1px solid #3d444d;
  border-left: 4px solid var(--upg-accent);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2),
    0 3px 0 #0d1117,
    0 10px 22px rgba(0, 0, 0, 0.4);
}
.ground-upg-kind-bag { --upg-accent: #ff9800; }
.ground-upg-kind-delivery { --upg-accent: #fb8c00; }
.ground-upg-kind-capacity { --upg-accent: #26c6da; }
.ground-upg-kind-speed { --upg-accent: #ffee58; }
.ground-upg-tile-head {
  display: none;
}
.ground-upg-tile-ico {
  font-size: 20px;
  line-height: 1;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4));
}
.ground-upg-tile-sku {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #8b949e;
}
.ground-upg-tile-body {
  display: none;
}
.ground-upg-tile-name {
  display: block;
  font-size: 10px;
  font-weight: 800;
  color: #e6edf3;
  line-height: 1.2;
  margin-bottom: 3px;
}
.ground-upg-tile-desc {
  display: block;
  font-size: 8px;
  color: #8b949e;
  line-height: 1.25;
}
.ground-upg-tile-foot {
  display: none;
}
.ground-upg-buy {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 3px 2px;
  margin: 0;
  border: none;
  border-radius: 0;
  background: linear-gradient(180deg, #ffb74d 0%, #f57c00 55%, #e65100 100%);
  color: #1a0500;
  cursor: pointer;
  font-family: inherit;
}
.ground-upg-buy-price {
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}
.ground-upg-upgrade {
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
}
.ground-upg-code {
  font-size: 8px;
  font-weight: 900;
  line-height: 1;
}
.ground-upg-pct {
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
}
.ground-upg-buy-hint {
  font-size: 7px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.85;
}
.ground-upg-buy:disabled {
  cursor: not-allowed;
  filter: grayscale(0.35) brightness(0.85);
}
.ground-upg-buy:disabled .ground-upg-buy-price,
.ground-upg-buy:disabled .ground-upg-buy-hint {
  color: #3e2723;
  text-shadow: none;
  opacity: 0.75;
}
.ground-upg--inreach .ground-upg-tile {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 2px rgba(63, 185, 80, 0.55),
    0 3px 0 #0d1117,
    0 12px 24px rgba(0, 0, 0, 0.45);
}
.ground-upg--inreach .ground-upg-tile-foot {
  background: linear-gradient(180deg, #c8e6c9 0%, #66bb6a 45%, #2e7d32 100%);
}
.ground-upg--inreach .ground-upg-buy {
  background: linear-gradient(180deg, #c8e6c9 0%, #66bb6a 45%, #2e7d32 100%);
  color: #0f2c14;
}
.ground-upg--inreach .ground-upg-buy:not(:disabled) .ground-upg-buy-hint {
  color: #1b5e20;
}
#help {
  padding: 8px 12px 12px;
  font-size: 12px;
  color: #8b949e;
  text-align: center;
  line-height: 1.5;
}

.tutorial-overlay {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  padding: 0 12px 10px;
  pointer-events: none;
  z-index: 5;
}
.tutorial-overlay.hidden {
  display: none !important;
}
.tutorial-card {
  pointer-events: auto;
  max-width: 560px;
  width: 100%;
  background: rgba(22, 27, 34, 0.94);
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 12px 16px 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
.tutorial-head {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #58a6ff;
  margin-bottom: 6px;
}
.tutorial-text {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.5;
  color: #e6edf3;
}
.tutorial-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.tutorial-next {
  flex: 1;
  min-width: 120px;
}
.tutorial-skip {
  flex: 0 0 auto;
  padding: 8px 14px;
  font-size: 13px;
}

.hidden { display: none !important; }

#gameScreen {
  height: 100%;
  display: flex;
  flex-direction: column;
}
#gameScreen #wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#titleScreen {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 120% 80% at 50% 20%, #1a2f4a 0%, #0d1117 55%);
  padding: 24px;
}
.title-inner {
  max-width: 560px;
  width: 100%;
  text-align: center;
}
#titleCanvas {
  display: block;
  margin: 0 auto 20px;
  border-radius: 16px;
  box-shadow:
    0 0 0 3px rgba(100, 200, 255, 0.25),
    0 20px 50px rgba(0, 0, 0, 0.5);
  background: #042034;
}
.title-brand {
  margin-bottom: 22px;
}
.title-brand h1 {
  font-size: clamp(2rem, 6vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #f0f6fc;
  text-shadow:
    0 0 40px rgba(79, 195, 247, 0.35),
    0 2px 0 #01579b;
  animation: title-float 3.2s ease-in-out infinite;
}
.title-tag {
  margin-top: 10px;
  font-size: 0.95rem;
  color: #8b949e;
  letter-spacing: 0.04em;
}
@keyframes title-float {
  0%, 100% { transform: translateY(0); opacity: 1; }
  50% { transform: translateY(-4px); opacity: 0.96; }
}
.title-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-bottom: 16px;
}
.btn-primary,
.btn-secondary,
.btn-ghost {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 28px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn-primary:active,
.btn-secondary:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(180deg, #2ea043 0%, #238636 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(46, 160, 67, 0.35);
}
.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(46, 160, 67, 0.45);
}
.btn-secondary {
  background: #21262d;
  color: #e6edf3;
  border: 1px solid #30363d;
}
.btn-secondary:hover { background: #30363d; }
.btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  color: #8b949e;
  border: 1px solid #30363d;
}
.btn-ghost:hover { color: #e6edf3; border-color: #484f58; }
.save-hint {
  font-size: 12px;
  color: #6e7681;
  max-width: 400px;
  margin: 0 auto;
  line-height: 1.45;
}

.update-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.78);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.update-overlay.open {
  display: flex;
}
.update-overlay.hidden {
  display: none !important;
}
.update-card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.update-card h2 {
  font-size: 22px;
  margin-bottom: 12px;
  color: #3fb950;
}
.update-body {
  font-size: 15px;
  line-height: 1.5;
  color: #e6edf3;
  margin: 0 0 22px;
}
.update-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.update-actions button {
  width: 100%;
}

.pause-overlay {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(0, 0, 0, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.pause-overlay.open { display: flex; }
.pause-card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 320px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.pause-card h2 {
  font-size: 22px;
  margin-bottom: 4px;
}
.pause-sub {
  font-size: 13px;
  color: #8b949e;
  margin-bottom: 20px;
}
.pause-card button {
  display: block;
  width: 100%;
  margin-bottom: 10px;
}
.pause-card .btn-ghost { margin-bottom: 0; }

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  z-index: 40;
  padding: 10px 20px;
  background: #238636;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
