:root {
  --ink: #2c4f49;
  --muted: #778d82;
  --accent: #548e76;
  --accent-dark: #396d58;
  --good: #64a982;
  --panel-solid: #fafcf7;
  --panel: rgba(250, 252, 247, 0.97);
}

html, body { background: #bce2e5; }
body, button { -webkit-user-select: none; -webkit-touch-callout: none; }
button { cursor: pointer; }
button:focus-visible { outline: 3px solid #407f6b; outline-offset: 3px; }
.app { width: 100%; max-width: none; padding: 0; background: #bce2e5; }
.stage { position: absolute; inset: 0; border: 0; border-radius: 0; box-shadow: none; background: #bce2e5; }
.stage::after { display: none; }
#worldCanvas, #gameCanvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#worldCanvas { cursor: grab; }
#worldCanvas:active { cursor: grabbing; }
.condition-chip, .scene-status, .toast { pointer-events: none; }
.view-reset { position: absolute; right: max(16px, env(safe-area-inset-right)); top: calc(max(12px, env(safe-area-inset-top)) + 156px); z-index: 2; display: grid; place-items: center; width: 40px; height: 40px; padding: 9px; border: 1px solid #eaf5e9; border-radius: 8px; color: #476e5a; background: #f4f9eff0; box-shadow: inset 0 1px 1px #fff, 0 3px 0 #74907966; touch-action: manipulation; }
.view-reset svg { width: 21px; height: 21px; }
.view-reset:active { transform: translateY(2px); box-shadow: inset 0 1px 3px #52785d33; }
.scene-fallback .view-reset { display: none; }
.has-3d #gameCanvas { display: none; }
[hidden] { display: none !important; }
.topbar {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  z-index: 4;
  margin: 0;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.topbar { transform: translateZ(0); }
.topbar, .controls, .meters { isolation: isolate; }
.brand { gap: 9px; }
.app-icon { width: 38px; height: 38px; border-radius: 11px; box-shadow: 0 2px 0 #477b6060, 0 4px 12px #25453b12; }
h1 { font-size: 21px; font-weight: 850; color: #294e45; text-shadow: 0 2px 0 #ffffff80; }
.top-actions { gap: 7px; }
.icon-button, .top-actions .tab {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 3px;
  width: 48px;
  height: 48px;
  border: 1px solid #ffffffb0;
  border-radius: 8px;
  background: #fbfdf4ed;
  box-shadow: 0 3px 0 #5c8a7538, 0 5px 14px #28534b0a;
  color: #47715f;
  font-size: 11px;
  font-weight: 750;
}
.top-actions svg { width: 19px; height: 19px; stroke-width: 1.8; }
.top-actions #shopButton { background: #fae5a5; color: #81633a; }
.top-actions .tab.active { background: #d7ebd9; color: #356b51; border-color: #71a282; }
.hud { display: flex; gap: 8px; justify-content: flex-start; }
.stat { display: flex; align-items: center; gap: 8px; padding: 9px 13px; min-height: 38px; border: 1px solid #ffffffa0; background: #fafff2ef; box-shadow: 0 3px 0 #62826a21; backdrop-filter: blur(8px); }
.stat span { font-size: 10px; font-weight: 700; white-space: nowrap; }
.stat strong { font-size: 12px; font-weight: 800; }
.stat:first-child { background: #fff0be; min-width: 90px; }
.stat:first-child strong { color: #8d6938; }
.stat:nth-child(2), .stat:nth-child(3) { cursor: pointer; }
.condition-chip {
  top: calc(max(12px, env(safe-area-inset-top)) + 106px);
  left: 19px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  width: fit-content;
  max-width: calc(100% - 38px);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  color: #34564e;
  font-size: 11px;
  line-height: 1.5;
  text-shadow: 0 1px 3px #ffffffc7;
  overflow: visible;
  white-space: normal;
}
.condition-chip span { white-space: nowrap; }
.session-settings { display:grid; grid-template-columns:1fr 1fr 44px; gap:12px; padding:16px 4px; align-items:center; }
.session-settings select { width:100%; min-height:44px; padding:8px; border:1px solid #93b6a4; border-radius:6px; background:#fff; color:#284d42; font:inherit; }
.session-settings > button { width:44px; height:44px; display:grid; place-items:center; padding:10px; }
.session-settings > p,.session-settings > h3,#crewList { grid-column:1 / -1; margin:0; }
.session-settings > p { font-size:12px; color:#526f60; }
.session-settings h3 { font-size:16px; padding-top:12px; }
.crew-choice { display:flex; gap:12px; padding:15px 4px; border-bottom:1px solid #cfdfd2; align-items:start; cursor:pointer; }
.crew-choice input { width:20px; height:20px; flex:0 0 20px; accent-color:#478a72; }
.crew-choice span { min-width:0; display:grid; gap:6px; }
.crew-choice small { font-size:12px; line-height:1.6; color:#526f60; }
.crew-choice b { font-size:13px; color:#386c59; }
.crew-choice:has(:checked) { background:#e7f3e9; }
.crew-choice:has(:disabled) { opacity:.65; }
.crew-portrait { width:72px; height:72px; flex:0 0 72px; object-fit:cover; border-radius:8px; background:#e6f0e6; }
[data-night="true"] .condition-chip,
[data-night="true"] .scene-status[data-mode="ready"],
[data-night="true"] .scene-status[data-mode="fishing"],
[data-night="true"] .scene-status[data-mode="charging"] { color: #eff9e9; text-shadow: 0 1px 3px #183934; }
.scene-status { position: absolute; top: calc(max(12px, env(safe-area-inset-top)) + 132px); left: 19px; z-index: 2; display: flex; align-items: center; gap: 7px; color: #365b50; font-size: 12px; font-weight: 700; text-shadow: 0 1px 3px #ffffffa0; }
.scene-status i { width: 6px; height: 6px; border-radius: 50%; background: #4f9076; }
.scene-status small { font-size: 11px; opacity: 0.8; }
.scene-status[data-mode="bite"], .scene-status[data-mode="fight"], .scene-status[data-mode="snag"] { padding: 7px 12px; left: 15px; border-radius: 8px; background: #fff8e8ee; color: #ad6650; }
.scene-status[data-mode="bite"] i, .scene-status[data-mode="fight"] i { background: #dc865c; }
.meters {
  position: absolute;
  z-index: 3;
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 86px);
  left: 50%;
  width: min(470px, calc(100% - 32px));
  transform: translateX(-50%);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid #ffffff96;
  border-radius: 8px;
  background: #f8fff0e6;
  backdrop-filter: blur(8px);
}
.meter { display: block; min-width: 0; }
.meter span { margin-bottom: 5px; font-size: 10px; color: #647f6e; }
.track { height: 6px; box-shadow: none; background: #dbe5d3; }
.track i { background: #7cad8b; box-shadow: none; }
.tension i { background: #dab36a; }
.stamina i { background: #80bcb1; }
.controls { position: absolute; z-index: 3; bottom: max(14px, env(safe-area-inset-bottom)); left: 50%; width: min(470px, calc(100% - 32px)); transform: translateX(-50%); grid-template-columns: 1.15fr 1fr 1fr 0.85fr; gap: 9px; }
.controls button, #castButton, #reelButton, #jerkButton, #pauseButton {
  height: 72px;
  min-height: 72px;
  border: 1px solid #ffffffb0;
  border-radius: 8px;
  background: #f8fcf1f5;
  box-shadow: 0 4px 0 #6f8c705c, 0 8px 17px #314d3220;
  color: #4d6e5e;
  font-size: 13px;
  font-weight: 800;
  gap: 4px;
}
.controls .primary#castButton { background: #699b77; border-color: #9cb58d; color: #fffbed; text-shadow: none; box-shadow: 0 4px 0 #3d7057, 0 8px 17px #314d3220; }
.controls .primary::before { display: none; }
.controls #jerkButton { background: #fff0d4f7; color: #947344; }
.control-icon, #castButton .control-icon, #reelButton .control-icon, #jerkButton .control-icon { display: flex; width: 27px; height: 27px; background: none; border: 0; border-radius: 0; }
.control-icon svg { width: 27px; height: 27px; stroke-width: 1.7; }
.controls button:active, .controls button.held { transform: translateY(3px); box-shadow: 0 1px 0 #6f8c705c; background: #dcebd7; }
.controls .primary#castButton:active, .controls .primary#castButton.held { background: #568966; box-shadow: 0 1px 0 #3d7057; }
.toast { left: 50%; right: auto; width: max-content; max-width: min(470px, calc(100% - 36px)); bottom: calc(max(14px, env(safe-area-inset-bottom)) + 148px); transform: translateX(-50%); min-height: 0; padding: 10px 17px; background: #fafff0ef; border: 1px solid #ffffff9c; box-shadow: 0 4px 14px #2b635127; color: #476650; font-size: 12px; font-weight: 650; }
.toast.hide { transform: translate(-50%, 8px); pointer-events: none; }
.panel.active { left: max(14px, calc((100vw - 550px) / 2)); right: max(14px, calc((100vw - 550px) / 2)); bottom: max(14px, env(safe-area-inset-bottom)); max-height: min(75dvh, 740px); border-radius: 8px; background: #f5f9ee; }
.panel-title { background: #f5f9ee; }
.bite-signal { position: absolute; z-index: 2; color: #fff9d7; font-size: 50px; line-height: 1; font-weight: 1000; transform: translate(-50%, -100%); text-shadow: 3px 3px 0 #d97653, -2px -2px 0 #d97653, 0 5px 12px #906d3e44; animation: bite-pop 0.36s infinite alternate; pointer-events: none; }
.catch-result { position: absolute; z-index: 6; top: 48%; left: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; width: min(300px, calc(100% - 40px)); padding: 22px; border-radius: 8px; border: 2px solid #ffffffc2; background: #f6f9eefa; box-shadow: 0 12px 50px #294b4340; pointer-events: none; animation: catch-in 0.3s ease-out; }
.catch-label { font-size: 12px; color: #6c9377; font-weight: 750; }
.catch-result canvas { width: 230px; max-width: 100%; height: auto; aspect-ratio: 380 / 220; }
.catch-result strong { font-size: 25px; }
.catch-result > span:not(.catch-label) { margin-top: 7px; font-size: 15px; color: #839079; }
.catch-result b { margin-top: 15px; color: #a78544; font-size: 17px; }
.stat, .meters, .toast, .panel.active { -webkit-backdrop-filter: none; backdrop-filter: none; }
.scene-fallback .scene-status { display: none; }
.scene-fallback .stage { inset: 128px 0 150px; }
.scene-fallback .condition-chip { top: 12px; left: 12px; max-width: 52%; }
.scene-fallback .toast { bottom: 12px; }
.scene-fallback .meters, .scene-fallback .controls { background-color: #f5f9ee; }
@keyframes bite-pop { from { transform: translate(-50%, -100%) scale(1); } to { transform: translate(-50%, -110%) scale(1.14); } }
@keyframes catch-in { from { opacity: 0; transform: translate(-50%, -44%) scale(0.95); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@media (max-width: 600px) {
  .topbar { left: 12px; right: 12px; grid-template-columns: 1fr; gap: 9px; }
  .brand { position: absolute; top: 0; left: 0; height: 42px; }
  .app-icon { width: 36px; height: 36px; }
  h1 { display: none; }
  .top-actions { padding-left: 48px; gap: 7px; }
  .icon-button, .top-actions .tab { flex: 1; width: auto; min-width: 0; height: 43px; gap: 2px; font-size: 10px; }
  .top-actions svg { width: 17px; height: 17px; }
  .hud { grid-column: 1; gap: 6px; }
  .stat { padding: 8px 10px; gap: 6px; min-width: 0; }
  .stat:first-child { min-width: 75px; }
  .stat:nth-child(2), .stat:nth-child(3) { flex: 1; }
  .stat span { font-size: 9px; }
  .stat strong { font-size: 11px; }
  .condition-chip { top: calc(max(12px, env(safe-area-inset-top)) + 101px); left: 17px; gap: 3px 10px; font-size: 10px; max-width: calc(100% - 34px); }
  .scene-status { top: calc(max(12px, env(safe-area-inset-top)) + 125px); left: 17px; font-size: 11px; }
}
@media (max-width: 350px) {
  .top-actions { gap: 4px; padding-left: 44px; }
  .stat { padding: 8px 7px; gap: 4px; }
  .stat:first-child { min-width: 63px; }
  .stat strong { font-size: 10px; }
  .controls { gap: 6px; }
}
@media (max-height: 650px) {
  .controls button, #castButton, #reelButton, #jerkButton, #pauseButton { height: 60px; min-height: 60px; gap: 2px; font-size: 12px; }
  .control-icon, #castButton .control-icon, #reelButton .control-icon, #jerkButton .control-icon { width: 23px; height: 23px; }
  .control-icon svg { width: 23px; height: 23px; }
  .meters { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 72px); padding: 8px 12px; }
  .toast { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 126px); }
}
@media (orientation: landscape) and (max-height: 520px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .brand { position: static; }
  h1 { display: block; font-size: 18px; }
  .top-actions { padding-left: 0; }
  .top-actions .tab, .icon-button { width: 42px; height: 40px; }
  .hud { grid-column: 1; }
  .condition-chip { top: 103px; }
  .scene-status { top: 126px; }
  .controls { width: 325px; left: auto; right: 14px; transform: none; }
  .meters { width: 250px; left: 14px; bottom: 16px; transform: none; }
  .toast { bottom: 92px; }
}
@media (prefers-reduced-motion: reduce) {
  .bite-signal, .catch-result { animation: none; }
}
@media (orientation: landscape) and (max-height: 520px) and (max-width: 620px) {
  .controls { width: calc(60% - 22px); }
  .meters { width: calc(40% - 20px); gap: 8px; padding: 8px 10px; }
}
