/* ═══════════════════════════════════════════════════════════════════════════
   BLOCKICKS PENALTY — Voxel penalty shootout, in-panel mobile-first styles.
   All rules are scoped under .pen-shell to avoid bleeding into other games.
   ═══════════════════════════════════════════════════════════════════════════ */

.pen-shell {
  display: flex;
  flex-direction: column;
  min-height: 600px;
  height: clamp(600px, 80vh, 900px);
  background:
    radial-gradient(circle at 18% 12%, rgba(95,168,255,0.15), transparent 35%),
    linear-gradient(135deg, #0e1722 0%, #0a1018 100%);
  font-family: "Inter", "Space Grotesk", system-ui, sans-serif;
  color: #e9f1ff;
  overflow: hidden;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
.pen-shell, .pen-shell * { box-sizing: border-box; }
.pen-shell .hidden { display: none !important; }

/* ── Header bar ── */
.pen-shell .pen-header {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 20px;
  background: linear-gradient(180deg, rgba(8,16,28,0.95) 0%, rgba(8,16,28,0) 100%);
  -webkit-backdrop-filter: none; backdrop-filter: none;
  border-bottom: none;
  flex-shrink: 0;
  z-index: 15;
}
.pen-shell .pen-header-left {
  display: flex; align-items: center; gap: 10px; min-width: 0;
}
.pen-shell .pen-game-title {
  font-weight: 700; font-size: 14px; letter-spacing: 0.5px;
  white-space: nowrap;
}
.pen-shell .pen-phase-badge {
  font-size: 10px; letter-spacing: 1px; padding: 4px 8px;
  background: rgba(255,210,63,0.15); color: #ffd23f;
  border: 1px solid rgba(255,210,63,0.3);
  border-radius: 8px;
}
.pen-shell .pen-header-right {
  display: flex; gap: 6px;
}
.pen-shell .pen-icon-btn {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  border-radius: 8px;
  font-weight: 800; font-size: 13px; letter-spacing: 1px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.pen-shell .pen-icon-btn:active { background: rgba(255,255,255,0.18); }

/* ── Stage (3D + overlays) ── */
.pen-shell .pen-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #87b8e8;
  z-index: 1;
}
.pen-shell .pen-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
}

/* ── Generic overlay (menu, names, pause, end) ── */
.pen-shell .pen-overlay {
  position: absolute; inset: 0;
  background: rgba(8,16,28,0.85);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
  z-index: 20;
  padding: 18px;
  overflow-y: auto;
}
.pen-shell .pen-menu-card {
  width: 100%;
  max-width: 360px;
  background: linear-gradient(180deg, #1f2c40 0%, #131c2b 100%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 22px 18px;
  display: flex; flex-direction: column; gap: 10px; align-items: center;
  text-align: center;
  box-shadow: 0 16px 50px rgba(0,0,0,0.4);
}
.pen-shell .pen-cube-stack {
  position: relative; width: 110px; height: 90px; margin-bottom: 4px;
}
.pen-shell .pen-tcube {
  position: absolute;
  width: 30px; height: 30px;
  box-shadow: inset -3px -3px 0 rgba(0,0,0,0.32), inset 3px 3px 0 rgba(255,255,255,0.2);
}
.pen-shell .pen-tc-1 { left: 12px; bottom: 0; background: #6fbf73; animation: pen-bob 2.2s ease-in-out infinite; }
.pen-shell .pen-tc-2 { left: 40px; bottom: 0; background: #6fbf73; animation: pen-bob 2.2s ease-in-out infinite 0.2s; }
.pen-shell .pen-tc-3 { left: 68px; bottom: 0; background: #6fbf73; animation: pen-bob 2.2s ease-in-out infinite 0.4s; }
.pen-shell .pen-tc-ball {
  left: 38px; bottom: 44px; width: 28px; height: 28px;
  background: radial-gradient(circle at 30% 30%, #fff 0 40%, #d1d8e0 41% 100%);
  border-radius: 50%;
  box-shadow: 0 8px 16px rgba(0,0,0,0.4);
  animation: pen-ball-bounce 1.4s ease-in-out infinite;
}
@keyframes pen-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@keyframes pen-ball-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px) rotate(180deg); }
}
.pen-shell .pen-menu-title {
  font-size: 30px; letter-spacing: 4px; font-weight: 800; margin: 4px 0 0;
  background: linear-gradient(180deg, #fff 0%, #ffd23f 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.pen-shell .pen-menu-title.pen-small { font-size: 22px; letter-spacing: 2px; }
.pen-shell .pen-menu-sub { margin: 0 0 12px; font-size: 11px; letter-spacing: 2px; opacity: 0.7; }

/* ── Lobby ── */
.pen-shell .pen-lobby-meta {
  font-size: 12px; opacity: 0.85;
  margin: 4px 0 8px;
  line-height: 1.4;
}
.pen-shell .pen-difficulty-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  margin: 4px 0 8px;
}
.pen-shell .pen-diff-label {
  font-size: 11px; letter-spacing: 1px; opacity: 0.7;
  font-weight: 700;
}
.pen-shell .pen-diff-buttons {
  display: flex; gap: 6px; flex: 1;
}
.pen-shell .pen-diff-btn {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: #cdd6e0;
  padding: 8px 6px; border-radius: 8px;
  font-size: 12px; font-weight: 700; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.pen-shell .pen-diff-btn:active { transform: scale(0.96); }
.pen-shell .pen-diff-btn.pen-diff-active {
  background: rgba(255,210,63,0.18);
  border-color: rgba(255,210,63,0.45);
  color: #ffd23f;
}
.pen-shell .pen-big-btn:disabled {
  opacity: 0.5; cursor: not-allowed;
  background: linear-gradient(180deg, #4a5a72 0%, #2c3650 100%);
  box-shadow: none;
}

/* ── Mode grid (2×2) ── */
.pen-shell .pen-mode-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%;
}
.pen-shell .pen-mode-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 12px 10px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 4px; min-height: 86px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease;
  text-align: left;
  color: #fff;
}
.pen-shell .pen-mode-card:active {
  transform: scale(0.96); background: rgba(255,255,255,0.12);
}
.pen-shell .pen-mc-flag { font-size: 20px; }
.pen-shell .pen-mc-title { font-weight: 700; font-size: 13px; }
.pen-shell .pen-mc-desc { font-size: 10px; opacity: 0.6; }
.pen-shell .pen-menu-foot { margin-top: 8px; font-size: 11px; opacity: 0.5; letter-spacing: 1px; }

/* ── Name inputs ── */
.pen-shell .pen-input-row {
  display: flex; flex-direction: column; gap: 6px;
  width: 100%;
  font-size: 12px; opacity: 0.85; text-align: left;
}
.pen-shell .pen-input-row input {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  padding: 10px 12px; border-radius: 8px;
  font-size: 15px; outline: none;
  font-family: inherit;
}
.pen-shell .pen-input-row input:focus { border-color: #5fa8ff; }

/* ── Buttons ── */
.pen-shell .pen-big-btn {
  background: linear-gradient(180deg, #5fa8ff 0%, #2a6fc8 100%);
  color: #fff; font-weight: 700; letter-spacing: 1.5px;
  padding: 12px 22px; border: none; border-radius: 10px;
  font-size: 14px; cursor: pointer; width: 100%;
  box-shadow: 0 4px 14px rgba(42,111,200,0.4), inset 0 -2px 0 rgba(0,0,0,0.2);
  transition: transform 0.1s ease;
}
.pen-shell .pen-big-btn:active { transform: translateY(1px) scale(0.98); }
.pen-shell .pen-shoot-btn {
  background: linear-gradient(180deg, #ffd23f 0%, #d68e00 100%);
  color: #1a1a1a;
  box-shadow: 0 4px 14px rgba(214,142,0,0.4), inset 0 -2px 0 rgba(0,0,0,0.2);
}
.pen-shell .pen-keep-btn {
  background: linear-gradient(180deg, #ff7a7a 0%, #c43030 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(196,48,48,0.4), inset 0 -2px 0 rgba(0,0,0,0.2);
}
.pen-shell .pen-ghost-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: #cdd6e0; cursor: pointer;
  padding: 9px 16px; border-radius: 8px;
  font-size: 13px; width: 100%;
}
.pen-shell .pen-ghost-btn:active { background: rgba(255,255,255,0.05); }

/* ── HUD top scoreboard ── */
.pen-shell .pen-hud-top {
  position: absolute; top: 56px; left: 8px; right: 8px;
  z-index: 10; pointer-events: none;
}
.pen-shell .pen-scoreboard {
  display: grid; grid-template-columns: 1fr auto 1fr;
  background: rgba(8,16,28,0.7);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 7px 10px;
  pointer-events: auto;
}
.pen-shell .pen-score-side { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pen-shell .pen-score-p1 { align-items: flex-start; }
.pen-shell .pen-score-p2 { align-items: flex-end; }
.pen-shell .pen-score-name {
  font-size: 11px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 90px;
}
.pen-shell .pen-score-p1 .pen-score-name { color: #6fb8ff; }
.pen-shell .pen-score-p2 .pen-score-name { color: #ff7a7a; }
.pen-shell .pen-score-pips { display: flex; gap: 3px; }
.pen-shell .pen-pip {
  width: 9px; height: 9px; border-radius: 50%;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.25);
  transition: background 0.3s ease, transform 0.2s ease;
}
.pen-shell .pen-pip.goal { background: #4ade80; box-shadow: 0 0 6px #4ade80; }
.pen-shell .pen-pip.miss { background: #ef4444; }
.pen-shell .pen-pip.current { transform: scale(1.3); border-color: #ffd23f; }
.pen-shell .pen-score-mid {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 0 6px;
}
.pen-shell .pen-score-mid #pen-round { font-size: 10px; opacity: 0.7; letter-spacing: 1px; }
.pen-shell .pen-score-mid #pen-phase-text { font-size: 11px; font-weight: 700; color: #ffd23f; letter-spacing: 1px; }

/* ── Turn banner ── */
.pen-shell .pen-turn-banner {
  position: absolute; top: 0; left: 50%;
  transform: translate(-50%, -100%);
  margin-top: 60px;
  background: rgba(255,210,63,0.95); color: #1a1a1a;
  padding: 5px 16px;
  border-radius: 0 0 10px 10px;
  font-weight: 800; font-size: 11px; letter-spacing: 2px;
  z-index: 9;
  transition: transform 0.4s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  white-space: nowrap;
}
.pen-shell .pen-turn-banner.show { transform: translate(-50%, 0); }

/* ── Result flash ── */
.pen-shell .pen-result-flash {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 18; pointer-events: none;
}
.pen-shell .pen-result-flash > span {
  font-size: 64px; font-weight: 900; letter-spacing: 5px;
  color: #fff;
  text-shadow:
    0 0 18px currentColor,
    0 0 36px currentColor,
    0 6px 0 rgba(0,0,0,0.4);
  animation: pen-flash-pop 1.4s cubic-bezier(.2,.8,.2,1) forwards;
}
.pen-shell .pen-result-flash.goal > span { color: #4ade80; }
.pen-shell .pen-result-flash.miss > span { color: #ef4444; }
.pen-shell .pen-result-flash.save > span { color: #ffd23f; }
@keyframes pen-flash-pop {
  0%   { transform: scale(0.4); opacity: 0; }
  20%  { transform: scale(1.2); opacity: 1; }
  60%  { transform: scale(1);   opacity: 1; }
  100% { transform: scale(1.05); opacity: 0; }
}

/* ── Bottom controls ── */
.pen-shell .pen-controls {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(180deg, rgba(10,16,24,0) 0%, rgba(10,16,24,0.85) 40%, rgba(10,16,24,1) 100%);
  border-top: none;
  padding: 40px 14px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 10;
  pointer-events: none;
}
.pen-shell .pen-controls > * {
  pointer-events: auto;
}
.pen-shell .pen-ctrl-hint {
  font-size: 11px; opacity: 0.75; letter-spacing: 1px; text-align: center;
}
.pen-shell .pen-aim-pad {
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.pen-shell .pen-goal-frame {
  position: relative; width: 100%; aspect-ratio: 3 / 1.6;
  background: rgba(8,16,28,0.55);
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 6px;
  touch-action: none;
}
.pen-shell .pen-aim-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.07) 1px, transparent 1px);
  background-size: 33.33% 33.33%;
  pointer-events: none;
}
.pen-shell .pen-aim-target {
  position: absolute;
  width: 32px; height: 32px;
  margin-left: -16px; margin-top: -16px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,210,63,0.9) 0 40%, rgba(255,210,63,0.4) 41% 70%, transparent 71%);
  border: 2px solid #ffd23f;
  box-shadow: 0 0 12px #ffd23f;
  pointer-events: none;
  transition: left 0.08s ease, top 0.08s ease;
}
.pen-shell .pen-keep-target {
  background: radial-gradient(circle, rgba(255,122,122,0.9) 0 40%, rgba(255,122,122,0.4) 41% 70%, transparent 71%);
  border-color: #ff7a7a;
  box-shadow: 0 0 12px #ff7a7a;
}

.pen-shell .pen-slider-row {
  width: 100%;
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.pen-shell .pen-slider {
  display: flex; align-items: center; gap: 6px;
  font-size: 9px; letter-spacing: 1px; opacity: 0.85;
}
.pen-shell .pen-slider span { font-weight: 700; }
.pen-shell .pen-slider input[type="range"] {
  flex: 1;
  -webkit-appearance: none; appearance: none;
  height: 4px; background: rgba(255,255,255,0.2); border-radius: 2px;
  outline: none;
}
.pen-shell .pen-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: #ffd23f; border: 2px solid #fff; cursor: pointer;
}
.pen-shell .pen-slider input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: #ffd23f; border: 2px solid #fff; cursor: pointer;
}

.pen-shell .pen-keep-timer {
  width: 100%; max-width: 360px;
  height: 4px; background: rgba(255,255,255,0.15); border-radius: 2px; overflow: hidden;
}
.pen-shell .pen-keep-timer > span {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, #4ade80, #ffd23f, #ef4444);
  transform-origin: left center;
  transition: transform 0.05s linear;
}

#pen-watch-controls .pen-ctrl-hint {
  font-size: 13px; padding: 10px 18px; opacity: 1;
  background: rgba(8,16,28,0.5);
  border-radius: 10px;
}

/* ── End / pause card flourishes ── */
.pen-shell .pen-trophy { font-size: 48px; line-height: 1; }
.pen-shell .pen-end-score {
  font-size: 36px; font-weight: 800; letter-spacing: 4px; color: #ffd23f;
  margin: 4px 0;
}
.pen-shell .pen-end-summary { font-size: 11px; opacity: 0.7; line-height: 1.5; }

/* ── Compact-height tweaks for very short panels ── */
@media (max-height: 560px) {
  .pen-shell .pen-aim-pad { gap: 6px; }
  .pen-shell .pen-controls { padding: 30px 10px 10px; }
  .pen-shell .pen-big-btn { padding: 10px 18px; font-size: 13px; }
  .pen-shell .pen-result-flash > span { font-size: 48px; letter-spacing: 3px; }
}

/* ── Very narrow phones (< 360px): squeeze the menu cards ── */
@media (max-width: 360px) {
  .pen-shell .pen-mc-title { font-size: 12px; }
  .pen-shell .pen-mc-desc  { font-size: 9px; }
  .pen-shell .pen-mode-card { min-height: 78px; padding: 10px 8px; }
}
