:root {
  --ocean-deep: #0B3C5D;
  --ocean-mid: #1E88C7;
  --ocean-light: #7FD8E8;
  --sand: #F6E7C1;
  --danger: #E05252;
  --warn: #F0A93E;
  --good: #4CAF7D;
  --card-bg: #FFFFFF;
  --text-dark: #1A2B3C;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text-dark);
  background: var(--ocean-deep);
}

body {
  display: flex;
  flex-direction: column;
}

#topBar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(11, 60, 93, 0.9);
  z-index: 20;
}

.coin-badge {
  background: var(--sand);
  color: var(--text-dark);
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14px;
  white-space: nowrap;
}

.topbar-clean {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.clean-label {
  color: #E8F6FB;
  font-size: 13px;
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  gap: 6px;
}

.icon-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 12px;
  font-size: 20px;
  padding: 6px 10px;
  cursor: pointer;
}

.bar {
  flex: 1;
  height: 10px;
  background: rgba(255,255,255,0.25);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--good);
  transition: width 0.6s ease;
}
.bar-fill.bar-warn { background: var(--warn); }
.bar-fill.bar-danger { background: var(--danger); }

#tank {
  flex: 1;
  position: relative;
  background: linear-gradient(180deg, var(--ocean-light) 0%, var(--ocean-mid) 55%, var(--ocean-deep) 100%);
  overflow: hidden;
}

#tank::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(255,255,255,0.08), transparent 40%),
    radial-gradient(circle at 80% 30%, rgba(255,255,255,0.06), transparent 35%);
  pointer-events: none;
}

.deco-strip {
  position: absolute;
  bottom: 6px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 18px;
  font-size: 30px;
  pointer-events: none;
  z-index: 1;
}

.fish-wrap {
  position: absolute;
  width: 78px;
  height: 66px;
  transition-property: left, top;
  transition-timing-function: ease-in-out;
  cursor: pointer;
  z-index: 5;
  animation: bob 2.4s ease-in-out infinite;
}

.fish-wrap.facing-left .fish-svg,
.fish-wrap.facing-left .photo-fish {
  transform: scaleX(-1);
}

.fish-wrap.fish-egg {
  animation: none;
}

.fish-wrap.fish-sick { filter: grayscale(0.4); }

@keyframes bob {
  0%, 100% { margin-top: 0px; }
  50% { margin-top: 6px; }
}

.fish-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 3px 3px rgba(0,0,0,0.25));
}

.egg-svg { filter: drop-shadow(0 3px 3px rgba(0,0,0,0.2)); }

.fish-label {
  text-align: center;
  font-size: 11px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-fish {
  position: relative;
  width: 100%;
  height: 100%;
}
.photo-fish-body {
  position: absolute;
  inset: 4% 8%;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  box-shadow: 0 3px 4px rgba(0,0,0,0.3);
  clip-path: ellipse(46% 38% at 50% 50%);
}
.photo-fish-fins {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.photo-fish-sad .photo-fish-body { filter: grayscale(0.5) brightness(0.9); }
.photo-fish-dull .photo-fish-body { filter: saturate(0.45) brightness(0.85); }
.photo-fish-sparkly .photo-fish-body { filter: saturate(1.3) drop-shadow(0 0 6px rgba(255,255,150,0.8)); }

#actionBar {
  display: flex;
  gap: 10px;
  padding: 12px;
  background: rgba(11, 60, 93, 0.95);
  justify-content: center;
  z-index: 20;
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 700;
  background: var(--ocean-mid);
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-accent { background: var(--warn); color: #3A2500; }
.btn-secondary { background: #E8F6FB; color: var(--text-dark); }
.btn-small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }

.file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal.open { display: flex; }

.modal-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 20px;
  max-width: 420px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: #F0F0F0;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 15px;
  cursor: pointer;
}

.detail-visual {
  width: 140px;
  height: 120px;
  margin: 8px auto 4px;
}

.name-input {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  border: none;
  border-bottom: 2px solid #E0E0E0;
  padding: 6px 4px;
  margin-bottom: 6px;
}

.stage-badge {
  text-align: center;
  color: var(--ocean-mid);
  font-weight: 700;
  margin-bottom: 12px;
  text-transform: capitalize;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 14px;
}
.stat-row .bar { height: 12px; }

.hint {
  font-size: 13px;
  color: #666;
  text-align: center;
}
.hint-danger { color: var(--danger); font-weight: 600; }

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
}

.minigame-canvas {
  width: 100%;
  height: 340px;
  border-radius: 14px;
  background: var(--ocean-mid);
  touch-action: none;
  display: block;
}

.shop-item, .roster-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #EEE;
  font-size: 14px;
}
.shop-item-name, .roster-name { flex: 1; }
.shop-item-cost { color: #888; white-space: nowrap; }
.shop-list { margin-bottom: 8px; }

.deco-emoji { font-size: 28px; }

.tab-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.tab-btn {
  flex: 1;
  border: none;
  background: #EEE;
  color: #666;
  font-weight: 700;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
}
.tab-btn.active {
  background: var(--ocean-mid);
  color: #fff;
}

.gift-panel { }

.gift-choice-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #EEE;
  font-size: 14px;
  cursor: pointer;
}
.gift-choice-row.selected {
  background: #E8F6FB;
  border-radius: 8px;
}

.gift-qr-area {
  text-align: center;
  margin-top: 14px;
}
.gift-qr-area svg {
  width: 220px;
  height: 220px;
}

.gift-scan-video {
  width: 100%;
  max-height: 300px;
  border-radius: 14px;
  background: #000;
  object-fit: cover;
  margin-top: 10px;
}

.help-section {
  margin-bottom: 16px;
}
.help-section h3 {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--ocean-mid);
}
.help-section p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #444;
}

.gift-result-card {
  text-align: center;
  margin-top: 14px;
  padding: 14px;
  background: #FFF7E0;
  border-radius: 14px;
}

#photoPreviewArea {
  text-align: center;
  margin-top: 12px;
}
#photoPreviewArea .photo-fish {
  width: 140px;
  height: 120px;
  margin: 8px auto;
}

@media (min-width: 720px) {
  .modal-card { max-width: 520px; }
  #actionBar .btn { padding: 14px 26px; font-size: 16px; }
}
