/* Nemo's Ocean — phones.
   Everything in this file applies to phones (up to 700 px wide) or to touch screens only: the computer layout
   is untouched. Rules start with :root so they win over the sheets a page loads later (games.css, aquarium.css).
   Sizes: nothing tappable under 44 px, no text under 12 px, inputs at 16 px (iPhones zoom into smaller ones). */

:root{--safe-t:env(safe-area-inset-top,0px);--safe-b:env(safe-area-inset-bottom,0px);--chrome-b:var(--safe-b)}

@media (max-width:700px){
  /* the page fits the screen the browser really shows (its toolbars come and go) */
  body{min-height:100vh;min-height:100svh}
  main{min-height:calc(100svh - 120px)}

  /* the little message pill: clear of the home bar (and of the tab bar, see nav.css) */
  :root #toast{bottom:calc(16px + var(--chrome-b));max-width:calc(100% - 32px)}

  /* typing never zooms the page */
  :root input:not([type=checkbox]):not([type=radio]),:root textarea,:root select{font-size:16px}

  /* things to tap: at least 44 px */
  :root .btn.small{min-height:44px;font-size:13px;padding:10px 16px}
  :root .linkish,:root .foot-report{padding:12px 4px;margin:-12px -4px}
  :root .modal-close{width:44px;height:44px}
  :root .sound-btn{width:44px;height:44px}
  :root .gb-tabs button{min-height:40px;padding:9px 16px;font-size:13px}
  :root .focus-x{width:44px;height:44px;top:max(10px,var(--safe-t));right:max(10px,env(safe-area-inset-right,0px))}
  :root .game-top .howto-btn{width:44px;height:44px}

  /* small print: 12 px at the least */
  :root .eyebrow{font-size:12px;letter-spacing:.14em}
  :root .depth-label,:root .depth-scale,:root .rv-tag,:root .ticket-head,:root .tour-count,
  :root .art-label,:root .art-badge span,:root .legend li span small,:root .gb-name em,:root .gb-score small,
  :root .gc-genre,:root .gc-new,:root .arc-badge,:root .arc-wait span,:root .riddle-hint b,
  :root .uh-stat span,:root .wm-hud span,:root .dive-zone,:root .dive-mark,:root .ld-route,:root .sd2-from{font-size:12px}
  :root .rv-tag{letter-spacing:.1em}
  :root .uh-name{font-size:clamp(11px,2.9vw,12px)}
  :root .credit{opacity:1;color:#86a6ae;font-size:12px}

  /* the porthole badges are words, not specks */
  :root .port-badge{font:800 12px/1.2 var(--sans);letter-spacing:.02em;text-transform:none;padding:3px 9px;bottom:-10%}
  /* a missed porthole: a lit dot (the line under the portholes says what it means) */
  :root .port-badge.soft{width:14px;height:14px;top:4%;right:4%;bottom:auto;padding:0;font-size:0}

  /* the long greeting under the logo: never cut, never covered */
  :root .cal-chips .cal-tz span,:root .cal-chips .cal-aq span{overflow:visible;text-overflow:clip;white-space:normal}
}

/* ---- touch screens: no hover lifts left stuck after a tap, a short press instead */
@media (hover:none){
  *{-webkit-tap-highlight-color:transparent}
  :root .btn:hover{transform:none;box-shadow:none}
  :root .gc:hover{transform:none;box-shadow:0 18px 44px #0005;border-color:#ffffff1f}
  :root .gc:hover .gc-art svg,:root .gc:hover .gc-play{transform:none}
  :root .arc-hero:hover{transform:none;box-shadow:0 30px 80px #0007}
  :root .cal-help:hover{transform:none;background:#0b364a99}
  :root .tv-a:hover:not(:disabled){transform:none;background:#ffffff14}
  :root .howto-btn:hover{transform:none;background:#87e8d71f}
  :root .btn:active,:root .gc:active,:root .arc-hero:active,:root .tv-a:active:not(:disabled),:root .howto-btn:active,:root .cal-help:active{transform:scale(.97);transition-duration:.08s}

  /* blurring what lies behind is redrawn every frame over a 3D scene: plain surfaces instead */
  :root .aq-top .btn,:root .aq-title,:root .aq-rail,:root .aq-depth,:root .dive-card,:root .gc-genre,:root .focus-x{-webkit-backdrop-filter:none;backdrop-filter:none}
  :root .aq-top .btn,:root .aq-title,:root .aq-rail,:root .aq-depth{background:#06283af0}
  :root .dive-card{background:linear-gradient(150deg,#103d52,#082537)}
  :root .focus-x{background:#021422e6}
  :root .howto::backdrop,:root .report-dialog::backdrop{-webkit-backdrop-filter:none;backdrop-filter:none;background:#020e1ef0}

  /* a long press on a game shows no copy menu and selects nothing */
  :root .dive-stage,:root .uh-board,:root .sd2-deck,:root .wm-svg,:root .wm-stage,:root .tv-box,:root .riddle-keys{-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}
}

/* windows never taller than the screen the browser shows */
@media (max-width:700px){
  :root .reveal-modal{max-height:min(88svh,880px)}
  :root .howto{max-height:92svh}
  :root .souvenir{max-height:94svh}
  :root .souvenir img{max-height:calc(94svh - 90px)}
  :root .dive-stage{height:calc(100svh - 150px)}
}

/* ---------------------------------------------------------------- the tab bar and the sheets (nav.js) */
.tabbar{display:none}
@media (max-width:700px){
  :root{--tabbar-h:62px}
  html.has-tabs{--chrome-b:calc(var(--tabbar-h) + var(--safe-b))}
  /* her own pages: the bar replaces the logo bar and the footer (both are in the "Me" sheet) */
  /* (decided by CSS, so it is true the instant a page is drawn: the aquarium measures the page right away) */
  html.has-tabs .topbar,html.has-tabs .footer{display:none}
  :root:not(.signed-out):has(#app>.cal-page,#app>#aq,#app>.arcade,#app>.game-page,#app>.landing) :is(.topbar,.footer){display:none}
  :root:has(#app .preview-bar) :is(.topbar,.footer){display:flex}   /* (Nemo's preview of a calendar keeps them) */
  html.has-tabs main{padding-top:max(14px,var(--safe-t));padding-bottom:calc(var(--chrome-b) + 28px)}
  html.has-tabs .tabbar{display:grid}
  html.game-focus .tabbar,html.finale .tabbar,html.kb-open .tabbar{display:none}

  .tabbar{position:fixed;z-index:75;left:0;right:0;bottom:0;grid-template-columns:repeat(4,1fr);
    height:var(--chrome-b);padding:0 max(6px,env(safe-area-inset-right,0px)) var(--safe-b) max(6px,env(safe-area-inset-left,0px));
    background:linear-gradient(180deg,#07283cf7,#041a2bfc);border-top:1px solid #d9a95a4d;box-shadow:0 -12px 30px #0006}
  .tab{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;min-width:0;height:var(--tabbar-h);
    border:0;background:none;padding:0;color:#a3c1c7;font:700 12px/1 var(--sans);letter-spacing:.02em;-webkit-tap-highlight-color:transparent}
  .tab svg{width:25px;height:25px;transition:transform .2s}
  .tab[aria-current=page]{color:var(--aqua)}
  .tab[aria-current=page]:after{content:'';position:absolute;top:-1px;left:30%;right:30%;height:3px;border-radius:0 0 4px 4px;background:var(--aqua);box-shadow:0 0 14px #87e8d7cc}
  .tab:active svg{transform:scale(.9)}
  .tab:focus-visible{outline:2px solid var(--aqua);outline-offset:-6px;border-radius:14px}
  .tab-dot{position:absolute;top:9px;left:calc(50% + 8px);width:10px;height:10px;border-radius:50%;background:var(--orange);box-shadow:0 0 0 2px #06263a}
  .tab-dot[hidden]{display:none}
  .tab-me{width:27px;height:27px;border-radius:50%;display:grid;place-items:center;overflow:hidden;background:#87e8d733;border:1.5px solid currentColor;font:800 13px/1 var(--sans);color:var(--white)}
  .tab-me img{width:100%;height:100%;object-fit:cover}
  .tab-me.is-out,.me-face.is-out{background:none;color:inherit}
  .tab-me.is-out svg{width:19px;height:19px}
  .me-face.is-out svg{width:28px;height:28px;color:var(--aqua)}

  /* a sheet: rises from the bottom, a handle to pull it down */
  dialog.sheet{position:fixed;inset:auto 0 0 0;width:100%;max-width:none;max-height:calc(100svh - 24px);margin:0;padding:0 0 var(--safe-b);border:0;
    border-radius:24px 24px 0 0;background:linear-gradient(175deg,#123f56,#08243a 60%);color:var(--white);box-shadow:0 -20px 60px #000a;overflow:auto;overscroll-behavior:contain;
    transition:transform .2s ease-out}
  dialog.sheet[open]{animation:sheetUp .3s cubic-bezier(.2,.9,.25,1)}
  dialog.sheet.sheet-away{transform:translateY(100%)!important}
  dialog.sheet::backdrop{background:#010d17cc}
  @keyframes sheetUp{from{transform:translateY(100%)}}
  .sheet-handle{width:42px;height:5px;margin:10px auto 4px;border-radius:5px;background:#ffffff40}

  .me-head{display:flex;align-items:center;gap:14px;padding:12px 20px 16px;border-bottom:1px solid var(--line)}
  .me-face{flex:none;width:52px;height:52px;border-radius:50%;overflow:hidden;display:grid;place-items:center;background:#87e8d733;border:2px solid var(--aqua);font:600 24px/1 var(--serif)}
  .me-face img{width:100%;height:100%;object-fit:cover}
  .me-head h2{margin:0;font-size:24px;letter-spacing:-.02em;overflow-wrap:anywhere}
  .me-head p{margin:2px 0 0;font-size:13px;color:var(--muted)}
  .me-list{display:flex;flex-direction:column;padding:6px 8px}
  .me-row{display:flex;align-items:center;gap:14px;min-height:54px;padding:0 12px;border:0;border-radius:14px;background:none;color:var(--white);font:600 16px/1.2 var(--sans);text-align:left;width:100%}
  .me-row:active{background:#ffffff12}
  .me-row>svg:first-child{width:22px;height:22px;flex:none;color:var(--aqua)}
  .me-row span{flex:1}
  .me-go{width:18px;height:18px;color:#ffffff59}
  .me-row[data-act=out]{color:#ffc8be}
  .me-row[data-act=out]>svg:first-child{color:#ffb0a5}
  .me-switch{position:relative;flex:none;width:46px;height:28px;border-radius:999px;background:#ffffff26;transition:background .2s}
  .me-switch:after{content:'';position:absolute;top:3px;left:3px;width:22px;height:22px;border-radius:50%;background:#fff;box-shadow:0 2px 6px #0006;transition:transform .2s}
  .me-row[aria-checked=true] .me-switch{background:var(--aqua)}
  .me-row[aria-checked=true] .me-switch:after{transform:translateX(18px)}
  /* the four switches under "Sound": smaller, set in, dimmed while the sound is off */
  .me-mix{margin:-4px 0 6px 36px;border-left:1px solid var(--line);padding-left:6px;transition:opacity .2s}
  .me-mix.is-off{opacity:.45}
  .me-sub{min-height:44px;font-size:15px;font-weight:500;color:#d6e8ea}
  .me-sub .me-switch{transform:scale(.85);transform-origin:right center}
  .me-foot{padding:14px 16px 18px;border-top:1px solid var(--line);color:#8eafb8;font-size:12px}
  /* the signature: one centred line, the blackbird before its name */
  .me-sign,html.signed-out .footer .credit{display:flex;align-items:center;justify-content:center;gap:7px;margin:0;white-space:nowrap;font-size:12px;letter-spacing:.02em;color:#86a6ae}
  .me-sign .credit-mark,html.signed-out .footer .credit-mark{width:17px;height:13px;flex:none}
  /* before she is aboard: the front door keeps a slim footer, the signature on one line */
  html.signed-out .footer{flex-direction:column;align-items:center;gap:8px;padding:18px 16px calc(18px + var(--safe-b));text-align:center}
  html.signed-out .footer .foot-meta{display:flex;justify-content:center;gap:14px;flex-wrap:nowrap;white-space:nowrap}
  html.signed-out .footer .foot-meta>span:last-child{display:none}
  html.signed-out .footer .credit:before{content:'Made with love for Nemo  ·';white-space:pre;margin-right:1px}
  html.signed-out .footer .credit:after{content:none}
  html.signed-out .footer .foot-meta>span:first-child{display:none}
  html.signed-out .nav-studio{display:none}
}
@media (max-width:700px) and (prefers-reduced-motion:reduce){dialog.sheet[open]{animation:none}}

/* ---------------------------------------------------------------- the calendar: today's porthole on the first screen */
@media (max-width:700px){
  :root .cal-copy{padding-top:0}
  :root .cal-copy .eyebrow{margin-bottom:10px}
  :root .cal-head h1{font-size:clamp(32px,9.5vw,40px);margin-bottom:12px}
  /* the long lead says what the countdown and the line under the portholes say already */
  :root .cal-head .lead{display:none}
  /* the aquarium, the games and "how it works" are in the tab bar and the "Me" sheet */
  html.has-tabs .cal-chips .cal-aq,html.has-tabs .cal-chips .cal-help,html.has-tabs .cal-page>.account{display:none!important}
  :root .cal-chips{display:flex;flex-direction:column;align-items:stretch;gap:4px}
  :root .cal-chips .cal-next{justify-content:flex-start;gap:10px;padding:11px 16px;font-size:14px;text-align:left}
  :root .cal-chips .cal-next strong{margin-left:auto;font-size:19px}
  /* the time zone: a quiet line under the countdown, not a second button-like pill */
  :root .cal-chips .cal-tz{border:0;background:none;padding:0 16px;justify-content:flex-start;font-size:12px;gap:6px}
  :root .cal-chips .cal-tz .ico{width:14px;height:14px}
  :root .hero-art.cal-scene{height:160px;margin-top:4px}
  :root .hero-art.cal-scene.finale{height:100vh;height:100dvh;margin:0}   /* the finale: the whole screen, whatever the size above says */
  :root .reef-tip{margin:-6px auto 10px;font-size:12px}
  /* four portholes a row on every phone, big enough to tap */
  :root .ports{grid-template-columns:repeat(4,minmax(0,1fr));gap:18px 12px}
  :root .hull{border-radius:24px}
  :root .hull-plate{padding:12px 6px 16px}
  :root .cal-hint{margin:14px 4px 0}
  /* the depth gauge: one line and its track */
  :root .depth{margin:22px 0;padding:14px 16px 16px}
  :root .depth-read{margin-bottom:12px;gap:4px 14px}
  :root .depth-value{font-size:26px}
  :root .depth-scale{display:none}
  :root .depth-track{height:22px}
  :root .depth-sub{width:30px;height:30px;margin:-15px 0 0 -15px}
  :root .legend{margin-top:32px}
}

/* ---------------------------------------------------------------- the surprise card: a sheet from the bottom */
@media (max-width:700px){
  :root .sheet-away{transform:translateY(100%)!important;transition:transform .2s ease-in!important}
  :root .reveal-modal{inset:auto 0 0 0;width:100%;max-width:none;max-height:calc(100svh - 20px);margin:0;border-radius:24px 24px 0 0;transition:transform .2s ease-out}
  :root .reveal-modal[open]{animation:sheetUp .38s cubic-bezier(.2,.9,.25,1)}
  :root .reveal-modal:before{content:'';position:absolute;z-index:4;top:8px;left:50%;width:42px;height:5px;margin-left:-21px;border-radius:5px;background:#ffffff66}
  :root .rv-view{height:122px;padding-top:14px;touch-action:none}
  :root .rv-porthole{width:84px;height:84px;box-shadow:0 0 0 6px #c8934a,0 0 0 8px #5e3b1a,0 0 0 9px #f3d79a66,0 0 50px color-mix(in srgb,var(--k) 65%,transparent)}
  :root .rv-icon .ico{width:42px;height:42px}
  :root .modal-close{top:12px;right:12px}
  :root .rv-body{padding:20px 20px 0}
  :root #reveal h2{font-size:clamp(25px,7vw,30px)}
  :root .rv-text{font-size:17px;line-height:1.7}
  /* the buttons stay at the bottom of the sheet, under her thumb, however long the surprise */
  :root .rv-actions{position:sticky;bottom:0;z-index:2;margin:0 -20px;padding:12px 20px calc(14px + var(--safe-b));gap:10px;
    background:var(--paper);box-shadow:0 -12px 22px -8px #14323f26}
  :root .rv-actions .btn{flex:1 1 40%;min-height:48px;padding:12px 14px;font-size:14px}
  :root .rv-actions .btn:not(.alt){flex-basis:100%;order:-1;min-height:52px;font-size:15px}
  :root .rv-actions .rv-status{order:-2}
  :root .rv-actions .rv-close{display:none}
  :root .rv-meet{margin-bottom:18px}
  :root .rv-meet .btn{width:100%;min-height:48px}
}

/* ---------------------------------------------------------------- games: the header, the arcade as a list */
@media (max-width:700px){
  /* the header: "← All games" and "?" on one row, the title under them on its own, never overlapped */
  :root .game-top{display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:10px 12px;margin:0 0 14px}
  :root .game-top>.btn{grid-column:1;grid-row:1;margin:0;justify-self:start}
  :root .game-top .howto-btn{position:static;grid-column:3;grid-row:1;margin:0}
  :root .game-top>div{grid-column:1 / -1;grid-row:2;min-width:0}
  :root .game-top .eyebrow{margin-bottom:4px}
  :root .game-top h1{font-size:clamp(30px,8.6vw,40px);line-height:1.08;text-wrap:balance}

  /* the arcade */
  :root .arc-top{margin-bottom:16px;gap:12px}
  :root .arc-top h1{font-size:clamp(36px,10vw,46px)}
  :root .arc-wait{flex-direction:row;flex-wrap:wrap;align-items:baseline;gap:2px 10px;padding:12px 16px}
  :root .arc-wait b{font-size:22px}
  :root .arc-wait small{flex-basis:100%}
  :root .arc-hero-art{min-height:170px}
  :root .arc-hero-copy{padding:4px 18px 20px;gap:10px}
  :root .arc-hero h2{font-size:30px}
  :root .arc-hero p{font-size:14px}
  :root .arc-play{align-self:stretch;min-height:50px}
  :root .gc-champ.empty{display:none}
  :root .arc-chamber{margin-top:28px;padding:16px 12px 14px;border-radius:24px}
  :root .arc-chamber-head{margin:0 4px 12px}
  :root .arc-chamber-head p{font-size:13px}
  :root .arc-shelf{margin-top:28px;font-size:22px}
  :root .arc-chamber .arc-shelf{margin-top:0}

  /* one game, one row: the cover on the left, the name and how she did on the right */
  :root .arc-grid{grid-template-columns:minmax(0,1fr);gap:10px}
  /* (the whole cover, small: its lettering is never cut) */
  :root .gc{display:grid;grid-template-columns:118px minmax(0,1fr);align-items:center;border-radius:18px}
  :root .gc-art{aspect-ratio:16/10;margin:10px 0 10px 10px;border-radius:12px}
  :root .gc-genre{display:none}
  :root .gc-new{position:static;display:inline-block;margin:0 0 2px;align-self:flex-start;padding:2px 7px;font-size:12px;letter-spacing:.06em;border-radius:6px;transform:none;box-shadow:none}
  :root .gc-body{padding:12px 12px 12px 14px;gap:4px;justify-content:center}
  :root .gc-body h3{font-size:19px;line-height:1.15}
  :root .gc-body p{display:block;font-size:13px;line-height:1.35}
  :root .gc-meta{min-height:0}
  :root .gc-meta:empty,:root .gc-meta:has(.gc-champ.empty){display:none}
  :root .gc-foot{flex-wrap:nowrap;padding-top:6px;border-top:0}
  :root .gc-play{width:36px;height:36px}
}

/* ---------------------------------------------------------------- the aquarium: the reef between the top of the screen and the tab bar */
@media (max-width:700px){
  html.has-tabs main:has(#aq){padding-top:0}
  html.has-tabs .aq.is-swipe,html.has-tabs .aq.is-swipe .aq-stage{height:calc(100svh - var(--chrome-b))}
  :root .aq-top{top:max(12px,var(--safe-t));left:14px;right:14px}
  :root .aq-title{padding:8px 12px}
  :root .aq-title strong{font-size:17px}
  :root .aq-all{min-height:32px}
  :root .aq-depth-z{font-size:12px;letter-spacing:.04em}
  :root .aq-card{bottom:72px;max-width:calc(100% - 28px)}
  :root .aq-hint{bottom:164px}   /* above the friend's card (72 px up, about 70 tall), never under it */
  :root .aq-rail{bottom:16px}
  :root .aq-rename{width:44px;height:44px}
  /* "← My calendar" is the Calendar tab now: the depth takes its place, the friend's card sits under them */
  html.has-tabs .aq-top>.btn{display:none}
  :root .aq-depth{position:static;margin:0;padding:8px 12px;align-self:stretch;justify-content:center}
  :root .aq-card.at-top{top:calc(max(12px,var(--safe-t)) + 84px)}
}

/* ---------------------------------------------------------------- Word of the Day, U-Haul */
@media (max-width:700px){
  /* the colour key stays, the sentence around it goes (the "?" explains it): the grid and the keys fit one screen */
  :root .riddle-lead{font-size:0;margin:0 0 12px;text-align:center}
  :root .rl-key{font-size:12px;margin:0 6px}
  :root .rg-row{grid-template-columns:repeat(var(--n,5),min(13.5vw,7svh));gap:7px}
  :root .riddle-grid{gap:7px;margin-bottom:14px}
  :root .rg-tile{font-size:min(7vw,3.6svh);border-radius:10px}
  :root .riddle-keys{gap:6px}
  :root .riddle-keys div{gap:4px}
  :root .rk{height:52px;max-width:none;font-size:16px;border-radius:8px}
  :root .rk.wide{font-size:13px}

  :root .uh-bar{flex-wrap:nowrap;gap:8px}
  :root .uh-stat{min-width:0;padding:8px 12px}
  :root .uh-stat:nth-child(2){flex:1}
  :root .uh-stat b{font-size:18px;white-space:normal;line-height:1.2}
  :root .uh-bar .btn{flex:none;padding:10px 14px}
}

/* ---------------------------------------------------------------- the landing page and coming aboard */
@media (max-width:700px){
  /* one clear way in, the others under it, all the same width */
  :root .landing .actions{flex-direction:column;align-items:stretch;gap:10px}
  :root .landing .actions .btn{min-height:48px;font-size:14px}
  :root .landing .actions .btn:first-child{min-height:54px;font-size:16px}
  :root .landing .lead{line-height:1.75}
  :root .section-label{margin:30px 0 16px}
  :root .section-label h2{font-size:clamp(28px,8vw,36px)}
  /* the three promises: the icon beside the words, not above them */
  :root .feature-row{gap:12px;margin-bottom:36px}
  :root .feature{display:grid;grid-template-columns:auto minmax(0,1fr);column-gap:16px;align-items:start;padding:18px 20px}
  :root .feature-icon{grid-row:span 2;margin:2px 0 0}
  :root .feature h3{font-size:20px;margin-bottom:4px}
  :root .feature p{font-size:14px;line-height:1.5}
  :root .aboard .dev-login div .btn{flex:none;white-space:nowrap}
  :root .footer{padding-bottom:calc(25px + var(--safe-b))}
}

/* ---------------------------------------------------------------- meeting a new friend */
@media (max-width:700px){
  /* it still scrolls on a very short screen, without showing a bar */
  :root dialog.meet{scrollbar-width:none}
  :root dialog.meet::-webkit-scrollbar{display:none}
  :root .meet-copy{padding:4px 20px max(24px,calc(12px + var(--safe-b)))}
  :root .meet-tap{margin-bottom:16px}
  :root .meet-actions{flex-direction:column;align-items:stretch;gap:8px;max-width:360px;margin:0 auto}
  :root .meet-actions .btn{min-height:50px;font-size:15px}
}

/* "Find in the reef" needs the 3D reef: without it (an old phone, or the reef failed) the button would do nothing */
@media (max-width:700px){
  :root .aq-stage:not(.has-webgl)~* .aq-album li .btn,:root .aq:has(.aq-stage:not(.has-webgl)) .aq-album li .btn{display:none}
}
