.frog-page {
  --ferry-paper: #faf9f4;
  --ferry-card: #fffdfa;
  --ferry-ink: #28213c;
  --ferry-muted: #6d6579;
  --ferry-line: #e4e1da;
  --ferry-accent: #6b4bc0;
  --ferry-selected: #eee7f9;
  --ferry-primary: #6b4bc0;
  --ferry-primary-ink: #fff;
  --ferry-primary-shadow: #4c328f;
  margin: 0;
  background: var(--ferry-paper);
  color: var(--ferry-ink);
  font: 1rem/1.4 'Trebuchet MS', system-ui, sans-serif;
}

.frog-page[data-lv-play] { background: var(--lv-play-surface); }
html[data-theme="dark"] .frog-page {
  --ferry-paper: #191622;
  --ferry-card: #252030;
  --ferry-ink: #f0eaf8;
  --ferry-muted: #b8acc6;
  --ferry-line: #3c334b;
  --ferry-accent: #c4a7fa;
  --ferry-selected: #37294c;
  --ferry-primary: #bea0f0;
  --ferry-primary-ink: #241733;
  --ferry-primary-shadow: #714fa6;
}

.ferry, .ferry *, .ferry *::before, .ferry *::after { box-sizing: border-box; }
.ferry {
  width: min(100%, 1220px);
  margin-inline: auto;
  padding: clamp(16px, 3vh, 38px) clamp(14px, 4vw, 56px) 20px;
}
.ferry [hidden] { display: none !important; }
.ferry button { color: inherit; font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ferry button:disabled { cursor: default; }
.ferry :focus-visible { outline: 3px solid #9071d6; outline-offset: 3px; }
.ferry-header, .ferry-actions, .ferry-tool { display: flex; align-items: center; }
.ferry-header { justify-content: space-between; gap: 10px; margin-block-end: clamp(14px, 2.6vh, 26px); }
.ferry-masthead { min-width: 0; }
.ferry-genre {
  color: var(--ferry-accent);
  font-size: .875rem;
  font-weight: 800;
  letter-spacing: .15em;
  text-transform: uppercase;
}
.ferry h1, .ferry-panel h2 {
  font-family: 'Arial Rounded MT Bold', 'Trebuchet MS', Arial, sans-serif;
  font-weight: 900;
  line-height: 1.04;
  letter-spacing: -.055em;
}
.ferry h1 { margin: .1em 0 0; font-size: clamp(2.35rem, 6vw, 5rem); }
.ferry h1 span { color: var(--ferry-accent); }
.ferry-actions { gap: 8px; flex-shrink: 0; }
.ferry-tool {
  gap: 8px;
  justify-content: center;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--ferry-line);
  border-radius: 12px;
  background: var(--ferry-card);
}
.ferry-tool:hover:not(:disabled), .ferry-tool[aria-pressed="true"] { background: var(--ferry-selected); }
.ferry-tool:disabled { color: var(--ferry-muted); opacity: .65; }
.ferry-tool-icon { position: relative; display: inline-grid; width: 18px; height: 18px; place-items: center; }
.sound-icon { font: bold 20px/1 Georgia, serif; }
#ferry-sound[aria-pressed="false"] .sound-icon::after {
  position: absolute;
  width: 20px;
  height: 1.5px;
  border-radius: 1px;
  background: currentColor;
  content: "";
  transform: rotate(-43deg);
}
.pause-icon::before { width: 10px; height: 12px; border-inline: 3px solid; content: ""; }
.pause-icon.is-paused::before {
  width: 0;
  height: 0;
  border: 7px solid transparent;
  border-right: 0;
  border-left: 10px solid currentColor;
}

