  :root {
    --acc: #d8f03a; --ink: #10202f; --panel: rgba(10, 22, 42, .94); --muted: #9fb3c8;
    --st: env(safe-area-inset-top, 0px); --sr: env(safe-area-inset-right, 0px);
    --sb: env(safe-area-inset-bottom, 0px); --sl: env(safe-area-inset-left, 0px);
  }
  html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1a2a; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; color: #fff;
    user-select: none; -webkit-user-select: none; touch-action: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
  canvas { display: block; touch-action: none; }
  button { font: inherit; -webkit-tap-highlight-color: transparent; }
  .hidden { display: none !important; }
  kbd { background: #24364f; border-radius: 4px; padding: 1px 6px; font-family: inherit; font-size: 12px; border-bottom: 2px solid #142235; white-space: nowrap; }

  /* placar estilo TV */
  #score { position: fixed; top: calc(10px + var(--st)); left: calc(10px + var(--sl)); border-radius: 6px; overflow: hidden; box-shadow: 0 6px 20px rgba(0,0,0,.4); font-size: 14px; }
  #score .row { display: flex; align-items: stretch; height: 27px; background: rgba(9, 20, 42, .92); }
  #score .row + .row { border-top: 1px solid rgba(255,255,255,.08); }
  #score .srv { width: 14px; display: flex; align-items: center; justify-content: center; }
  #score .srv i { width: 7px; height: 7px; border-radius: 50%; background: var(--acc); box-shadow: 0 0 6px var(--acc); visibility: hidden; }
  #score .srv i.on { visibility: visible; }
  #score .nm { width: 58px; font-weight: 700; letter-spacing: .5px; display: flex; align-items: center; }
  #score .sets { display: flex; align-items: center; }
  #score .sets b { width: 22px; text-align: center; color: #8ea3b9; font-weight: 600; }
  #score .sets b.w { color: #fff; }
  #score .sets b.cur { color: #fff; background: rgba(255,255,255,.08); height: 100%; display: flex; align-items: center; justify-content: center; }
  #score .pt { min-width: 36px; display: flex; align-items: center; justify-content: center; background: var(--acc); color: var(--ink); font-weight: 800; }
  #score .tag { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); background: rgba(9,20,42,.92); padding: 2px 8px; border-top: 1px solid rgba(255,255,255,.08); }

  #tools { position: fixed; top: calc(10px + var(--st)); right: calc(10px + var(--sr)); display: flex; gap: 8px; }
  #tools button { width: 40px; height: 40px; border-radius: 10px; background: rgba(8, 20, 40, .72); border: 1px solid rgba(255,255,255,.14); color: #fff; display: grid; place-items: center; cursor: pointer; padding: 0; }
  #tools button svg { width: 20px; height: 20px; }
  #tools button.off { opacity: .45; }

  #toast { position: fixed; top: calc(14px + var(--st)); left: 50%; transform: translateX(-50%) translateY(-8px); background: rgba(9,20,42,.9); border-left: 3px solid var(--acc); padding: 6px 14px; border-radius: 4px; font-weight: 700; font-size: 14px; letter-spacing: .5px; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; white-space: nowrap; }
  #toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
  #toast span { color: var(--acc); }

  #msg { position: fixed; top: 30%; left: 50%; transform: translate(-50%, -50%) scale(.96); text-align: center; pointer-events: none; opacity: 0; transition: opacity .25s, transform .25s; width: 92vw; }
  #msg.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  #msg .big { font-size: clamp(30px, 7vw, 60px); font-weight: 800; text-shadow: 0 4px 16px rgba(0,0,0,.7); letter-spacing: 1px; }
  #msg .small { font-size: clamp(15px, 3.4vw, 22px); font-weight: 600; text-shadow: 0 2px 8px rgba(0,0,0,.85); margin-top: 4px; }

  #fb { position: fixed; top: 58%; left: 50%; transform: translateX(-50%); font-weight: 800; letter-spacing: 2px; font-size: 15px; text-shadow: 0 2px 8px rgba(0,0,0,.8); opacity: 0; transition: opacity .2s; pointer-events: none; white-space: nowrap; }
  #fb.show { opacity: 1; }

  #hint { position: fixed; bottom: calc(14px + var(--sb)); left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.5); padding: 7px 16px; border-radius: 20px; font-size: 13.5px; white-space: nowrap; max-width: 94vw; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
  #hint:empty { display: none; }
  body.touch #hint { bottom: auto; top: calc(62px + var(--st)); font-size: 12px; }

  #meter { position: fixed; right: calc(26% + var(--sr)); top: 50%; transform: translateY(-50%); width: 14px; height: 170px; border-radius: 8px; background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.25); pointer-events: none; }
  #meter .zone { position: absolute; left: 0; right: 0; background: rgba(216, 240, 58, .55); border-radius: 3px; }
  #meter .mk { position: absolute; left: -6px; right: -6px; height: 4px; margin-top: -2px; background: #fff; border-radius: 2px; box-shadow: 0 0 6px #fff; }
  #meter .lb { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 10px; letter-spacing: 1px; color: var(--muted); white-space: nowrap; }

  /* controles touch */
  #touch { position: fixed; inset: 0; pointer-events: none; }
  #stickZone { position: absolute; left: 0; bottom: 0; width: 46%; height: 72%; pointer-events: auto; touch-action: none; }
  #stickBase { position: absolute; left: calc(100px + var(--sl)); top: calc(100% - 110px - var(--sb)); width: 124px; height: 124px; margin: -62px 0 0 -62px; border-radius: 50%; background: rgba(255,255,255,.06); border: 2px solid rgba(255,255,255,.22); opacity: .6; }
  #stickBase.on { opacity: 1; }
  #stickKnob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: rgba(255,255,255,.32); border: 2px solid rgba(255,255,255,.5); }
  #btns { position: absolute; right: calc(14px + var(--sr)); bottom: calc(14px + var(--sb)); width: 214px; height: 196px; pointer-events: auto; touch-action: none; }
  .tb { position: absolute; border-radius: 50%; border: 2px solid rgba(255,255,255,.38); background: rgba(10, 25, 50, .55); color: #fff; font-weight: 800; font-size: 11px; letter-spacing: .5px; width: 68px; height: 68px; padding: 0; touch-action: none; display: grid; place-items: center; line-height: 1.05; }
  .tb.down { transform: scale(.93); background: rgba(255,255,255,.25); }
  .tb.armed { background: var(--acc); color: var(--ink); border-color: var(--acc); }
  #bTop { right: 0; bottom: 0; width: 90px; height: 90px; font-size: 14px; border-color: var(--acc); background: rgba(216,240,58,.2); }
  #bTop.armed { background: var(--acc); }
  #bSlice { right: 102px; bottom: 6px; }
  #bLob { right: 10px; bottom: 102px; }
  #bDrop { right: 94px; bottom: 90px; }
  @media (max-height: 430px) {
    #btns { transform: scale(.84); transform-origin: right bottom; }
    #stickBase { transform: scale(.88); }
    #meter { height: 130px; }
  }

  /* menus */
  .overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(5, 15, 30, .5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); padding: calc(10px + var(--st)) calc(10px + var(--sr)) calc(10px + var(--sb)) calc(10px + var(--sl)); box-sizing: border-box; }
  .panel { background: var(--panel); padding: 22px 26px; border-radius: 18px; text-align: center; width: min(600px, 100%); max-height: 100%; overflow-y: auto; box-sizing: border-box; box-shadow: 0 10px 40px rgba(0,0,0,.5); border: 1px solid rgba(216, 240, 58, .22); touch-action: pan-y; }
  .panel h1 { margin: 0 0 2px; font-size: clamp(28px, 6vw, 42px); letter-spacing: 1px; }
  .panel h1 span { color: var(--acc); }
  .panel .sub { color: var(--muted); margin-bottom: 12px; font-size: 14px; }
  .label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; margin: 12px 0 6px; letter-spacing: 1px; }
  .opts { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
  .opts button, .btn { border: 0; cursor: pointer; border-radius: 10px; padding: 8px 14px; background: #1f3a5f; color: #fff; font-weight: 600; font-size: 14px; transition: transform .1s, background .15s; }
  .opts button:hover, .btn:hover { background: #2a4d7a; }
  .opts button.sel { background: var(--acc); color: var(--ink); }
  .btn.play { margin-top: 18px; background: var(--acc); color: var(--ink); font-size: 20px; padding: 12px 46px; font-weight: 800; letter-spacing: 1px; }
  .btn.play:hover { background: #e6ff5a; }
  .btn.ghost { background: transparent; border: 1px solid rgba(255,255,255,.25); margin: 10px 4px 0; }
  details.controls { margin-top: 14px; text-align: left; font-size: 13.5px; color: #c9d6e3; line-height: 1.65; background: rgba(255,255,255,.04); border-radius: 10px; padding: 8px 14px; }
  details.controls summary { cursor: pointer; font-weight: 700; color: #fff; }
  .tip { font-size: 12.5px; color: var(--muted); margin-top: 10px; }
  table.stats { margin: 12px auto 0; border-collapse: collapse; font-size: 14px; min-width: 280px; }
  table.stats th, table.stats td { padding: 5px 12px; }
  table.stats th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
  table.stats td:first-child { text-align: left; color: #c9d6e3; }
  table.stats tr + tr td { border-top: 1px solid rgba(255,255,255,.07); }
  table.stats td.b { font-weight: 800; color: var(--acc); }
  #endPts { margin: 10px auto 0; display: inline-block; background: rgba(216,240,58,.15); color: var(--acc); border: 1px solid rgba(216,240,58,.4); border-radius: 20px; padding: 5px 14px; font-weight: 800; letter-spacing: .5px; }
  .opts button:disabled { opacity: .35; cursor: not-allowed; }
  .opts button.sel:disabled { opacity: 1; }
  #torneioFaixa { margin: -4px auto 10px; display: inline-block; background: rgba(216,240,58,.12); border: 1px solid rgba(216,240,58,.35); color: var(--acc); border-radius: 20px; padding: 4px 14px; font-size: 13px; font-weight: 700; }
  #convite { margin-top: 12px; font-size: 14px; color: #c9d6e3; }
  #convite a { color: var(--acc); font-weight: 700; }
