/* ---------- 响应式 ---------- */
@media (max-width:940px){
  body{padding:10px}
  .main{flex-direction:column}
  .panel{width:100%;flex:1 1 auto}
  /* 窄屏面板在台面下方，没有「收起」这回事：页头按钮与开关都藏起来 */
  .panel-mini,.chal{display:none}

  .canvas-wrap{padding:6px}
  .btn-card{flex-wrap:wrap}
  .btn{flex:1 1 45%}
  /* 页头「趣味挑战」在窄屏被藏起来了，清台的入口改从面板这颗按钮进
     （用 flex 顶掉 hidden 之后一定要补居中，否则文字会贴左边） */
  .btn.only-narrow{display:flex;align-items:center;justify-content:center}
  .chip{width:24px;height:24px;font-size:11px}
  .chips{gap:5px}
}
@media (max-width:560px){
  .brand h1{font-size:17px}
  .seg button{padding:6px 11px;font-size:12px}
  .btn{flex:1 1 100%;min-width:0}
  .status-line{font-size:14px}
  .rec-list{font-size:12px}
  /* 球号条：窄屏改成上下两段，小球缩小，一行放下 7 颗 */
  .rack-strip{gap:6px}
  /* 计时跟着收一档，别把两颗球号挤到换行 */
  .rack-clock{flex:0 0 56px;font-size:15px}
  .rack-clock::before,.rack-clock::after{height:20px}
  .group-panel{flex-direction:column;align-items:flex-start;gap:6px;padding:7px 9px;border-radius:11px}
  .gp-head{flex-direction:row;align-items:baseline;gap:6px}
  .gp-owner{font-size:12px}
  .gp-tag{font-size:10px}
  .chip{width:18px;height:18px;font-size:9px}
  .chips{gap:3px;justify-content:flex-start}
}

/* 手机竖屏再窄一档（≤560px）：计时压到最小、球号缩小一点，保住“7 颗球号一行不裁” */
@media (max-width:560px){
  .rack-clock{flex:0 0 46px;font-size:13px;letter-spacing:0}
  .rack-clock::before,.rack-clock::after{height:18px}
  .group-panel{padding:6px 8px;gap:5px}
  .chip{width:17px;height:17px;font-size:8px}
  .chips{gap:2px}
}

/* ============================================================
   手机横屏：全屏台面（只留必要信息），面板收进右侧抽屉
   —— 竖屏保持上面那套「台面在上、面板在下」的布局不变
   ============================================================ */
