:root { --game-ratio: 1.7777777777777777; }
.smashi-controls { display: none; }
@media (pointer: coarse), (hover: none) and (any-pointer: coarse) {
  html body { height: calc(100dvh - 120px); }
  body canvas {
    width: min(100vw, calc((100dvh - 124px) * var(--game-ratio))) !important;
    height: auto !important;
  }
  #wrap #screen { width: min(100vw, calc((100dvh - 124px) * var(--game-ratio))); }
  #help, .keyboard-help { display: none; }
  .smashi-controls {
    box-sizing: border-box;
    position: fixed;
    z-index: 5;
    bottom: 0;
    width: 100%;
    height: 120px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    padding: 6px max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    gap: min(5vw, 24px);
    align-items: center;
    color: #fff4dd;
    background: #100a1d;
    border-top: 1px solid #524064;
    touch-action: none;
    user-select: none;
    font: 600 12px system-ui, sans-serif;
  }
  .smashi-pad, .smashi-actions { display: grid; gap: 4px; align-items: stretch; }
  .smashi-pad { grid-template: repeat(2, 44px) / repeat(3, 1fr); }
  .smashi-pad button:first-child { grid-column: 2; }
  .smashi-pad button:nth-child(2) { grid-column: 1; grid-row: 2; }
  .smashi-actions { grid-template: repeat(2, 44px) / repeat(3, 1fr); }
  .smashi-controls button {
    touch-action: none;
    border-radius: 8px;
    border: 1px solid #6d5683;
    background: #241935;
    color: inherit;
    font: inherit;
    min-width: 0;
    padding: 1px 2px;
  }
  .smashi-controls button:active { background: #774278; }
}

@media (pointer: coarse) { body { margin: 0; } body canvas { width: min(calc(100vw - 32px), calc((100dvh - 124px) * var(--game-ratio))) !important; } .smashi-controls { left: 0; } }
#touchUI { display: none !important; }
