/* SLEIGH DEFENSE - phones and tablets */

/* No page zoom, pull-to-refresh, text selection or long-press menus while playing. */
html, body {
  touch-action: none; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
/* The leaderboard list still scrolls with a finger, and the name box still takes text. */
.sd-board { touch-action: pan-y; }
input { -webkit-user-select: text; user-select: text; touch-action: manipulation; }
button { touch-action: manipulation; }

/* Size the stage to the space the browser bars leave (100vh is too tall on phones). */
@supports (height: 100dvh) {
  .sd-root, #stage { width: min(100vw, 150dvh); height: min(66.6667vw, 100dvh); }
}

/* Keyboard-only and touch-only text. */
.t-only { display: none !important; }
html.sd-touch-mode .t-only { display: revert !important; }
html.sd-touch-mode .k-only { display: none !important; }
html.sd-touch-mode .sd-cd-key { display: none; }
html.sd-touch-mode .sd-ui { font-size: clamp(10px, 1.75cqw, 18px); }

/* Pause button (touch only), next to the sound button. */
.sd-pausebtn {
  pointer-events: auto; width: 2.8em; height: 2.8em; padding: 0; cursor: pointer;
  display: none; align-items: center; justify-content: center; gap: .32em;
  background: #fff; border: 3px solid var(--ink); border-radius: 50%; box-shadow: 0 3px 0 var(--ink);
}
html.sd-touch-mode .sd-pausebtn.t-only { display: inline-flex !important; }
.sd-pausebtn i { display: block; width: .42em; height: 1.15em; background: var(--ink); border-radius: 2px; }
.sd-pausebtn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
html.sd-touch-mode .sd-mute, html.sd-touch-mode .sd-pausebtn { width: 3.3em; height: 3.3em; }

/* Short phone screens: smaller logo so the title panel fits. */
@media (max-height: 420px) {
  html.sd-touch-mode .sd-logo svg { max-height: 25cqh; }
  html.sd-touch-mode .sd-tag { margin-bottom: .45em; }
}

/* Touch help on the title screen. */
.sd-touch-help li { flex-wrap: nowrap !important; }
.sd-t-ico {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  margin: 0 .3em 0 0 !important; min-width: 4.6em; height: 1.9em; padding: 0 .5em;
  font: 900 .75em var(--font) !important; color: #fff; letter-spacing: .04em;
  border: 3px solid var(--ink); border-radius: 999px; box-shadow: 0 2px 0 var(--ink);
}
.sd-t-stick { min-width: 1.9em; width: 1.9em; padding: 0; border-radius: 50%; background: radial-gradient(circle, #fff 0 34%, #8fa6c9 36% 100%); }
.sd-t-whack { background: linear-gradient(var(--red), var(--red-d)); }
.sd-t-throw { background: linear-gradient(#3fd36a, var(--green-d)); }

/* Name entry with the phone keyboard open: keep the box at the top, drop the list. */
/* The panel always sits at the top on touch screens, so the name box and SAVE never jump
   when the keyboard opens or closes (a jump makes the SAVE tap miss). */
html.sd-touch-mode .sd-over { justify-content: flex-start; }
html.sd-touch-mode .sd-over-panel { margin-top: 1.6em; }
html.sd-touch-mode .sd-name-form label { margin-bottom: .35em; }
html.sd-touch-mode .sd-ui[data-typing] .sd-over .sd-board,
html.sd-touch-mode .sd-ui[data-typing] .sd-over .sd-again,
html.sd-touch-mode .sd-ui[data-typing] .sd-over .sd-status { display: none; }
html.sd-touch-mode .sd-name-row input { font-size: max(16px, 1.3em); } /* 16px stops iOS zooming in */

/* ---------- Touch controls layer (covers the whole screen, side margins too) ---------- */
.sd-touch {
  position: fixed; inset: 0; z-index: 50; pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.sd-touch[hidden] { display: none; }
.sd-stick-zone {
  position: absolute; left: env(safe-area-inset-left); bottom: 0; width: 50%; top: 22%;
  pointer-events: auto; touch-action: none;
}
.sd-stick {
  --r: 54px;
  position: absolute; left: 4vmin; bottom: calc(4vmin + env(safe-area-inset-bottom));
  width: calc(var(--r) * 2); height: calc(var(--r) * 2);
  border-radius: 50%; background: rgba(255,255,255,.14); border: 3px solid rgba(255,255,255,.45);
  box-shadow: 0 0 0 3px rgba(29,20,51,.25); opacity: .55; transition: opacity .15s;
}
.sd-stick.sd-on { bottom: auto; margin: calc(var(--r) * -1) 0 0 calc(var(--r) * -1); opacity: 1; background: rgba(255,255,255,.22); }
.sd-stick-knob {
  position: absolute; left: 50%; top: 50%; width: 52%; height: 52%; margin: -26% 0 0 -26%;
  border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff, #cfdcf0);
  border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
}

.sd-tbtn {
  position: absolute; pointer-events: auto; touch-action: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1em;
  border-radius: 50%; border: 4px solid var(--ink); box-shadow: 0 5px 0 var(--ink);
  color: #fff; font: 900 clamp(10px, 2.6vmin, 15px) var(--font, sans-serif); letter-spacing: .05em;
  text-shadow: 0 2px 0 var(--ink); opacity: .9;
}
.sd-tbtn b { font-weight: 900; }
.sd-tbtn.sd-down { transform: translateY(4px) scale(.96); box-shadow: 0 1px 0 var(--ink); opacity: 1; }
.sd-tbtn-whack {
  right: calc(4vmin + env(safe-area-inset-right)); bottom: calc(5vmin + env(safe-area-inset-bottom));
  width: min(27vmin, 150px); height: min(27vmin, 150px);
  background: radial-gradient(circle at 40% 30%, #ff6b75, var(--red) 55%, var(--red-d));
}
.sd-tbtn-throw {
  right: calc(4vmin + min(27vmin, 150px) + 3vmin + env(safe-area-inset-right));
  bottom: calc(5vmin + min(12vmin, 66px) + env(safe-area-inset-bottom));
  width: min(19vmin, 108px); height: min(19vmin, 108px);
  background: radial-gradient(circle at 40% 30%, #6be58c, var(--green) 55%, var(--green-d));
}
.sd-tbtn-throw:not(.sd-ready) { filter: grayscale(.75) brightness(.85); }
.sd-tbtn-ring { position: absolute; inset: -9px; width: calc(100% + 18px); height: calc(100% + 18px); transform: rotate(-90deg); pointer-events: none; }
.sd-tbtn-ring circle { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 0; }
.sd-tbtn-throw.sd-ready .sd-tbtn-ring circle { stroke: var(--gold); }
.sd-tbtn-cane {
  width: 38%; height: 38%;
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M14 36V14a8 8 0 0 1 16 0v3' fill='none' stroke='%231d1433' stroke-width='9' stroke-linecap='round'/%3E%3Cpath d='M14 36V14a8 8 0 0 1 16 0v3' fill='none' stroke='%23fff' stroke-width='5' stroke-linecap='round'/%3E%3Cpath d='M14 36V14a8 8 0 0 1 16 0v3' fill='none' stroke='%23e63946' stroke-width='5' stroke-dasharray='4 4' stroke-linecap='butt'/%3E%3C/svg%3E");
}
.sd-tbtn-gift {
  width: 34%; height: 34%; border: 3px solid var(--ink); border-radius: 4px;
  background:
    linear-gradient(90deg, transparent 40%, #ffc93c 40% 60%, transparent 60%),
    linear-gradient(transparent 40%, #ffc93c 40% 60%, transparent 60%),
    #e63946;
}

/* ---------- "Turn your phone" screen (touch devices held upright) ---------- */
.sd-rotate { display: none; }
@media (orientation: portrait) {
  html.sd-touch-mode .sd-rotate {
    position: fixed; inset: 0; z-index: 900; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 1.4em; padding: 2em;
    background: radial-gradient(ellipse at 50% 30%, #23407a 0%, #13254a 70%);
    color: #fff; text-align: center; font: 900 clamp(18px, 5.5vw, 28px) 'Arial Black', 'Segoe UI Black', system-ui, sans-serif;
    letter-spacing: .04em; text-shadow: 0 3px 0 #1d1433;
  }
  html.sd-touch-mode .sd-rotate p { margin: 0; max-width: 14em; }
  html.sd-touch-mode .sd-touch { display: none; }
}
.sd-rotate-phone {
  width: 70px; height: 120px; border: 6px solid #fff; border-radius: 14px; position: relative;
  box-shadow: 0 4px 0 #1d1433; animation: sdTurn 2.2s ease-in-out infinite;
}
.sd-rotate-phone::after { content: ''; position: absolute; left: 50%; bottom: 6px; width: 16px; height: 4px; margin-left: -8px; border-radius: 2px; background: #fff; }
@keyframes sdTurn { 0%, 25% { transform: rotate(0); } 55%, 85% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }
@media (prefers-reduced-motion: reduce) { .sd-rotate-phone { animation: none; transform: rotate(-90deg); } }