@media (orientation:landscape) and (max-height:560px) and (max-width:1000px){
  html,body{height:100%;overflow:hidden}
  body{padding:0;background:#05080d}
  .app{height:100dvh;padding:0 6px;gap:0}

  /* 页头收起来，把纵向空间全留给台面 */
  header{display:none}
  /* 横屏已经有右上角的「面板」抽屉按钮，页头这个桌面开关就不需要了 */
  .panel-mini{display:none}

  .main{flex:1 1 auto;min-height:0;display:flex;flex-direction:column;
    gap:4px;padding:4px 0 36px}

  /* 台面：宽度由可用高度反推（1120/620 ≈ 1.8065），等比不变形；
     多出来的两侧留黑，手指也不容易挡住球 */
  .stage{flex:1 1 auto;min-height:0;display:flex}
  .table-col{width:min(100%,calc((100dvh - 76px) * 1.8065));height:100%;gap:4px;margin:0 auto}

  /* 顶部细带：球号条压扁成一行，右端「全屏」「面板」两个小按钮
     宽度不够时最先让位的是“纯色/花色”小字（颜色本身已经分得清），球号一颗都不许裁 */
  .rack-strip{flex:0 0 auto;gap:5px;align-items:center}
  .group-panel{flex-direction:row;align-items:center;gap:6px;
    padding:3px 7px;border-radius:9px;overflow:hidden}
  .gp-head{flex:0 0 auto;flex-direction:row;align-items:baseline;gap:4px;min-width:0}
  .gp-owner{font-size:10px;line-height:1.2;white-space:nowrap}
  .gp-tag{display:none}
  .chips{gap:2px;flex-wrap:nowrap;justify-content:flex-start;overflow:hidden;min-width:0}
  .chip{flex:0 0 auto;width:13px;height:13px;font-size:7px}
  .panel-toggle{display:flex;padding:0 8px;font-size:11px;height:24px}

  /* 画布容器：宽度铺满 table-col，高度随之等比缩放 */
  .canvas-wrap{width:100%;padding:4px;border-radius:12px}

  /* 底部状态条：一行读完「轮到谁 + 力度」，固定不占台面高度 */
  .status-card{
    position:fixed;left:0;right:0;bottom:0;z-index:39;
    flex-direction:row;align-items:center;gap:10px;
    padding:5px 10px calc(5px + env(safe-area-inset-bottom,0px));
    border-radius:0;border-left:0;border-right:0;border-bottom:0;
    background:rgba(9,14,20,.97);
    box-shadow:0 -8px 22px rgba(0,0,0,.45);
    transition:opacity .16s;
  }
  .status-card .sub{display:none}
  .status-card .status-line{flex:0 1 auto;min-width:0;font-size:13px;gap:6px}
  .status-card .status-line #statusText{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .status-card .power-block{flex:1 1 auto;min-width:0;margin:0;padding:0;border-top:0;
    display:flex;align-items:center;gap:8px}
  .status-card .power-head{margin:0;flex:0 0 auto;gap:6px;font-size:11px}
  .status-card .power-track{flex:1 1 auto;height:9px}

  /* 面板：右侧抽屉，点「面板」滑出，点遮罩或选完即收起 */
  .panel{
    position:fixed;top:0;right:calc(-1 * min(340px,88vw));z-index:41;
    width:min(340px,88vw);height:100dvh;max-height:100dvh;
    overflow-y:auto;overscroll-behavior:contain;
    padding:10px max(10px,env(safe-area-inset-right,0px)) 58px 10px;
    background:#0a1119;border-left:1px solid #1b2837;border-radius:0;
    transition:right .22s ease;
  }
  body.panel-open .panel{right:0}
  body.panel-open .panel-scrim{
    display:block;position:fixed;inset:0;z-index:40;background:rgba(3,7,12,.66);
  }
  /* 抽屉展开时先藏起底部状态条，免得挡住战绩 */
  body.panel-open .status-card{opacity:0;pointer-events:none}

  /* 抽屉里一行一个按钮更好点 */
  .btn{flex:1 1 100%}

  /* 顶部细带宽度太紧（球号一颗都不许裁），横屏把计时放回底部状态条右端；
     布局细节用 display 切换，桌面上这两条互斥，不会同时出现两个表 */
  .rack-clock{display:none}
  .bar-clock{display:inline;font-size:11px;color:#a8bccd;margin-left:2px}
}

/* ============================================================
   手机竖屏轻提示：提醒横屏 + 全屏更好打
   —— 只做一条不遮台面的小条，点「知道了」后写进 localStorage 不再出现
   ============================================================ */
.rotate-tip{display:none}
@media (orientation:portrait) and (max-width:1000px){
  .rotate-tip:not([hidden]){
    display:flex;align-items:center;gap:10px;
    margin:0 2px 6px;padding:8px 10px;border-radius:10px;
    border:1px solid #2a4257;background:linear-gradient(180deg,#16222f,#111a25);
    box-shadow:0 6px 18px rgba(0,0,0,.35);
  }
  .rotate-tip .rt-text{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:2px}
  .rotate-tip .rt-title{font-size:13px;font-weight:600;color:#e8f2fa}
  .rotate-tip .rt-desc{font-size:11px;line-height:1.35;color:#93a8bb}
  .rotate-tip .rt-btn{
    flex:0 0 auto;padding:6px 12px;border-radius:8px;cursor:pointer;
    border:1px solid #31506b;background:#1d2c3c;color:#d7e6f2;font-size:12px;
  }
  .rotate-tip .rt-btn:hover{background:#24384c}
}
