  #shippingGame {
    --gap: 10px;
    --cell: 72px;

    --bg: #0a0f14;
    --panel: #131b24;
    --panel-2: #18222e;
    --board: #131d27;
    --cellbg: #1f2c3a;
    --line: #26313d;
    --text: #e8eef5;
    --muted: #93a4b6;
    --accent: #f0a93b;
    --accent-ink: #22160a;
    --port: #58d3c0;
    --ok: #6ee7a8;
    --ng: #ff7a6b;
  }

  #shippingGame, #shippingGame * { box-sizing: border-box; }

  #shippingGame :focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 8px; }

  #shippingGame {
    width: min(100%, 430px);
    height: var(--shipping-frame-height);
    position: relative;
    margin-inline: auto;
    color: var(--text);
    font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", "Yu Gothic", Meiryo, sans-serif;
    --shipping-frame-height: min(650px, calc(100dvh - 20px));
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #111925 0%, #0c1319 100%);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 24px 50px -30px #000, inset 0 1px 0 #ffffff0f;
    overflow: hidden;
  }

  #shippingGame .screen { display: flex; flex-direction: column; gap: 0.55rem; padding: 0.7rem; }
  #shippingGame .screen[hidden] { display: none; }

  /* ---------- タイトル ---------- */
  #shippingGame .hero { flex: none; padding: 1.3rem 1rem 0.2rem; text-align: center; }
  #shippingGame .hero h2 { margin: 0; font-size: 1.62rem; line-height: 1.2; font-weight: 900; letter-spacing: 0.02em; }
  #shippingGame .hero h2 span { color: var(--accent); }
  #shippingGame .hero .lead { margin: 0.65rem auto 0; max-width: 21em; font-size: 0.8rem; color: var(--muted); }

  #shippingGame .demo {
    flex: none;
    margin: 0.95rem auto 0.8rem;
    display: grid;
    grid-template-columns: repeat(4, 34px);
    grid-template-rows: repeat(2, 34px);
    gap: 5px;
    padding: 0.55rem;
    border-radius: 12px;
    background: var(--board);
    border: 1px solid var(--line);
  }
  #shippingGame .demo i { border-radius: 6px; background: var(--cellbg); display: grid; place-items: center; font-style: normal; font-size: 0.8rem; font-weight: 800; }
  #shippingGame .demo i.t2 { background: #efe7db; color: #33291f; }
  #shippingGame .demo i.t8 { background: #f3b171; color: #2b1b0b; }
  #shippingGame .demo i.port { border: 2px dashed var(--port); background: #0f2724; color: var(--port); font-size: 0.55rem; letter-spacing: 0.05em; }

  #shippingGame .menu { flex: none; display: flex; flex-direction: column; gap: 0.5rem; padding: 0 1rem 1.1rem; }
  #shippingGame .menu .sub { font-size: 0.7rem; color: var(--muted); text-align: center; margin: 0.2rem 0 0; }

  #shippingGame .btn {
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    min-height: 46px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  #shippingGame .btn:hover:not(:disabled) { background: #1e2937; }
  #shippingGame .btn:disabled { opacity: 0.4; cursor: default; }
  #shippingGame .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
  #shippingGame .btn.primary:hover:not(:disabled) { background: #f6bc5c; }

  /* ---------- HUD ---------- */
  #shippingGame .hud { flex: none; display: grid; grid-template-columns: 1fr auto auto; gap: 0.45rem; align-items: stretch; }

  #shippingGame .order {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.05rem;
    padding: 0.3rem 0.6rem;
    border-radius: 11px;
    background: var(--panel);
    border: 1px solid var(--line);
  }
  #shippingGame .order .cap { font-size: 0.58rem; letter-spacing: 0.12em; color: var(--muted); font-weight: 700; }
  #shippingGame .order .val { font-size: 1.4rem; font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; }
  #shippingGame .order.now .val { color: var(--accent); }
  #shippingGame .order.mini { min-width: 62px; text-align: center; }
  #shippingGame .order.mini .val { font-size: 1.02rem; color: #c8d4e2; }

  #shippingGame .moves {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-width: 68px;
    padding: 0.3rem 0.5rem;
    border-radius: 11px;
    background: var(--panel);
    border: 1px solid var(--line);
  }
  #shippingGame .moves .cap { font-size: 0.58rem; letter-spacing: 0.1em; color: var(--muted); font-weight: 700; }
  #shippingGame .moves .val { font-size: 1.18rem; font-weight: 800; font-variant-numeric: tabular-nums; }
  #shippingGame .moves.low .val { color: var(--ng); }

  /* ---------- 盤 ---------- */
  #shippingGame .board-wrap { flex: none; position: relative; }

  #shippingGame .board {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: var(--gap);
    border-radius: 14px;
    background: var(--board);
    border: 1px solid var(--line);
    box-shadow: inset 0 1px 0 #ffffff0a;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
  }

  #shippingGame .cells {
    position: absolute;
    inset: var(--gap);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: var(--gap);
  }
  #shippingGame .cell { background: var(--cellbg); border-radius: 9px; }

  #shippingGame .port-mark {
    position: absolute;
    pointer-events: none;
    border: 2px dashed var(--port);
    border-radius: 9px;
    background: linear-gradient(180deg, #0f2724aa, #0b1c1aaa);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 3;
    transition: box-shadow 160ms ease-out, background 160ms ease-out;
  }
  #shippingGame .port-mark span {
    font-size: 0.5rem;
    letter-spacing: 0.08em;
    font-weight: 800;
    color: var(--port);
    transform: translateY(-1px);
    background: #0b141a;
    padding: 0 0.25rem;
    border-radius: 4px;
    margin-top: -0.35rem;
  }
  #shippingGame .port-mark.armed { box-shadow: 0 0 0 3px #58d3c055, 0 0 18px -2px #58d3c0aa; background: #14504acc; }
  #shippingGame .port-mark.flash { animation: shipping-portflash 340ms ease-out; }
  @keyframes shipping-portflash {
    0% { box-shadow: 0 0 0 0 #58d3c0cc; }
    100% { box-shadow: 0 0 0 22px #58d3c000; }
  }

  #shippingGame .tile {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--cell);
    height: var(--cell);
    border-radius: 9px;
    display: grid;
    place-items: center;
    font-size: calc(var(--cell) * 0.42);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    letter-spacing: -0.02em;
    z-index: 2;
    will-change: transform;
    transition: transform 118ms ease-out;
    transform: translate3d(0, 0, 0);
  }
  #shippingGame .tile.wide { font-size: calc(var(--cell) * 0.32); }
  #shippingGame .tile.at-port { box-shadow: 0 0 0 3px #58d3c0cc, 0 0 16px -2px #58d3c0; }
  #shippingGame .tile.pop { animation: shipping-pop 150ms ease-out; }
  #shippingGame .tile.spawn { animation: shipping-spawn 140ms cubic-bezier(.2, .9, .3, 1.3); }
  #shippingGame .tile.vanish { z-index: 1; }
  #shippingGame .tile.shipping {
    z-index: 6;
    transition: transform 300ms cubic-bezier(.4, 0, .85, .35), opacity 300ms ease-in 60ms;
    opacity: 0;
  }

  @keyframes shipping-pop {
    0% { scale: 1; }
    45% { scale: 1.14; }
    100% { scale: 1; }
  }
  @keyframes shipping-spawn {
    from { scale: 0.3; opacity: 0.25; }
    to { scale: 1; opacity: 1; }
  }

  #shippingGame .ship-badge {
    position: absolute;
    z-index: 7;
    pointer-events: none;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    background: var(--port);
    color: #06201d;
    font-size: 0.74rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    animation: shipping-badge 760ms ease-out forwards;
  }
  @keyframes shipping-badge {
    0% { opacity: 0; transform: translateY(6px) scale(0.9); }
    18% { opacity: 1; transform: translateY(-2px) scale(1); }
    70% { opacity: 1; transform: translateY(-14px) scale(1); }
    100% { opacity: 0; transform: translateY(-26px) scale(0.96); }
  }

  /* ---------- 十字ボタン ---------- */
  #shippingGame .dpad {
    flex: none;
    display: grid;
    grid-template-columns: repeat(3, 62px);
    grid-template-rows: repeat(2, 54px);
    gap: 0.4rem;
    justify-content: center;
    margin: 0.1rem auto 0;
  }
  #shippingGame .dpad button {
    font: inherit;
    font-size: 1.15rem;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-bottom-width: 3px;
    border-radius: 12px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  #shippingGame .dpad button:hover { background: #1e2937; }
  #shippingGame .dpad button:active { transform: translateY(1px); border-bottom-width: 2px; }
  #shippingGame .dpad .up { grid-area: 1 / 2; }
  #shippingGame .dpad .left { grid-area: 2 / 1; }
  #shippingGame .dpad .down { grid-area: 2 / 2; }
  #shippingGame .dpad .right { grid-area: 2 / 3; }

  #shippingGame .status {
    flex: none;
    margin: 0;
    text-align: center;
    font-size: 0.72rem;
    color: var(--muted);
    min-height: 1.1rem;
  }
  #shippingGame .status.warn { color: #ffc780; }

  #shippingGame .foot-row { flex: none; display: flex; justify-content: center; gap: 0.4rem; padding-bottom: 0.15rem; }
  #shippingGame .chip {
    font: inherit;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.26rem 0.85rem;
    cursor: pointer;
    touch-action: manipulation;
  }
  #shippingGame .chip:hover { color: var(--text); border-color: #3a4757; }

  /* ---------- オーバーレイ ---------- */
  #shippingGame .overlay {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 1rem;
    text-align: center;
    border-radius: 14px;
    background: #0a1117d8;
    backdrop-filter: blur(2px);
    z-index: 8;
  }
  #shippingGame .overlay.show { display: flex; animation: shipping-fade 200ms ease-out; }
  @keyframes shipping-fade { from { opacity: 0; } to { opacity: 1; } }
  #shippingGame .overlay h2 { margin: 0; font-size: 1.35rem; font-weight: 900; }
  #shippingGame .overlay.win h2 { color: var(--accent); }
  #shippingGame .overlay.lose h2 { color: var(--ng); }
  #shippingGame .overlay p { margin: 0; font-size: 0.8rem; color: var(--muted); }
  #shippingGame .overlay .big { font-size: 1rem; font-weight: 800; color: var(--text); }
  #shippingGame .overlay .acts { display: flex; flex-direction: column; gap: 0.4rem; width: min(230px, 100%); margin-top: 0.35rem; }

  #shippingGame .restart-dialog {
    width: min(360px, calc(100% - 32px));
    padding: 1rem;
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
  }
  #shippingGame .restart-dialog::backdrop { background: #0a1117d8; }
  #shippingGame .restart-dialog h2 { margin: 0; font-size: 1.1rem; }
  #shippingGame .restart-dialog p { margin: 0.55rem 0 0.85rem; color: var(--muted); font-size: 0.85rem; }
  #shippingGame .restart-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; }

  /* ---------- 遊び方 ---------- */
  #shippingGame .help { padding: 0.35rem 0.2rem 0.2rem; }
  #shippingGame .help h2 { margin: 0 0 0.55rem; font-size: 1.08rem; font-weight: 900; }
  #shippingGame .help ol, #shippingGame .help ul { margin: 0 0 0.75rem; padding-left: 1.15rem; font-size: 0.79rem; color: #c8d4e2; }
  #shippingGame .help li { margin-bottom: 0.32rem; }
  #shippingGame .help b { color: var(--accent); }
  #shippingGame .help .portword { color: var(--port); font-weight: 800; }
  #shippingGame .keys { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 0.6rem; font-size: 0.75rem; color: var(--muted); margin-bottom: 0.85rem; }
  #shippingGame kbd {
    font: inherit;
    font-size: 0.72rem;
    padding: 0.05rem 0.35rem;
    background: #1a2431;
    border: 1px solid #2f3d4d;
    border-bottom-width: 2px;
    border-radius: 5px;
    color: #d6e1ee;
    white-space: nowrap;
  }

  #shippingGame .sr-only {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }

  @media (max-width: 360px) {
    #shippingGame .dpad { grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 48px); }
    #shippingGame .hero h2 { font-size: 1.45rem; }
  }

  @media (max-height: 700px) {
    #shippingGame .hero { padding-top: 0.8rem; }
    #shippingGame .demo { margin: 0.6rem auto 0.5rem; }
  }

  @media (prefers-reduced-motion: reduce) {
    #shippingGame .tile { transition-duration: 0ms; }
    #shippingGame .tile.shipping { transition-duration: 1ms; }
    #shippingGame .tile.pop, #shippingGame .tile.spawn, #shippingGame .ship-badge, #shippingGame .port-mark.flash { animation-duration: 1ms; }
  }

