* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  font-family: monospace;
  background: white;
}

button {
  border: 1px solid black;
  background: white;
  padding: 8px 14px;
  margin: 0;
  cursor: pointer;
  font: inherit;
}

button:hover {
  background: black;
  color: white;
}

.sea-scene {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.sea-bg {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image: url("assets/sea/bg.png");
  background-repeat: no-repeat;
  background-position: center top;
  background-size: cover;
  animation: seaFloat 6s ease-in-out infinite;
}

@keyframes seaFloat {
  0% {
    transform: translateY(16vh);
  }

  50% {
    transform: translateY(18vh);
  }

  100% {
    transform: translateY(16vh);
  }
}

#fishLayer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.hook {
  position: absolute;
  left: 50%;
  top: -820px;
  z-index: 0;
  width: 300px;
  transform: translateX(-50%);
  transition: top 1.2s ease;
  pointer-events: none;
}

.fishing .hook {
  top: -120px;
}

.fish {
  position: absolute;
  z-index: 2;
  width: 120px;
  transition: transform 0.6s ease, opacity 0.6s ease;
}

.fish.caught {
  opacity: 0.9;
}

#fishBtn {
  position: fixed;
  top: 16px;
  right: 136px;
  z-index: 10;
}

.lang-toggle {
  position: fixed;
  top: 16px;
  right: 60px;
  z-index: 10;
  display: flex;
}

.lang-toggle button {
  width: 38px;
  padding: 8px 0;
}

.lang-toggle button + button {
  border-left: 0;
}

.lang-toggle button.active {
  background: black;
  color: white;
}

.invest-panel {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 10;
}

.invest-form {
  display: none;
  width: 180px;
  margin-top: 8px;
}

.invest-panel.open .invest-form {
  display: block;
}

.invest-form input {
  width: 100%;
  border: 1px solid black;
  background: white;
  padding: 8px;
  font: inherit;
}

.invest-form button {
  width: 100%;
  margin-top: 6px;
}

.invest-package {
  position: fixed;
  z-index: 0;
  width: 120px;
  pointer-events: none;
}

.scene-arrow {
  position: fixed;
  z-index: 20;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.scene-arrow-next {
  top: 16px;
  right: 16px;
}

.scene-arrow-back {
  top: 16px;
  left: 16px;
}

.home-scene {
  display: none;
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: white;
}

body.home-mode .sea-scene,
body.home-mode .inventory-panel {
  display: none;
}

body.home-mode .home-scene {
  display: block;
}

.home-table {
  position: absolute;
  left: 50%;
  bottom: -25vh;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  transform: translateX(-50%);
  pointer-events: none;
}

.package-wrap {
  position: absolute;
  left: 50%;
  top: 66%;
  width: min(360px, 48vw);
  transform: translate(-170vw, -50%);
  transition: transform 1s ease;
}

.package-wrap.in {
  transform: translate(-50%, -50%);
}

.package-img {
  display: block;
  width: 100%;
  pointer-events: none;
}

.package-words {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 62%;
  transform: translate(-50%, -50%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, max-content));
  justify-content: center;
  justify-items: center;
  gap: 6px;
  opacity: 0;
}

.package-wrap.open .package-words {
  opacity: 1;
}

.package-token {
  border: 1px solid black;
  background: white;
  padding: 5px 8px;
  font-size: clamp(12px, 1.6vw, 18px);
  cursor: grab;
  user-select: none;
}

.package-token:active {
  cursor: grabbing;
}

.word-workbench {
  display: none;
  position: absolute;
  left: 50%;
  top: 84%;
  z-index: 5;
  width: min(520px, calc(100vw - 32px));
  transform: translateX(-50%);
}

.home-scene.package-open .word-workbench {
  display: block;
}

.word-drop-zone {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 42px;
  padding: 8px;
  border: 1px dashed black;
  background: rgba(255, 255, 255, 0.72);
}

.word-drop-zone.drag-over {
  background: white;
}

.package-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.inventory-panel {
  position: fixed;
  left: 0;
  top: 50%;
  z-index: 10;
  width: min(340px, calc(100vw - 56px));
  padding: 12px;
  border: 1px solid black;
  border-left: 0;
  background: rgba(255, 255, 255, 0.86);
  transform: translate(-100%, -50%);
  transition: transform 0.35s ease;
}

.inventory-panel.open {
  transform: translate(0, -50%);
}

.inventory-handle {
  position: absolute;
  left: 100%;
  top: 50%;
  width: 36px;
  height: 86px;
  padding: 8px 6px;
  border-left: 0;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.inventory-panel h1 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: normal;
}

.collection {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 34px;
}

.word-chip {
  border: 1px solid black;
  background: white;
  padding: 5px 8px;
}

.word-chip.selected {
  background: black;
  color: white;
}

.inventory-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.combined-word {
  min-height: 20px;
  margin-top: 10px;
  word-break: break-word;
}
