:root { --accent: #3cdcff; }
  .portal-back {
    position: fixed;
    top: max(10px, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    backdrop-filter: blur(8px);
  }html, body {
    margin: 0; padding: 0; overflow: hidden; height: 100%;
    background: #05050a;
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    touch-action: none;
    -webkit-user-select: none; user-select: none;
  }
  #wrap { position: relative; width: 100vw; height: 100vh; display: flex; align-items: center; justify-content: center; }
  canvas { display: block; background: #05050a; touch-action: none; }

  .overlay {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: radial-gradient(circle at 50% 30%, rgba(20,20,35,0.94), rgba(3,3,8,0.98));
    color: #fff; text-align: center; gap: 10px; padding: 20px; box-sizing: border-box;
    animation: fadeIn 0.25s ease;
    overflow-y: auto;
  }
  @keyframes fadeIn { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: scale(1); } }
  .hidden { display: none !important; }

  h1.title {
    font-size: clamp(26px, 7vw, 44px);
    margin: 0 0 2px 0;
    letter-spacing: 2px;
    color: var(--accent);
    text-shadow: 0 0 18px rgba(60,220,255,0.8), 0 0 40px rgba(60,220,255,0.4);
    font-weight: 800;
  }
  .subtitle { color: #8899aa; font-size: clamp(11px,3vw,14px); margin-bottom: 4px; letter-spacing: 1px; }

  .btn-group { display: flex; flex-direction: column; gap: 8px; width: min(320px, 82vw); }
  .btn {
    padding: 12px 16px; border-radius: 14px; border: 2px solid rgba(255,255,255,0.15);
    background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
    color: #eee; font-size: 15px; font-weight: 700; cursor: pointer; letter-spacing: 0.5px;
    transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  }
  .btn:active { transform: scale(0.96); }
  .btn.selected {
    border-color: #39ff14; color: #39ff14;
    box-shadow: 0 0 18px rgba(57,255,20,0.35);
  }
  .btn.start {
    border-color: var(--accent); color: var(--accent); margin-top: 6px;
    box-shadow: 0 0 20px rgba(60,220,255,0.3);
  }
  .btn.danger { border-color: #ff3c3c; color: #ff3c3c; }

  .row { display: flex; gap: 8px; width: min(320px, 82vw); }
  .row .btn { flex: 1; padding: 9px 4px; font-size: 12.5px; }

  .icon-btn {
    position: absolute; top: max(10px, env(safe-area-inset-top)); z-index: 6;
    pointer-events: all; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.2);
    color: #fff; border-radius: 10px; padding: 7px 11px; font-size: 15px;
  }
  #pauseBtn { right: 12px; }
  #settingsBtn { left: 12px; }

  #hud {
    position: absolute; top: max(10px, env(safe-area-inset-top)); left: 0; right: 0;
    display: flex; justify-content: space-between; padding: 0 60px; pointer-events: none;
    box-sizing: border-box;
  }
  #hud .side { display:flex; flex-direction:column; align-items:center; gap:1px; }
  #hud .score { font-size: 22px; font-weight: 800; text-shadow: 0 0 10px currentColor; }
  #hud .label { font-size: 9px; letter-spacing: 2px; opacity: 0.6; }
  #timerHud {
    position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
    font-size: 14px; font-weight: 800; color: #ffe63c; text-shadow: 0 0 8px rgba(255,230,60,0.7);
  }

  .stat-box {
    width: min(320px, 82vw); background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px; padding: 10px 14px; font-size: 13px; color: #cdd; text-align: right;
    display: flex; flex-direction: column; gap: 4px;
  }
  .stat-box .stat-row { display: flex; justify-content: space-between; }
  .toggle-row { display: flex; justify-content: space-between; align-items: center; width: min(320px,82vw);
    background: rgba(255,255,255,0.04); border-radius: 10px; padding: 8px 14px; font-size: 14px; }
  .switch { width: 44px; height: 24px; border-radius: 20px; background: rgba(255,255,255,0.15); position: relative; cursor: pointer; transition: background 0.15s; }
  .switch.on { background: #39ff14; }
  .switch .knob { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left 0.15s; }
  .switch.on .knob { left: 22px; }

  .footer-hint { color: #556; font-size: 10.5px; margin-top: 2px; }
  .countdown-num {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
    font-size: 90px; font-weight: 900; color: #fff; text-shadow: 0 0 30px rgba(255,255,255,0.7);
    pointer-events: none; z-index: 4;
  }
