:root {
  --ui-bg: rgba(21, 36, 67, 0.84);
  --ui-border: rgba(255,255,255,0.14);
  --ui-text: rgba(245,245,250,0.96);
  --ui-subtext: rgba(205,214,231,0.82);
  --gold: #f2c84b;
  --green: #1ea85b;
  --blue: #3b5aa8;
  --red: #b43b3b;
}
html, body {
  margin: 0;
  height: 100%;
  background: #0a1c36;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ui-text);
  overflow: hidden;
}
.hidden { display: none !important; }
#gameShell, #ui { height: 100%; }
#ui {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  position: relative;
}
.topbar, .bottombar {
  display: flex;
  gap: 10px;
  padding: 12px;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(8px);
}
.topRight, .actions, .wideActions, .repTop, .invHeader, .gate-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.badge, .panel, .inventoryWidget, .repWidget, .adminDrawer, .card, .gate-card {
  background: linear-gradient(180deg, #233e79 0%, #162b57 100%);
  border: 1px solid var(--ui-border);
  box-shadow: 0 10px 24px rgba(0,0,0,0.25);
  border-radius: 14px;
}
.badge {
  padding: 8px 14px;
  font-weight: 800;
  white-space: nowrap;
}
.panel {
  padding: 12px 14px;
  min-width: 210px;
}
.miniPanel { min-width: 170px; }
.panelTitle {
  font-weight: 800;
  letter-spacing: .08em;
  font-size: 12px;
}
.panelSub, .repSub, .adminText {
  color: var(--ui-subtext);
  font-size: 12px;
  margin-top: 4px;
}
.bar, .repBar, .fishingMeter {
  height: 10px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.bar { margin-top: 8px; }
.barFill, .repFill {
  height: 100%;
  width: 0;
  background: var(--gold);
}
.repFill { background: #67c0ff; }
#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #0b1630;
  touch-action: none;
}
.bottombar {
  padding-top: 0;
}
.hudStack {
  flex: 1;
  display: flex;
  gap: 10px;
  min-width: 0;
}
.inventoryWidget, .repWidget {
  padding: 12px;
}
.inventoryWidget { flex: 1; min-width: 220px; }
.repWidget { width: 220px; }
.inventoryGrid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.invSlot {
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  min-height: 86px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
}
.invSlot.selected { outline: 2px solid var(--gold); }
.invSlot.empty { opacity: .5; }
.invSlot img { width: 28px; height: 28px; object-fit: contain; }
.invToggle, button, .btn {
  border: 0;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 800;
  color: #fff;
  background: var(--green);
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0,0,0,.22);
}
button.secondary, .btn { background: var(--blue); }
button.danger { background: var(--red); }
button.small, .invToggle { padding: 8px 10px; font-size: 12px; }
button:disabled { opacity: .55; background: #355; cursor: default; }
.depositBtn { min-width: 150px; }
.banner, .tutorialBubble, .tileHint, .toast {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 12px;
  box-shadow: 0 8px 18px rgba(0,0,0,.35);
}
.banner {
  top: 64px;
  background: rgba(242,200,75,.96);
  color: #1b1403;
  padding: 10px 14px;
  font-weight: 900;
}
.tutorialBubble {
  top: 108px;
  background: rgba(27,45,87,.96);
  color: #fff;
  padding: 12px 14px;
  max-width: min(500px, 92vw);
  text-align: center;
  border: 1px solid rgba(255,255,255,.12);
}
.tileHint {
  bottom: 162px;
  background: rgba(15,25,48,.95);
  padding: 8px 12px;
  color: var(--ui-subtext);
  font-size: 12px;
}
.toast {
  bottom: 18px;
  background: rgba(15,25,48,.95);
  padding: 10px 14px;
}
.adminDrawer {
  margin: 0 12px 12px;
  padding: 12px;
}
.adminTitle { font-weight: 800; }
#resetSqlOutput {
  width: 100%;
  min-height: 130px;
  margin-top: 8px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.18);
  color: #fff;
  padding: 10px;
  resize: vertical;
  font: 12px/1.35 ui-monospace, monospace;
}
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.55);
}
.card {
  width: min(360px, 88vw);
  padding: 18px;
  text-align: center;
}
.title { font-size: 22px; font-weight: 900; }
.subtitle { margin-top: 8px; color: var(--ui-subtext); font-size: 14px; }