/* Game-page spacing follows the other game-lab pages. */
.shipping-site { margin: 0; background: #fffefd; color: #2e3131; font-family: system-ui, -apple-system, "Segoe UI", "Yu Gothic", Meiryo, sans-serif; }
.shipping-page { box-sizing: border-box; width: min(1120px, calc(100% - 48px)); margin: 0 auto 64px; font-size: 16px; line-height: 1.8; }
.shipping-page > .breadcrumb { padding-top: 8px; color: #667572; font-size: .875rem; line-height: 20px; }
.shipping-page > .breadcrumb ol { display: flex; flex-wrap: wrap; gap: 2px 6px; margin: 0; padding: 0; list-style: none; }
.shipping-page > .breadcrumb li { display: flex; align-items: baseline; gap: 6px; }
.shipping-page > .breadcrumb a { color: #26755b; text-underline-offset: 3px; }
.shipping-page .game-intro { padding: 4px 0 32px; }
.shipping-page .game-intro h1 { margin: 0 0 16px; font-size: clamp(28px, 4vw, 42px); line-height: 1.3; }
.shipping-page .game-intro p { margin: 0; color: #6e7473; }
.shipping-page .game-shell { box-sizing: border-box; }
.shipping-key-guide { position: absolute; top: 10px; left: 0; right: 112px; min-height: 44px; display: flex; flex-wrap: wrap; align-content: center; column-gap: 8px; margin: 0; color: #6e7473; font-size: 14px; line-height: 1.45; }
.shipping-key-guide strong { color: #347a68; }
.shipping-page .game-fullscreen-open, .shipping-page .game-fullscreen-close { min-height: 44px; }
.shipping-page .is-game-fullscreen .shipping-key-guide { display: none; }
.shipping-page .description-section { padding: 64px 0 12px; }
.shipping-page .description-section h2, .shipping-page .info-section h2 { margin: 0 0 22px; font-size: 32px; line-height: 1.3; }
.shipping-page .description-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 30px; padding: 28px 30px; border: 1px solid #e4e9df; border-left: 5px solid #62ad98; border-radius: 8px; background: #fff; }
.shipping-page .description-block + .description-block { padding-left: 30px; border-left: 1px solid #e4e9df; }
.shipping-page .description-block h3 { margin: 0 0 12px; font-size: 20px; line-height: 1.4; }
.shipping-page .guide-list { display: grid; margin: 0; }
.shipping-page .guide-list > div { display: grid; grid-template-columns: 115px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid #edf0eb; }
.shipping-page .guide-list > div:last-child { border: 0; }
.shipping-page .guide-list dt { color: #347a68; font-weight: 800; }
.shipping-page .guide-list dd { margin: 0; color: #545d5b; }
.shipping-page .info-section { padding: 32px 0; }
.shipping-page .info-section p { margin: 0; }
.shipping-page .info-section a { color: #347a68; text-underline-offset: 3px; }
@media (max-width: 760px) {
  .shipping-page { width: calc(100% - 32px); }
  .shipping-page > .breadcrumb { padding-top: 4px; }
  .shipping-page .game-intro { padding: 0 0 24px; }
  .shipping-page .description-section { padding-top: 48px; }
  .shipping-page .description-section h2, .shipping-page .info-section h2 { font-size: 27px; }
  .shipping-page .description-panel { grid-template-columns: 1fr; gap: 22px; padding: 22px 20px; }
  .shipping-page .description-block + .description-block { padding: 24px 0 0; border-top: 1px solid #e4e9df; border-left: 0; }
  .shipping-page .guide-list > div { grid-template-columns: 1fr; gap: 2px; }
}

/* Keep the outer game frame the same size between the menu and play. */
.is-game-fullscreen #shippingGame { --shipping-frame-height: min(650px, calc(100dvh - 84px - env(safe-area-inset-top) - env(safe-area-inset-bottom))); }
#shippingGame .screen { height: 100%; min-height: 0; }
#shippingGame #screenTitle { justify-content: center; }
#shippingGame #screenHelp, #shippingGame #screenSettings { overflow: auto; }
#shippingGame #screenGame { gap: 6px; padding: 8px; }
#shippingGame #screenGame .board-wrap, #shippingGame #screenGame .hud {
  width: min(100%, calc(var(--shipping-frame-height) - 252px));
  margin-inline: auto;
}
#shippingGame .order { min-width: 0; }
#shippingGame .dpad {
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(2, 44px);
  gap: 5px;
  margin: 0 auto;
}
#shippingGame .status { min-height: 0; }
#shippingGame .chip { min-height: 44px; }
#shippingGame .help { margin-inline: auto; max-width: 33em; }
#shippingGame .shipping-help-save { margin: 0 0 .8rem; color: var(--muted); font-size: .75rem; }
#shippingGame .shipping-sound-row { display: flex; align-items: center; gap: 10px; min-height: 44px; }
#shippingGame .shipping-sound-row input[type="range"] { width: min(44vw, 180px); }
#shippingGame .shipping-sound-row input[type="checkbox"] { width: 22px; height: 22px; }
#shippingGame #shippingSettingsNote { min-height: 1.5em; margin: .25rem 0 .4rem; font-size: .8rem; color: var(--muted); }
#shippingGame .overlay { gap: .3rem; padding: .55rem; }
#shippingGame .overlay h2 { font-size: clamp(1rem, 4vw, 1.35rem); }
#shippingGame .overlay .acts { gap: .25rem; margin-top: 0; }
#shippingGame .overlay .acts button { min-height: 44px; padding: .3rem; }
#shippingGame .shipping-ad-status {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 12px;
  background: #101722f2;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
}
#shippingGame .shipping-ad-status[hidden] { display: none; }
@media (orientation: landscape) and (max-height: 500px) and (min-width: 554px) {
  #shippingGame {
    width: min(100%, 640px);
    --shipping-frame-height: min(350px, calc(100dvh - 20px));
  }
  .is-game-fullscreen #shippingGame { --shipping-frame-height: min(350px, calc(100dvh - 84px - env(safe-area-inset-top) - env(safe-area-inset-bottom))); }
  #shippingGame #screenTitle { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .5rem; align-content: center; }
  #shippingGame #screenTitle[hidden], #shippingGame #screenGame[hidden] { display: none; }
  #shippingGame .hero { grid-row: 1; grid-column: 1; padding: .6rem .35rem 0; }
  #shippingGame .demo { grid-row: 2; grid-column: 1; }
  #shippingGame .menu { grid-row: 1 / 3; grid-column: 2; align-self: center; padding: 0 .4rem; }
  #shippingGame #screenGame {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(185px, 38%);
    grid-template-rows: auto auto auto auto;
    align-content: center;
  }
  #shippingGame #screenGame .board-wrap {
    grid-column: 1;
    grid-row: 1 / -1;
    align-self: center;
    width: min(100%, calc(var(--shipping-frame-height) - 18px));
  }
  #shippingGame #screenGame .hud { grid-column: 2; width: 100%; }
  #shippingGame .dpad, #shippingGame .status, #shippingGame .foot-row { grid-column: 2; }
}

