/* On phones the arena is the screen. Controls float over the broadcast. */
@media (max-width:800px) {
  :root {
    --arena-safe-top:env(safe-area-inset-top,0px);
    --arena-safe-left:max(12px,env(safe-area-inset-left,0px));
    --arena-safe-right:max(12px,env(safe-area-inset-right,0px));
    --arena-floor:calc(env(safe-area-inset-bottom,0px) + 12px);
    --arena-chrome:#fbfdf0eb;
  }
  html:has(body.app-shell),body.app-shell {
    width:100%;height:100%;height:100dvh;min-height:0;
    margin:0;padding:0;overflow:hidden;overscroll-behavior:none;
  }
  body.app-shell {border:0;border-radius:0;background:#d8e8d2;box-shadow:none;}
  .app-shell main,.app-shell .game-layout,.app-shell .arena-column {margin:0;padding:0;min-height:0;}
  .app-shell .game-layout {display:block;}
  .app-shell .arena-column>.race-schedule,.app-shell #round-brief,
  .app-shell .arena-meta,.app-shell .race-footnote,.app-shell .announcer,
  .app-shell .arena-column>#animal-roster {display:none!important;}

  .app-shell .arena {
    position:fixed;inset:0;z-index:0;width:100%;height:100%;height:100dvh;
    margin:0;border:0;border-radius:0;overflow:hidden;box-shadow:none;
  }
  .app-shell .stage,.app-shell.market-round .stage {
    position:absolute;inset:0;width:100%;height:100%;height:100dvh;
    min-height:0;max-height:none;border-radius:0;
  }
  .app-shell #race-canvas {display:block;width:100%;height:100%;}
  .app-shell #race-canvas.hidden {display:none!important;}
  .app-shell .stage::after {
    content:'';position:absolute;inset:0;z-index:1;pointer-events:none;
    background:linear-gradient(180deg,#18372b35 0,transparent 190px,transparent calc(100% - 170px),#16312850 100%);
  }
  .app-shell .stage-controls,.app-shell .race-progress {display:none!important;}

  .app-shell .topbar {
    position:fixed;top:calc(var(--arena-safe-top) + 10px);left:var(--arena-safe-left);right:var(--arena-safe-right);
    z-index:20;height:44px;min-height:44px;width:auto;margin:0;padding:0;gap:8px;
    border:0;border-radius:0;background:transparent;box-shadow:none;backdrop-filter:none;
    justify-content:space-between;pointer-events:none;
  }
  .app-shell .topbar>* {pointer-events:auto;}
  .app-shell .brand {
    gap:7px;height:44px;padding:6px 9px 6px 6px;border-radius:14px;background:var(--arena-chrome);
    border:1px solid #fff9;box-shadow:0 4px 16px #19362a13;font-size:12px;letter-spacing:0;flex-shrink:0;
  }
  .app-shell .brand-mark {width:30px;height:30px;border-radius:9px;}
  .app-shell .brand-mark svg {width:23px;height:23px;}
  .app-shell .header-actions {gap:5px;margin-left:auto;}
  .app-shell .header-actions .icon-button {width:40px;height:40px;border-radius:13px;background:var(--arena-chrome);border:1px solid #fff9;}
  .app-shell .header-actions .help {display:none;}
  .app-shell .level-button {height:40px;min-width:40px;padding:5px;border-radius:12px;background:var(--arena-chrome);border-color:#fff9;}
  .app-shell .level-button>span {font-size:7px;}
  .app-shell .level-button strong {font-size:13px;margin-left:2px;}
  .app-shell .wallet {height:40px;padding:6px 9px;border-radius:12px;background:var(--arena-chrome);border-color:#fff9;font-size:12px;gap:5px;}
  .app-shell .wallet .coin {width:19px;height:19px;font-size:11px;}

  .app-shell .arena-top {
    position:absolute;top:calc(var(--arena-safe-top) + 62px);left:var(--arena-safe-left);right:auto;
    z-index:8;width:max-content;max-width:calc(100% - 98px);height:32px;min-height:32px;
    padding:0 10px;gap:8px;border:1px solid #fff8;border-radius:10px;background:var(--arena-chrome);
    box-shadow:0 2px 12px #1735290e;backdrop-filter:blur(9px);
  }
  .app-shell #round-label {display:none;}
  .app-shell .round-label {font-size:11px;white-space:nowrap;}
  .app-shell .race-type {margin-left:0;font-size:11px;}
  .app-shell .condition {font-size:8px;padding:4px 5px;white-space:nowrap;background:#e2ead7b3;}
  .app-shell .live-round-band {
    position:fixed;top:calc(var(--arena-safe-top) + 62px);right:var(--arena-safe-right);left:auto;z-index:21;
    margin:0;padding:0 10px;gap:0;height:32px;min-height:32px;min-width:66px;
    border:1px solid #ffffff40;border-radius:10px;background:#284638e6;color:#f4f8e7;box-shadow:0 2px 12px #1735291a;
  }
  .app-shell .live-round-band .sync-pill,.app-shell .round-length {display:none!important;}
  .app-shell .live-round-band .round-phase>span{display:inline;color:#e1ecde;font-size:10px;font-weight:600;white-space:nowrap;}
  .app-shell .round-phase {margin:0;gap:6px;}
  .app-shell .round-phase>strong {font-size:19px;color:#f4f8e7;letter-spacing:-.4px;}
  .app-shell .broadcast-hud {top:calc(var(--arena-safe-top) + 104px);left:var(--arena-safe-left);right:var(--arena-safe-right);}
  .app-shell .broadcast-hud>span {font-size:10px;background:#223e32ba;border:1px solid #ffffeb30;padding:6px 9px;backdrop-filter:blur(8px);}
  .app-shell .scene-replay-caption {top:calc(var(--arena-safe-top) + 104px);left:var(--arena-safe-left);font-size:10px;padding:6px 9px;max-width:calc(100% - 24px);}

  .app-shell .live-standings {
    left:var(--arena-safe-left);right:var(--arena-safe-right);bottom:calc(var(--arena-floor) + 72px);
    padding:6px 8px;
  }
  .app-shell .live-standings>li {font-size:10px;gap:4px;padding:3px 2px;}
  .app-shell .live-standings>li>b {font-size:9px;}
  .app-shell .scene-result {
    left:var(--arena-safe-left);right:var(--arena-safe-right);bottom:calc(var(--arena-floor) + 72px);
    width:auto;padding:11px 12px 10px;border-radius:15px;background:#263d30df;backdrop-filter:blur(12px);
  }
  .app-shell .scene-result-actions>button {min-height:40px;font-size:11px;}
  .app-shell .scene-result-title>strong {font-size:16px;}
  .app-shell .scene-result-rewards>strong {font-size:20px;}
  .app-shell .scene-result-rewards>span {font-size:10px;}
  .app-shell .stage:has(.live-standings:not(.hidden)) .finish-banner {
    top:calc(var(--arena-safe-top) + 154px);font-size:15px;padding:7px 14px;border-radius:10px;
  }

  .app-shell .app-bottom-nav {
    position:fixed;left:var(--arena-safe-left);right:auto;bottom:var(--arena-floor);z-index:35;
    transform:none;width:196px;height:52px;max-width:calc(100% - 146px);padding:4px;gap:1px;
    border:1px solid #ffffffa6;border-radius:17px;background:#fbfdf0eb;box-shadow:0 6px 25px #17352930;backdrop-filter:blur(18px);
  }
  .app-shell .app-bottom-nav>button {min-width:0;min-height:42px;padding:4px 2px;gap:2px;font-size:8px;border-radius:12px;color:#6a8069;}
  .app-shell .app-bottom-nav>button svg {width:18px;height:18px;}
  .app-shell .app-bottom-nav>button.active {color:#31583b;background:#dde9c9;}
  .app-shell .app-bottom-nav>button.active::before {display:none;}
  .app-shell .mobile-action-bar {
    position:fixed;left:auto;right:var(--arena-safe-right);bottom:var(--arena-floor);z-index:36;
    width:110px;height:52px;margin:0;padding:0;gap:0;border:0;border-radius:16px;
    background:transparent;box-shadow:none;backdrop-filter:none;
  }
  .app-shell .mobile-action-bar>button {
    width:110px;min-width:110px;height:52px;min-height:52px;justify-content:center;padding:10px;
    border:1px solid #e7f1c54d;border-radius:16px;background:#2d4c36f2;color:#fffdeb;font-size:13px;
    box-shadow:0 6px 25px #17352940;
  }
  .app-shell .mobile-action-bar>div {
    position:absolute;right:0;bottom:64px;width:max-content;max-width:calc(100vw - 24px);padding:6px 9px;
    border:1px solid #ffffff80;border-radius:9px;background:#fbfdf0e8;backdrop-filter:blur(10px);box-shadow:0 2px 12px #17352910;
  }
  .app-shell .mobile-action-bar strong {max-width:calc(100vw - 46px);font-size:10px;line-height:1.4;color:#3d5a3d;}
  .app-shell .mobile-action-bar>div>span {display:none;}
  .app-shell:has(#live-standings:not(.hidden)) .mobile-action-bar>div,
  .app-shell.round-result .mobile-action-bar>div,.app-shell.market-round .mobile-action-bar>div {display:none;}
  .app-shell.ticket-open .topbar,.app-shell.ticket-open .live-round-band {pointer-events:none;}

  .app-shell .ticket {
    max-height:calc(92dvh - var(--arena-safe-top));padding:30px 18px calc(18px + var(--app-safe-bottom));
    border-radius:24px 24px 0 0;overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;
    background:#fcfdf7f7;box-shadow:0 -15px 60px #18332235;backdrop-filter:blur(16px);
  }
  .app-shell .ticket-close {top:10px;right:12px;width:42px;height:42px;background:#e9efdf;border-radius:13px;}
  .app-shell .ticket #animal-roster {display:block;margin:0 0 15px;}
  .app-shell .ticket #animal-roster .roster-heading {margin:0 0 8px;}
  .app-shell .ticket #animal-roster .roster-heading h2 {font-size:12px;margin:0;padding:0;}
  .app-shell .ticket #animal-roster .animal-card {height:71px;min-height:71px;}
  .app-shell .ticket #animal-roster .animal-card canvas {height:39px;}
  .app-shell .ticket-backdrop {background:#17332766;backdrop-filter:blur(3px);}

  .app-shell dialog,.app-shell dialog.app-tab-view {
    position:fixed;inset:auto 0 0;top:auto;bottom:0;margin:0 auto;width:100%;max-width:620px;
    height:auto;max-height:calc(92dvh - var(--arena-safe-top));border:1px solid #dce5d2;border-bottom:0;
    border-radius:24px 24px 0 0;background:#fafcf4f7;backdrop-filter:none;box-shadow:0 -15px 60px #18332235;
    padding:13px 18px calc(20px + var(--app-safe-bottom));overflow-y:auto;overscroll-behavior:contain;
  }
  .app-shell dialog.app-tab-view {height:calc(90dvh - var(--arena-safe-top));padding-bottom:calc(80px + var(--app-safe-bottom));}
  .app-shell dialog::backdrop,.app-shell dialog.app-tab-view::backdrop {background:#17332766;backdrop-filter:blur(3px);}
  .app-shell dialog.app-tab-view::before {display:block;}
  .app-shell .modal-top {top:-14px;min-height:44px;padding:9px 0 6px;margin-bottom:5px;background:#fafcf4ee;}
  .app-shell .modal-top .icon-button {width:42px;height:42px;border-radius:13px;font-size:24px;}
  .app-shell dialog.app-tab-view .app-bottom-nav {
    position:fixed;left:50%;right:auto;bottom:var(--arena-floor);transform:translateX(-50%);
    width:228px;max-width:calc(100% - 36px);height:52px;border:1px solid #dce5d2;border-radius:17px;padding:4px;gap:4px;
  }
  .app-shell .toast {bottom:calc(var(--arena-floor) + 118px);max-width:calc(100% - 32px);z-index:120;font-size:11px;}
  .app-shell.ticket-open .toast {bottom:calc(var(--app-safe-bottom) + 16px);}

  .app-shell .market-stage {
    padding:calc(var(--arena-safe-top) + 114px) 15px calc(var(--arena-floor) + 76px);
    background:#213238;gap:0;
  }
  .app-shell .market-chart-top {flex-shrink:0;padding:0 1px;}
  .app-shell .market-chart-top h3 {font-size:20px;}
  .app-shell .market-quote strong {font-size:27px;}
  .app-shell .market-quote>span {font-size:10px;}
  .app-shell .market-asset-tabs {flex-shrink:0;margin:14px 0 3px;gap:6px;}
  .app-shell .market-asset-tabs>button {min-height:38px;padding:8px 9px;}
  .app-shell .market-chart-area {min-height:100px;margin:10px -5px 0;}
  .app-shell .market-news {flex-shrink:0;margin:0;padding:10px 1px 0;min-height:38px;border:0;background:transparent;}
  .app-shell .market-news>p {font-size:10px;line-height:1.5;}
  .app-shell .market-news>span {font-size:8px;}
}

@media (max-width:359px) {
  .app-shell .brand {padding-right:7px;gap:5px;font-size:11px;}
  .app-shell .brand-mark {width:27px;height:27px;}
  .app-shell .header-actions {gap:4px;}
  .app-shell .header-actions .icon-button {width:36px;height:38px;}
  .app-shell .wallet {padding:6px;font-size:11px;}
  .app-shell .arena-top {padding:0 8px;gap:5px;}
  .app-shell .condition {font-size:7px;padding:4px;}
  .app-shell .app-bottom-nav {width:174px;max-width:calc(100% - 130px);}
  .app-shell .mobile-action-bar,.app-shell .mobile-action-bar>button {width:98px;min-width:98px;}
  .app-shell .live-standings {padding:6px;}
  .app-shell .live-standings>li {font-size:9px;gap:3px;}
}

@media (max-width:800px) and (max-height:500px) and (orientation:landscape) {
  .app-shell .topbar {top:calc(var(--arena-safe-top) + 6px);height:38px;min-height:38px;}
  .app-shell .brand {height:38px;padding-top:3px;padding-bottom:3px;}
  .app-shell .header-actions .icon-button,.app-shell .level-button,.app-shell .wallet {height:36px;}
  .app-shell .arena-top,.app-shell .live-round-band {top:calc(var(--arena-safe-top) + 51px);height:28px;min-height:28px;}
  .app-shell .broadcast-hud,.app-shell .scene-replay-caption {top:calc(var(--arena-safe-top) + 87px);}
  .app-shell .live-standings {left:220px;right:calc(var(--arena-safe-right) + 122px);bottom:var(--arena-floor);transform:none;width:auto;min-width:0;padding:5px;}
  .app-shell .live-standings>li {font-size:8px;gap:2px;}
  .app-shell .live-standings>li>b {font-size:8px;}
  .app-shell .scene-result {left:50%;right:auto;bottom:calc(var(--arena-floor) + 62px);transform:translateX(-50%);width:min(410px,calc(100% - 36px));}
  .app-shell .stage:has(.live-standings:not(.hidden)) .finish-banner {top:calc(var(--arena-safe-top) + 120px);}
  .app-shell .market-stage {padding-top:calc(var(--arena-safe-top) + 87px);padding-bottom:calc(var(--arena-floor) + 60px);}
  .app-shell .market-chart-top h3 {font-size:17px;}
  .app-shell .market-quote strong {font-size:22px;}
  .app-shell .market-asset-tabs {grid-template-columns:repeat(6,minmax(0,1fr));margin-top:7px;}
  .app-shell .market-asset-tabs>button {min-height:30px;padding:5px 7px;}
  .app-shell .market-chart-area {min-height:55px;margin-top:5px;}
  .app-shell .market-news {min-height:25px;padding-top:4px;}
  .app-shell .market-news>p {font-size:9px;}
}

@media (max-width:600px) and (max-height:500px) and (orientation:landscape) {
  .app-shell .live-standings {left:var(--arena-safe-left);right:var(--arena-safe-right);bottom:calc(var(--arena-floor) + 64px);width:auto;}
}