.ferry-layout { display: grid; grid-template-columns: minmax(220px, 270px) minmax(0, 1fr); gap: clamp(14px, 2.4vw, 28px); }
.ferry-sidebar { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ferry-home { align-self: flex-start; margin: 4px 0 0 6px; }
.ferry-card { padding: 17px; border: 1px solid var(--ferry-line); border-radius: 16px; background: var(--ferry-card); }
.ferry-card h2 { margin: 0 0 12px; font-size: 1rem; }
.ferry-card p { color: var(--ferry-muted); font-size: .875rem; line-height: 1.4; }
.ferry-route p { margin: 11px 0 0; min-height: 2.8em; }
.ferry-modes { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--ferry-line); border-radius: 10px; }
.ferry-modes button { flex: 1; min-width: 0; min-height: 40px; padding: 5px 3px; border: 0; border-radius: 7px; background: transparent; font-size: .875rem; font-weight: 700; }
.ferry-modes button[aria-pressed="true"], .ferry-modes button:hover:not(:disabled) { background: var(--ferry-selected); }
.ferry-rule { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 11px; align-items: start; padding-block: 10px; }
.ferry-rule + .ferry-rule { border-top: 1px solid var(--ferry-line); }
.ferry-rule:last-child { padding-bottom: 0; }
.ferry-rule strong { font-size: .875rem; }
.ferry-rule p { margin: 2px 0 0; }
.rule-icon { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 9px; background: #e7efd9; color: #277552; }
.rule-leaf::before { width: 17px; height: 13px; border-radius: 50%; background: currentColor; clip-path: polygon(0 0, 100% 0, 100% 35%, 57% 55%, 100% 71%, 100% 100%, 0 100%); content: ""; transform: rotate(-24deg); }
.rule-firefly { background: #f7edc8; color: #795506; font-size: 1.22em; }
.rule-drop { background: #e2f2ee; color: #287b77; }
.rule-drop::before { width: 13px; height: 13px; border-radius: 2px 10px 10px 10px; background: currentColor; content: ""; transform: translateY(1px) rotate(45deg); }

.ferry-game { min-width: 0; }
.ferry-hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(64px, .8fr);
  align-items: center;
  padding: 10px clamp(10px, 2vw, 20px);
  border: 1px solid var(--ferry-line);
  border-radius: 15px 15px 0 0;
  background: var(--ferry-card);
  font-variant-numeric: tabular-nums;
}
.ferry-stat { display: grid; gap: 1px; min-width: 0; padding-inline: clamp(4px, 1.45vw, 14px); }
.ferry-stat + .ferry-stat { border-inline-start: 1px solid var(--ferry-line); }
.ferry-stat > span:first-child { color: var(--ferry-muted); font-size: .875rem; font-weight: 700; }
.ferry-stat strong { overflow-wrap: anywhere; font-size: clamp(1.05rem, 3.5vw, 1.65rem); line-height: 1.12; }
.ferry-stat strong, .ferry-panel-kicker { font-family: ui-monospace, 'Courier New', monospace; }
.ferry-life-icons { display: flex; align-items: center; gap: clamp(6px, 1.1vw, 11px); min-height: 1.15em; padding-inline: 2px; }
.ferry-life-icons i { width: clamp(8px, 1.5vw, 12px); aspect-ratio: 1; border: 1px solid #2a8059; border-radius: 2px 8px 8px 8px; background: #489b71; transform: rotate(45deg); }
.ferry-life-icons i.is-lost { border-color: var(--ferry-muted); background: transparent; opacity: .55; }

.ferry-board {
  position: relative;
  height: clamp(350px, 58svh, 651px);
  overflow: hidden;
  isolation: isolate;
  background: #0c3937;
  color: #fbffec;
  touch-action: manipulation;
  user-select: none;
}
.ferry-board[data-state="playing"] { cursor: pointer; touch-action: none; }
.ferry-board canvas, .ferry-cover, .ferry-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.ferry-board canvas { display: block; image-rendering: pixelated; }
.ferry-cover {
  background: linear-gradient(90deg, #0a2c3ce6 2%, #0a2c3ca6 30%, #0a2c3c33 58%, transparent 75%);
}
.ferry-board:not([data-state="ready"]) .ferry-cover { display: none; }
.ferry-overlay { display: flex; align-items: center; padding: clamp(18px, 4.5vw, 60px); }
.ferry-board:not([data-state="ready"]) .ferry-overlay { justify-content: center; background: #1c142bc9; text-align: center; }
.ferry-panel { width: min(100%, 340px); }
.ferry-panel :is(h2, p) { overflow-wrap: anywhere; }
.ferry-board:not([data-state="ready"]) .ferry-panel { padding: clamp(18px, 4vw, 32px); border: 1px solid #a992ca66; border-radius: 19px; background: #35284f; }
.ferry-panel-kicker { margin: 0 0 10px; color: #d9ee9b; font-size: .875rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.ferry-panel h2 { margin: 0 0 14px; font-size: clamp(2.5rem, 5.7vw, 4.55rem); }
.ferry-board:not([data-state="ready"]) .ferry-panel h2 { font-size: clamp(2rem, 4.7vw, 3.35rem); }
#ferry-panel-copy { margin: 0 0 20px; color: #f0f6df; font-size: clamp(.95rem, 1.8vw, 1.1rem); line-height: 1.45; }
#ferry-panel-copy:empty { display: none; }
.ferry button.ferry-primary { min-height: 48px; max-width: 100%; padding: 9px 23px; border: 0; border-radius: 10px; background: var(--ferry-primary); color: var(--ferry-primary-ink); font-weight: 800; box-shadow: 0 4px 0 var(--ferry-primary-shadow); }
.ferry-primary:hover { filter: brightness(1.08); }
.ferry button.ferry-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--ferry-primary-shadow); }
.ferry button.ferry-restart { display: block; min-height: 44px; margin: 8px auto -8px; padding: 0 8px; border: 0; background: transparent; color: #ecf3dd; text-decoration: underline; text-underline-offset: 4px; }
.ferry-toast { position: absolute; z-index: 1; top: 7%; left: 50%; width: max-content; max-width: 92%; margin: 0; padding: 7px 13px; border: 1px solid #c4a7fa7d; border-radius: 999px; background: #2c2142f0; color: #eff9b9; font-weight: 700; text-align: center; transform: translateX(-50%); pointer-events: none; }
.ferry-toast.is-hit { border-color: #f3cca0; color: #ffe0b7; }
.ferry-no-script { position: absolute; inset: auto 12px 12px; margin: 0; padding: 7px; border-radius: 7px; background: #10312b; text-align: center; }

.ferry-inputs { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--ferry-line); border-top: 0; border-radius: 0 0 15px 15px; background: var(--ferry-card); }
.ferry-inputs button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 49px;
  padding: 6px;
  border: 0;
  background: transparent;
  font-weight: 700;
  touch-action: manipulation;
}
.ferry-inputs button:first-child { border-inline-end: 1px solid var(--ferry-line); border-end-start-radius: 14px; }
.ferry-inputs button:last-child { border-end-end-radius: 14px; }
.ferry-inputs button:disabled { color: var(--ferry-muted); }
.ferry-inputs button[data-hit="true"], .ferry-inputs button:active:not(:disabled) { background: var(--ferry-selected); box-shadow: inset 0 -3px 0 var(--ferry-accent); }
@media (hover: hover) { .ferry-inputs button:hover:not(:disabled) { background: var(--ferry-selected); } }
.ferry-chevron { width: 9px; height: 9px; border: solid var(--ferry-accent); border-width: 2px 2px 0 0; }
.ferry-chevron.left { transform: rotate(-135deg); }
.ferry-chevron.right { transform: rotate(45deg); }
.ferry-inputs kbd { min-width: 21px; padding: 0 4px; border: 1px solid var(--ferry-line); border-radius: 4px; font: .875rem/1.35 ui-monospace, monospace; text-align: center; }
.ferry-controls { margin: 11px 0 0; color: var(--ferry-muted); font-size: .875rem; text-align: center; }
.ferry-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 740px), (max-height: 500px) and (pointer: coarse) {
  .frog-page {
    --ferry-mobile-inline: max(12px, env(safe-area-inset-left), env(safe-area-inset-right));
    --ferry-mobile-playbar: calc(var(--lv-playbar-height) + env(safe-area-inset-top));
  }
  .frog-page #lv-game-tools {
    height: var(--ferry-mobile-playbar);
    padding-block-start: env(safe-area-inset-top);
    padding-inline: var(--ferry-mobile-inline);
  }
  .ferry { width: 100%; padding: 0; }
  .frog-page[data-lv-play] .ferry {
    display: flex;
    flex-direction: column;
    height: calc(100svh - var(--ferry-mobile-playbar));
    height: calc(100dvh - var(--ferry-mobile-playbar));
  }
  .ferry-header {
    gap: 8px;
    margin: 0;
    padding: 3px var(--ferry-mobile-inline);
    border-bottom: 1px solid var(--ferry-line);
  }
  .ferry h1 { margin: 0; font-size: clamp(1.5rem, 6.8vw, 2.15rem); }
  .ferry-genre { display: none; }
  .ferry-actions { gap: 4px; }
  .ferry-tool { width: 44px; padding: 0; border: 0; background: transparent; }
  .ferry-tool > span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .ferry-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .frog-page[data-lv-play] .ferry-layout {
    flex: 1;
    min-height: 0;
    grid-template-rows: auto auto minmax(150px, 1fr) auto;
  }
  .ferry-sidebar, .ferry-game { display: contents; }
  .ferry-route {
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px var(--ferry-mobile-inline);
    border-width: 0 0 1px;
    border-radius: 0;
  }
  .ferry-layout:has(.ferry-board:is([data-state="playing"], [data-state="paused"])) .ferry-route { display: none; }
  .ferry-route h2 { margin: 0; }
  .ferry-route .ferry-modes { width: min(63%, 280px); }
  .ferry-route p { display: none; }
  .ferry-hud { grid-row: 2; padding: 7px var(--ferry-mobile-inline); border: 0; border-radius: 0; }
  .ferry-stat { overflow-wrap: anywhere; }
  .ferry-board { grid-row: 3; }
  .frog-page[data-lv-play] .ferry-board { height: auto; min-height: 0; }
  .ferry-inputs {
    grid-row: 4;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    border-width: 1px 0 0;
    border-radius: 0;
  }
  .ferry-inputs button { min-height: 54px; }
  .ferry-inputs button:is(:first-child, :last-child) { border-radius: 0; }
  .ferry-inputs button:focus-visible { outline-offset: -3px; }
  .ferry-controls { grid-row: 5; margin: 8px var(--ferry-mobile-inline); }
  .ferry-rules { grid-row: 6; margin: 0 var(--ferry-mobile-inline); }
  .ferry-home { grid-row: 7; margin: 14px var(--ferry-mobile-inline); }
  .frog-page[data-lv-play] :is(.ferry-controls, .ferry-rules) { display: none; }
  /* Shared logo styles force the brand link to render outside this layout. */
  .frog-page[data-lv-play] .ferry-home { display: none !important; }
  .ferry-overlay { padding-inline: max(18px, var(--ferry-mobile-inline)); }
}

@media (max-width: 740px) and (orientation: portrait) {
  .ferry-cover { background: linear-gradient(0deg, #0a2c3c 0%, #0a2c3ceb 17%, #0a2c3c33 50%, transparent 66%); }
  .ferry-board[data-state="ready"] .ferry-overlay { align-items: flex-end; }
  .ferry-board[data-state="ready"] .ferry-panel h2 { margin-bottom: 8px; }
  .ferry-panel h2 { font-size: clamp(1.8rem, 8vw, 2.5rem); }
  #ferry-panel-copy { margin-bottom: 13px; }
}

@media (max-width: 495px) and (max-height: 660px), (max-height: 500px) and (pointer: coarse) {
  .ferry-panel h2, .ferry-board:not([data-state="ready"]) .ferry-panel h2 { font-size: clamp(1.55rem, 6vw, 2.05rem); }
  .ferry-panel-kicker { margin-bottom: 7px; }
}

@media (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
  .frog-page[data-lv-play] .ferry-layout { grid-template-rows: auto auto minmax(110px, 1fr) auto; }
  .ferry-route { padding-block: 0; }
  .ferry-route .ferry-modes { padding-block: 1px; border: 0; }
  .ferry-hud { padding-block: 3px; }
  .ferry-stat strong { font-size: 1.125rem; }
  .ferry-overlay { align-items: safe center; padding-block: 8px; overflow: auto; }
  .ferry-panel h2 { margin-block-end: 4px; }
  #ferry-panel-copy { margin-block-end: 8px; }
  .ferry-inputs button { min-height: 48px; }
}

@media (pointer: coarse) { .ferry-inputs kbd { display: none; } }
