:root {
  /* Disable double-tap zoom while retaining scrolling and pinch accessibility. */
  touch-action: manipulation;
  --app-height: 100dvh;
  --app-safe-top: env(safe-area-inset-top, 0px);
  --app-safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-safe-left: env(safe-area-inset-left, 0px);
  --app-safe-right: env(safe-area-inset-right, 0px);
}
[hidden] {
  display: none !important;
}
.sheet-close-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
#companion-sheet .companion-column {
  display: flex;
}
#companion-sheet .companion-card {
  box-shadow: none;
}
#companion-sheet {
  padding: 16px;
  width: 430px;
}
.connection-panel {
  position: fixed;
  z-index: 31;
  top: calc(var(--app-safe-top) + 60px);
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, calc(100% - 28px));
  padding: 12px 16px;
  border: 1px solid #d9d1bb;
  border-radius: 14px;
  background: #fff9e8;
  box-shadow: 0 6px 22px #16394922;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}
.connection-panel button {
  display: block;
  margin: 8px auto 0;
  border: 0;
  border-radius: 10px;
  min-height: 44px;
  padding: 0 18px;
  background: #245567;
  color: #fff;
}
#art-retry {
  position: fixed;
  z-index: 32;
  top: calc(var(--app-safe-top) + 54px);
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  min-height: 44px;
  background: #fff4d7;
  color: #664e25;
  border: 1px solid #dfc595;
  border-radius: 12px;
  font-size: 13px;
}
.profile {
  border: 0;
  background: transparent;
  box-shadow: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--ink);
}
.profile i {
  width: 22px;
  height: 22px;
}
.penguin-art[data-art-state='waiting'],
.penguin-art[data-art-state='loading'] {
  background: radial-gradient(ellipse, #d9e5e188, transparent 65%);
  border-radius: 40%;
}
.penguin-art[data-art-state='error'] {
  background: radial-gradient(ellipse, #e3cdb777, transparent 65%);
}
.task-count:empty {
  display: none;
}
.collection-item small {
  font-size: 12px;
}
.detail-note,
.detail-stats {
  font-size: 13px;
}
.modal-copy {
  font-size: 14px;
  line-height: 1.8;
}
.form-input {
  font-size: 16px;
}
.saved {
  min-height: 44px;
  font-size: 12px;
}
.saved.is-error {
  color: #b04d35;
}
.saved.is-error > span:first-child {
  background: #b04d35;
}
.board {
  touch-action: none;
}
.board.is-dragging .tile {
  transform: none;
  transition: none;
}
.board.is-dragging .tile.selected,
.board.is-dragging .tile.valid-target {
  outline: none;
}
.tile.drag-source > .penguin-art {
  opacity: 0.2;
}
.board.is-dragging .tile.drop-allowed {
  outline: 2px dashed #268c8c;
  outline-offset: -2px;
}
.board.is-dragging .tile.drop-hover {
  outline: 3px solid #16856c;
  outline-offset: 0;
  background: #d6f5cfba;
}
.board.is-dragging .tile.drop-swap {
  outline-color: #bc8435;
  background: #ffdf9fba;
}
.board.is-dragging .tile.drop-invalid {
  outline: 3px solid #c15f49;
  background: #ffd9cb99;
}
.drag-ghost {
  z-index: 100;
  pointer-events: none;
  opacity: 1;
}
dialog .toast {
  display: none;
  position: sticky;
  bottom: 0;
  left: auto;
  transform: none;
  min-width: 0;
  max-width: 100%;
  margin-top: 12px;
}
dialog .toast.show {
  display: block;
  transform: none;
}
@media (max-width: 760px) {
  html {
    height: 100%;
    overflow: hidden;
  }
  body {
    height: var(--app-height);
    overflow: hidden;
    padding: var(--app-safe-top) var(--app-safe-right) var(--app-safe-bottom) var(--app-safe-left);
  }
  .workspace {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  .topbar {
    flex: 0 0 44px;
    height: 44px;
    margin: 0 12px;
    border: 0;
  }
  .topbar .page-name {
    font-size: 16px;
  }
  .topbar-right {
    gap: 4px;
  }
  .saved {
    font-size: 11px;
  }
  main {
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow: auto;
    overscroll-behavior-y: contain;
    padding: 4px 10px 80px;
  }
  main.island-mode {
    overflow: hidden;
  }
  #island-page {
    height: 100%;
  }
  .game-layout {
    height: 100%;
    gap: 8px;
    min-height: 0;
  }
  .island-card {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    border-radius: 22px;
  }
  .island-card-top {
    height: 56px;
    flex: 0 0 56px;
    padding: 0 12px;
    gap: 8px;
  }
  .tiny-island {
    display: none;
  }
  .island-name {
    font-size: 13px;
  }
  .island-name small {
    font-size: 11px;
    margin-top: 3px;
  }
  .resources {
    gap: 12px;
  }
  .resource {
    gap: 5px;
  }
  .resource strong {
    font-size: 16px;
  }
  .resource small {
    display: none;
  }
  .resource .coin-icon,
  .fish i {
    width: 24px;
    height: 24px;
  }
  .seascape {
    height: auto;
    flex: 1;
    min-height: 0;
  }
  .island-status {
    top: 6px;
    right: 8px;
    font-size: 11px;
    padding: 5px 8px;
    border-width: 1px;
  }
  .board {
    gap: 9px 12px;
  }
  .tile {
    border-radius: 42%;
    touch-action: none;
  }
  .tile > .penguin-art {
    height: calc(100% - 20px);
    width: calc(100% - 6px);
    bottom: 18px;
  }
  .tile .level {
    font-size: 11px;
    line-height: 16px;
    padding: 1px 7px;
  }
  .tile.empty:after {
    font-size: 24px;
    color: #3d7b8b;
    opacity: 1;
  }
  .sea-caption {
    bottom: 5px;
    left: 4%;
    right: 4%;
    font-size: 11px;
    padding: 4px 7px;
    line-height: 1.45;
    min-height: 25px;
  }
  .sea-caption i {
    display: none;
  }
  .adoption-bar {
    height: 64px;
    min-height: 64px;
    flex: 0 0 64px;
    padding: 8px 12px;
  }
  .adoption-info strong {
    font-size: 13px;
  }
  .adopt-avatar {
    display: block;
    width: 32px;
    height: 38px;
  }
  .adoption-info {
    gap: 4px;
  }
  .primary-button {
    min-height: 44px;
    font-size: 14px;
    padding: 0 15px;
  }
  #adopt {
    flex: 1;
    max-width: 220px;
    margin-left: 10px;
  }
  .sidebar {
    inset: auto calc(8px + var(--app-safe-right)) calc(6px + var(--app-safe-bottom))
      calc(8px + var(--app-safe-left));
    width: auto;
    height: 64px;
    padding: 3px 8px;
    border-radius: 20px;
  }
  .navigation {
    gap: 4px;
    height: 100%;
  }
  .nav-item {
    position: relative;
    flex: 1;
    min-width: 0;
    width: auto;
    min-height: 54px;
    padding: 5px 8px;
    font-size: 12px;
    gap: 3px;
  }
  .nav-item i {
    width: 21px;
    height: 21px;
  }
  .nav-item > .task-count {
    display: block;
    position: absolute;
    top: 2px;
    right: calc(50% - 29px);
    margin: 0;
    min-width: 18px;
    line-height: 18px;
    padding: 0 4px;
    border-radius: 10px;
    background: #d55f42;
    color: #fff;
    font-size: 11px;
    text-align: center;
  }
  #companion-sheet {
    position: fixed;
    inset: auto 0 0;
    margin: 0;
    width: 100%;
    max-width: none;
    max-height: calc(var(--app-height) - var(--app-safe-top) - 16px);
    padding: 14px max(14px, var(--app-safe-right)) calc(18px + var(--app-safe-bottom))
      max(14px, var(--app-safe-left));
    border-radius: 25px 25px 0 0;
    overscroll-behavior: contain;
  }
  #companion-sheet .companion-card {
    padding: 14px;
    gap: 12px;
    grid-template-columns: 112px minmax(0, 1fr);
  }
  #companion-sheet .pet-stage {
    width: 112px;
  }
  #companion-sheet .pet-name h2 {
    font-size: 18px;
  }
  #companion-sheet .pet-actions button {
    font-size: 13px;
    min-height: 44px;
  }
  #companion-sheet .affection > div:first-child {
    font-size: 12px;
  }
  #companion-sheet .affection small {
    font-size: 12px;
  }
  #companion-sheet .pet-name > span {
    font-size: 11px;
  }
  #companion-sheet .card-label {
    font-size: 13px;
  }
  .daily-card h3 {
    font-size: 14px;
  }
  .daily-card p {
    font-size: 12px;
  }
  .round-button {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }
  dialog {
    max-height: calc(var(--app-height) - var(--app-safe-top) - var(--app-safe-bottom) - 28px);
    padding: 20px;
    overscroll-behavior: contain;
  }
  .page-summary {
    font-size: 12px;
    gap: 8px;
    margin: 10px 2px 14px;
    flex-wrap: wrap;
  }
  .soft-badge {
    font-size: 12px;
    padding: 6px 10px;
  }
  .collection-filters {
    position: sticky;
    top: -4px;
    z-index: 4;
    background: #f6f3ebed;
    backdrop-filter: blur(8px);
    padding: 7px 0;
    scrollbar-width: thin;
  }
  .filter-chip {
    font-size: 12px;
    min-height: 44px;
    padding: 0 13px;
  }
  .collection-item .level-badge {
    font-size: 12px;
  }
  .collection-item h3 {
    font-size: 15px;
  }
  .collection-item small {
    font-size: 12px;
    margin-top: 6px;
  }
  .ultimate-card .collection-art {
    height: 190px;
  }
  .task-copy p,
  .reward-pill {
    font-size: 12px;
  }
  .toast {
    bottom: calc(82px + var(--app-safe-bottom));
    font-size: 13px;
    max-width: calc(100% - 28px);
    padding: 12px 16px;
  }
}
@media (max-width: 760px) and (max-height: 600px) {
  .topbar {
    flex-basis: 40px;
    height: 40px;
  }
  .island-card-top {
    height: 48px;
    flex-basis: 48px;
  }
  .adoption-bar {
    height: 56px;
    min-height: 56px;
    flex-basis: 56px;
    padding: 5px 10px;
  }
  .board {
    gap: 5px 12px;
  }
}