.fishingCard { width: min(520px, 92vw); }
.fishingSceneWrap { display:flex; gap:14px; align-items:stretch; margin:16px 0 10px; }
.fishingScene {
  position:relative; flex:1; min-height:220px; border-radius:16px;
  background: linear-gradient(180deg, #5aa0d0 0%, #1c4b7a 52%, #0d2740 100%);
  border:1px solid rgba(255,255,255,.10); overflow:hidden;
}
.depthLabel { position:absolute; left:10px; font-size:11px; color:rgba(255,255,255,.72); }
.depthTop { top:8px; }
.depthBottom { bottom:8px; }
.depthLine { position:absolute; left:0; right:0; height:1px; background:rgba(255,255,255,.16); top:20%; }
.depthLine.line2 { top:40%; }
.depthLine.line3 { top:60%; }
.depthLine.line4 { top:80%; }
.verticalMeter {
  position:relative;
  width:42px; min-height:248px; height:248px; margin:0;
  border-radius:24px;
  background: linear-gradient(180deg, rgba(8,18,45,.98), rgba(17,32,74,.96));
  border:1px solid rgba(255,255,255,.16);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.05), 0 10px 26px rgba(0,0,0,.26);
  overflow:visible;
}
.verticalMeter::before {
  content:''; position:absolute; inset:8px 10px;
  border-radius:999px;
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
}
.catchZone {
  position:absolute; left:5px; right:5px; top:auto;
  border-radius:999px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.16), 0 0 14px rgba(124,255,193,.26);
}
.fishMarker {
  position:absolute; left:-6px; width:54px; height:12px; top:auto;
  border-radius:999px;
  background: linear-gradient(90deg, rgba(255,210,86,0), #ffd65a 16%, #fff0a4 50%, #ffd65a 84%, rgba(255,210,86,0));
  box-shadow: 0 0 12px rgba(255,214,90,.65);
}
.fishMarker.caught {
  box-shadow: 0 0 16px rgba(255,230,133,.85);
}
.fishingTargetFish {
  position:absolute; left:50%; width:50px; height:30px; margin-left:-25px;
  background-image:url('assets/fish.png'); background-repeat:no-repeat; background-position:center; background-size:contain;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,.34));
  transition: bottom .14s linear, transform .18s ease, filter .18s ease;
}
.fishingTargetFish.rare {
  filter: drop-shadow(0 0 10px rgba(173,123,255,.55)) drop-shadow(0 6px 8px rgba(0,0,0,.34)) hue-rotate(25deg) saturate(1.35);
}
.fishingTargetFish.caught {
  transform: scale(1.08) rotate(-8deg);
  filter: drop-shadow(0 0 18px rgba(255,220,120,.55)) drop-shadow(0 6px 10px rgba(0,0,0,.35));
}
.fishingHook {
  position:absolute; left:50%; width:3px; margin-left:-1.5px; top:0;
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(217,226,235,.72) 45%, rgba(146,159,170,.55) 100%);
  border-radius:999px;
  box-shadow: 0 0 6px rgba(255,255,255,.22);
}
.fishingHook::before {
  content:''; position:absolute; left:50%; bottom:-1px; width:6px; height:6px; margin-left:-3px;
  background: radial-gradient(circle, rgba(255,255,255,.96) 0%, rgba(214,225,236,.55) 60%, rgba(214,225,236,0) 72%);
}
.fishingHook::after {
  content:''; position:absolute; left:50%; bottom:-14px; width:14px; height:18px; margin-left:-2px;
  border-right:3px solid rgba(248,250,253,.96);
  border-bottom:3px solid rgba(248,250,253,.96);
  border-bottom-right-radius:13px;
  transform: translateX(-50%) rotate(8deg);
  box-shadow: inset -1px -1px 0 rgba(140,150,162,.38);
}
.fishingHook.caught::after {
  box-shadow: 0 0 14px rgba(255,214,90,.34), inset -1px -1px 0 rgba(140,150,162,.38);
}
.rareFishBadge {
  margin: 0 auto 12px; width:max-content; padding:6px 10px; border-radius:999px;
  background:rgba(136,85,221,.18); border:1px solid rgba(136,85,221,.48); color:#d8c7ff; font-weight:800; font-size:12px;
}

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.gate-card {
  width: min(540px, 94vw);
  padding: 24px;
}
.gate-kicker {
  color: var(--ui-subtext);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.gate-card input {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.06);
  color: #fff;
}
.gate-error { color: #ffb8b8; margin-top: 8px; }
@media (max-width: 900px) {
  #ui { grid-template-rows: auto 1fr auto auto; }
  .topbar, .bottombar, .topRight, .hudStack, .actions { flex-wrap: wrap; }
  .repWidget, .inventoryWidget, .panel { width: 100%; min-width: 0; }
  .inventoryGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tileHint { bottom: 220px; }
  html, body { overflow: auto; }
  #ui { height: auto; min-height: 100%; }
  #gameCanvas { min-height: 58vh; }
}


.hiddenReset{
  position:absolute;
  left:-9999px;
  width:1px;
  height:1px;
  opacity:0;
  pointer-events:none;
}

#ui{
  grid-template-rows:auto 1fr auto;
  min-height:100vh;
}

.adminDrawer{display:none;}

.bottombar{
  position:relative;
  z-index:5;
  flex-wrap:wrap;
  gap:12px;
}

.actions{
  flex-wrap:wrap;
  justify-content:flex-end;
}

#gameCanvas{
  min-height:0;
}

@media (min-width: 980px) and (orientation: landscape){
  #ui{
    grid-template-rows:auto 1fr;
  }
  .bottombar{
    position:absolute;
    left:12px;
    right:12px;
    bottom:12px;
    border-radius:16px;
    background:linear-gradient(180deg, rgba(35,62,121,.86), rgba(22,43,87,.90));
    border:1px solid var(--ui-border);
    box-shadow:0 10px 24px rgba(0,0,0,.28);
    backdrop-filter:blur(8px);
    padding:12px;
  }
  .tileHint{
    bottom:110px;
  }
}

@media (max-width: 979px){
  html, body{
    overflow:hidden;
  }
  #ui{
    grid-template-rows:auto 1fr auto;
  }
  .bottombar{
    padding:10px 12px 12px;
  }
}

@media (max-width: 760px){
  .topbar{
    flex-wrap:wrap;
  }
  .topRight{
    width:100%;
    flex-wrap:wrap;
  }
  .panel{
    min-width:0;
    flex:1 1 220px;
  }
  .hudStack{
    width:100%;
    flex-direction:column;
  }
  .repWidget, .inventoryWidget{
    width:100%;
    min-width:0;
  }
  .actions{
    width:100%;
  }
  .actions button{
    flex:1 1 160px;
  }
}
