/* Handheld experiments are intentionally isolated from the desktop game layout. */
@media (max-width: 820px) {
  #menu.menu-screen {
    gap: 22px;
  }

  #menu .brand-block h1 {
    font-size: clamp(2.45rem, 11vw, 3.25rem);
    line-height: .94;
  }

  #menu .clubhouse-entry {
    margin-top: 14px;
  }

  #game {
    position: fixed;
    z-index: 20;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    padding-bottom: 0;
    overflow: hidden;
  }

  #game .top-bar {
    display: none;
  }

  #game .game-nav-actions {
    display: none;
  }

  #game .hole-heading {
    display: none;
  }

  #game .hud-strip .player-roster,
  #game .hud-strip .scorecard-button {
    display: none;
  }

  #game .sandbox-banner {
    display: none;
  }

  #game .disc-controls {
    display: none;
  }

  #game .inline-throw-style-selector {
    display: none;
  }

  #game .command-header h3,
  #game .character-setting-note,
  #game .throw-mechanic-tip {
    display: none;
  }

  #game [data-throw-instruction] {
    display: none !important;
  }

  #game .command-header {
    display: none;
  }

  #game .command-header .turn-dot {
    display: none;
  }

  #game .course-boundary-note,
  #game .map-key {
    display: none;
  }

  #game .throw-hole-reset,
  #game .physics-debug-button,
  #game .master-control-button,
  #game .master-mixer-button {
    display: none;
  }

  #game .handheld-hole-number.hidden {
    display: block !important;
    margin: 0 0 2px;
    color: var(--accent);
    font-size: .7rem;
    font-weight: 900;
    letter-spacing: .09em;
    line-height: 1;
    text-transform: uppercase;
  }

  #game .course-map-heading {
    position: absolute;
    z-index: 45;
    top: 0;
    right: 0;
    left: 0;
    display: flex;
    margin: 0;
    padding: calc(10px + env(safe-area-inset-top)) 14px 11px;
    align-items: center;
    color: var(--text);
    background: linear-gradient(180deg, rgba(6, 10, 6, .72), rgba(6, 10, 6, .38) 72%, transparent);
    border: 0;
    backdrop-filter: blur(3px);
    pointer-events: none;
  }

  #game .course-map-heading h3 {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.1;
    text-shadow: 0 1px 5px rgba(0, 0, 0, .85);
  }

  #game .course-map-distance {
    min-width: 0;
    justify-items: end;
    text-align: right;
  }

  #game .course-map-distance span {
    color: #edf4e8;
    font-size: .72rem;
    text-shadow: 0 1px 5px rgba(0, 0, 0, .9);
  }

  #game .course-map-distance strong {
    display: none;
  }

  #game .aim-timing {
    position: absolute;
    z-index: 3;
    top: calc(58px + env(safe-area-inset-top));
    right: 12px;
    left: 12px;
    display: block;
    pointer-events: none;
  }

  #game .aim-timing-label,
  #game .aim-track-labels {
    display: none;
  }

  #game .aim-track {
    height: 10px;
    border-width: 1px;
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, .55), 0 1px 5px rgba(0, 0, 0, .45);
  }

  #game .aim-marker {
    top: 1px;
    bottom: 1px;
    width: 4px;
    box-shadow: 0 0 4px rgba(255, 255, 255, .9);
  }

  #game .course-throw-overlay {
    position: absolute;
    z-index: 46;
    inset: 0;
    display: block;
    margin: 0;
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    pointer-events: none;
  }

  #game .course-throw-overlay .throw-pull-zone {
    position: absolute;
    inset: 0;
    width: auto;
    height: auto;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    pointer-events: none;
  }

  #game .course-throw-overlay .trajectory-rail {
    top: 50%;
    bottom: auto;
    height: clamp(160px, 32vh, 260px);
    opacity: .5;
    pointer-events: auto;
    transform: translateY(-50%);
    transition: opacity 130ms ease;
  }

  #game .course-throw-overlay .trajectory-rail.is-adjusting,
  #game .course-throw-overlay.is-adjusting-trajectory .throw-disc-pull {
    opacity: 1;
  }

  #game .course-throw-overlay .throw-pull-zone[data-throw-state="primed"] .trajectory-rail,
  #game .course-throw-overlay .throw-pull-zone[data-throw-state="angle"] .trajectory-rail,
  #game .course-throw-overlay .throw-pull-zone[data-throw-state="dragging"] .trajectory-rail,
  #game .course-throw-overlay .throw-pull-zone.is-releasing .trajectory-rail {
    opacity: 0;
    pointer-events: none;
  }

  #game .course-throw-overlay .throw-pull-zone.is-releasing .trajectory-rail {
    transition-duration: 80ms;
  }

  #game .course-throw-overlay .throw-last-distance,
  #game .course-throw-overlay .throw-strength-readout {
    top: 82px;
  }

  #game .course-throw-overlay .throw-direction-readout {
    top: 132px;
  }

  #game .course-throw-overlay .throw-strength-track {
    bottom: calc(86px + env(safe-area-inset-bottom));
  }

  /* Keep the throw target over the map without blocking camera gestures around it. */
  #game .throw-disc-pull {
    position: absolute;
    z-index: 4;
    top: calc(50% - 56px);
    left: 50%;
    opacity: .5;
    pointer-events: auto;
    transition: transform 210ms cubic-bezier(.2, .8, .25, 1), opacity 130ms ease;
  }

  #game .throw-pull-guide {
    position: absolute;
    z-index: 3;
    top: calc(50% + 62px);
    bottom: auto;
    left: 50%;
    height: clamp(90px, 18vh, 150px);
    opacity: .5;
    pointer-events: none;
    transition: opacity 130ms ease;
  }

  #game .throw-pull-zone[data-throw-state="primed"] .throw-disc-pull,
  #game .throw-pull-zone[data-throw-state="angle"] .throw-disc-pull,
  #game .throw-pull-zone[data-throw-state="dragging"] .throw-disc-pull,
  #game .throw-pull-zone[data-throw-state="primed"] .throw-pull-guide,
  #game .throw-pull-zone[data-throw-state="angle"] .throw-pull-guide,
  #game .throw-pull-zone[data-throw-state="dragging"] .throw-pull-guide {
    opacity: 1;
  }

  #game .throw-pull-zone.is-releasing .throw-disc-pull,
  #game .throw-pull-zone.is-releasing .throw-pull-guide {
    opacity: 0;
    transition-duration: 80ms;
  }

  .handheld-footer-nav.hidden {
    position: fixed;
    z-index: 80;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex !important;
    min-height: 68px;
    padding: 7px 14px calc(7px + env(safe-area-inset-bottom));
    align-items: center;
    justify-content: space-around;
    background: linear-gradient(0deg, rgba(6, 10, 6, .72), rgba(6, 10, 6, .38) 58%, rgba(6, 10, 6, 0));
    border-top: 0;
    box-shadow: 0 -8px 22px rgba(0, 0, 0, .18);
    backdrop-filter: blur(2px);
  }

  .handheld-footer-button {
    display: grid;
    flex: 1 1 0;
    min-width: 0;
    max-width: 88px;
    min-height: 52px;
    padding: 6px 12px;
    place-items: center;
    gap: 3px;
    color: var(--accent);
    background: transparent;
    border: 0;
    font-size: .72rem;
  }

  .handheld-footer-button i {
    font-size: 1.3rem;
  }

  .handheld-footer-button > span {
    display: block;
    width: 100%;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .handheld-disc-button > span {
    font-size: .62rem;
  }

  .handheld-footer-player {
    display: grid;
    flex: 1 1 0;
    min-width: 0;
    max-width: 72px;
    place-items: center;
    gap: 3px;
    color: var(--muted);
    font-size: .65rem;
    font-weight: 800;
  }

  .handheld-footer-player > span:last-child {
    width: 100%;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .handheld-footer-avatar {
    position: relative;
    display: block;
  }

  .handheld-footer-avatar .player-avatar-frame {
    width: 36px;
    height: 36px;
  }

  .handheld-footer-avatar .connection-dot {
    position: absolute;
    z-index: 2;
    bottom: -1px;
    right: -1px;
    font-size: .43rem;
    filter: drop-shadow(0 0 2px #101610);
    pointer-events: none;
  }

  .handheld-footer-avatar .connection-dot.online {
    color: #7ce66d;
  }

  .handheld-turn-dot {
    position: absolute;
    z-index: 3;
    bottom: -2px;
    left: -2px;
    width: 9px;
    height: 9px;
    background: var(--accent);
    border: 2px solid #101610;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(242, 193, 78, .8);
    animation: handheldTurnPulse 1.1s ease-in-out infinite alternate;
  }

  @keyframes handheldTurnPulse {
    from { transform: scale(.9); }
    to { transform: scale(1.15); }
  }

  .player-actions-dialog {
    width: calc(100vw - 28px);
    max-width: calc(100vw - 28px);
    max-height: calc(100vh - 28px);
    overflow-y: auto;
  }

  .handheld-settings-dialog,
  .handheld-disc-dialog {
    width: 100%;
    max-width: none;
    max-height: min(78vh, 680px);
    margin: auto 0 0;
    padding: 20px 18px calc(22px + env(safe-area-inset-bottom));
    color: var(--text);
    background: linear-gradient(160deg, #202a20, #111711 72%);
    border: 1px solid #61705d;
    border-width: 1px 0 0;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -24px 70px rgba(0, 0, 0, .65);
    overflow-x: hidden;
    overflow-y: auto;
  }

  .handheld-settings-dialog[open],
  .handheld-disc-dialog[open] {
    display: grid;
    gap: 18px;
  }

  .handheld-settings-dialog::backdrop,
  .handheld-disc-dialog::backdrop {
    background: rgba(3, 6, 3, .7);
    backdrop-filter: blur(4px);
  }

  .handheld-settings-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
  }

  .handheld-settings-head h2,
  .handheld-settings-head p {
    margin: 0;
  }

  .handheld-settings-close {
    display: grid;
    flex: 0 0 42px;
    width: 42px;
    aspect-ratio: 1;
    padding: 0;
    place-items: center;
    border-radius: 50%;
  }

  .handheld-disc-field {
    display: grid;
    min-width: 0;
    gap: 7px;
    color: var(--muted);
    font-size: .75rem;
    font-weight: 900;
    text-transform: uppercase;
  }

  .handheld-disc-categories {
    display: grid;
    gap: 9px;
  }

  .handheld-disc-category {
    padding: 9px;
    background: #111711;
    border: 1px solid #394737;
    border-radius: 10px;
  }

  .handheld-disc-category.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(242, 193, 78, .25);
  }

  .handheld-disc-category.active > span {
    color: var(--accent);
  }

  .handheld-disc-field select {
    width: 100%;
    min-width: 0;
    padding: 14px 12px;
    color: var(--text);
    text-transform: none;
  }

  .handheld-settings-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .handheld-settings-throw-style {
    grid-column: 1 / -1;
    margin: 0 0 2px;
    padding: 0 0 14px;
    border-bottom: 1px solid #455541;
  }

  .handheld-settings-action,
  .handheld-settings-actions > .audio-settings-button {
    display: flex;
    width: 100%;
    height: 58px;
    padding: 10px 14px;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    color: var(--text);
    background: linear-gradient(180deg, #253125, #171e17);
    border: 1px solid #52624e;
    border-radius: 12px;
    font-weight: 800;
  }

  .handheld-settings-action i,
  .handheld-settings-actions > .audio-settings-button i {
    display: grid;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    place-items: center;
    color: #1f1806;
    background: var(--accent);
    border-radius: 50%;
  }

  .handheld-settings-help {
    min-width: 0;
  }

  .handheld-settings-help[open] {
    grid-column: 1 / -1;
  }

  .handheld-settings-help summary {
    list-style: none;
    cursor: pointer;
  }

  .handheld-settings-help summary::-webkit-details-marker {
    display: none;
  }

  .handheld-help-content {
    margin-top: 10px;
    padding: 14px;
    color: var(--muted);
    background: #101610;
    border: 1px solid #3c493a;
    border-radius: 12px;
  }

  .handheld-help-content > :first-child {
    margin-top: 0;
  }

  .handheld-help-content .shot-choice {
    width: 100%;
    margin-top: 8px;
  }

  .handheld-throw-help-summary {
    display: grid;
    gap: 7px;
    margin-bottom: 12px;
    padding: 12px;
    color: var(--muted);
    background: rgba(36, 48, 35, .72);
    border: 1px solid #455541;
    border-radius: 10px;
  }

  .handheld-throw-help-summary strong {
    color: var(--text);
  }

  .handheld-map-help {
    margin: 14px 0;
    padding: 12px;
    background: rgba(36, 48, 35, .72);
    border: 1px solid #455541;
    border-radius: 10px;
  }

  .handheld-map-help > p:first-child {
    margin-top: 0;
  }

  .handheld-boundary-help {
    display: flex;
    align-items: center;
    gap: 7px;
  }

  .handheld-help-map-key {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    font-size: .72rem;
  }

  .handheld-help-map-key > span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
  }

  .mode-dialog {
    width: calc(100vw - 28px);
    max-width: calc(100vw - 28px);
    padding: 16px;
    overflow-x: hidden;
  }

  .mode-dialog > *,
  .mode-dialog-head > *,
  .mode-field {
    min-width: 0;
    max-width: 100%;
  }

  .mode-field select {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    text-overflow: ellipsis;
  }

  .mode-description {
    overflow-wrap: anywhere;
  }

  #game .game-grid {
    height: 100%;
    grid-template-columns: 1fr;
    grid-template-areas: "map";
  }

  #game .situation,
  #game .command-column,
  #game .command-chat-panel {
    display: none;
  }

  #game .map-panel {
    position: relative;
    width: 100vw;
    height: 100%;
    max-width: none;
    min-width: 0;
    margin-left: calc(50% - 50vw);
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #101610;
  }

  #game .course-stage {
    height: 100%;
    min-height: 100%;
    aspect-ratio: auto;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    touch-action: none;
    cursor: grab;
  }

  #game .course-stage:active {
    cursor: grabbing;
  }
}
