/* Dashboard typing screen rewrite (responsive + keyboard-safe) */

:root {
  --ttg-vh: 100dvh;
  --ttg-keyboard-inset: 0px;
}

#typingScreen {
  background: transparent;
}

/* Atmospheric Starfield Layer (Global) */
.sky-atmosphere-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  opacity: 0;
  transition: opacity 1.2s ease;
}

.dark-theme .sky-atmosphere-layer {
  opacity: 1;
}

.star-container {
  position: absolute;
  inset: 0;
}

body {
  position: relative;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% -8%, color-mix(in srgb, var(--accent-color) 18%, transparent) 0%, transparent 44%),
    radial-gradient(circle at 88% 110%, color-mix(in srgb, var(--accent-secondary, #3b82f6) 14%, transparent) 0%, transparent 42%),
    var(--bg-primary);
  /* Premium Day-to-Night Transition */
  transition: background 0.8s cubic-bezier(0.4, 0, 0.2, 1),
    color 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

body.typing-open {
  overflow: hidden;
}

#typingScreen.active {
  display: block !important;
}

#typingScreen .typing-shell {
  --ttg-sidebar-width: 276px;
  position: relative;
  height: var(--ttg-vh);
  min-height: var(--ttg-vh);
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--ttg-sidebar-width);
  background: transparent;
  transition: grid-template-columns 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 769px) {
  #typingScreen .typing-shell {
    --ttg-sidebar-width: 320px;
    /* Wider sidebar for tablets/desktops */
    gap: 20px;
  }
}

#typingScreen .typing-shell.sidebar-collapsed {
  --ttg-sidebar-width: 56px;
}

#typingScreen .typing-workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(10px, 1.6vw, 16px);
  padding: clamp(10px, 1.8vw, 20px);
  transform: translateY(var(--ttg-viewport-top, 0px));
}

#typingScreen .typing-topbar {
  display: flex;
  align-items: stretch;
  gap: 10px;
  min-height: 64px;
}

#typingScreen .typing-icon-btn {
  width: 44px;
  min-width: 44px;
  height: 44px;
  border: 1px solid color-mix(in srgb, var(--border-color) 80%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg-secondary) 90%, transparent);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

#typingScreen .typing-icon-btn:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent-color) 44%, var(--border-color));
  background: color-mix(in srgb, var(--bg-secondary) 68%, var(--accent-color) 7%);
}

#typingScreen .typing-icon-btn svg {
  width: 22px;
  height: 22px;
}

#typingScreen .typing-topbar .typing-panel-toggle {
  display: none;
}

#typingScreen .typing-panel-toggle-text {
  display: none;
}

#typingScreen .typing-live-strip {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

#typingScreen .typing-live-card {
  border: 1px solid color-mix(in srgb, var(--border-color) 82%, transparent);
  border-radius: 14px;
  background:
    linear-gradient(160deg,
      color-mix(in srgb, var(--bg-secondary) 92%, transparent) 0%,
      color-mix(in srgb, var(--bg-tertiary) 88%, transparent) 100%);
  padding: 10px 12px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--shadow-dark) 35%, transparent);
}

#typingScreen .typing-time-card {
  margin-top: 0 !important;
  text-align: left;
}

#typingScreen .typing-time-card .typing-live-label,
#typingScreen .typing-time-card .typing-live-value {
  text-align: left;
  justify-content: flex-start;
}

#typingScreen .typing-live-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#typingScreen .typing-live-value {
  font-size: clamp(18px, 1.8vw, 24px);
  line-height: 1.1;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#typingScreen #liveWPM {
  font-size: clamp(15px, 1.55vw, 19px);
}

#typingScreen #timeValue {
  font-family: "Courier New", monospace;
  letter-spacing: 0.05em;
}

#typingScreen #streakIcon {
  width: 14px;
  height: 14px;
  color: var(--accent-color);
  transition: transform 0.25s ease;
}

#typingScreen #streakIcon.no-rotation {
  transform: none;
  opacity: 0.7;
}

#typingScreen .typing-paragraph-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 3px solid color-mix(in srgb, var(--border-color) 92%, transparent);
  border-radius: clamp(14px, 1.6vw, 20px);
  background:
    linear-gradient(145deg,
      color-mix(in srgb, var(--bg-secondary) 96%, transparent) 0%,
      color-mix(in srgb, var(--bg-primary) 96%, transparent) 100%);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--bg-primary) 55%, transparent),
    0 10px 24px color-mix(in srgb, var(--shadow-dark) 30%, transparent);
  background-clip: padding-box;
}

#typingScreen .typing-paragraph-content::-webkit-scrollbar {
  width: 14px;
}

#typingScreen .typing-paragraph-content::-webkit-scrollbar-track {
  background: transparent;
  margin: 6px 0;
}

#typingScreen .typing-paragraph-content::-webkit-scrollbar-thumb {
  background-color: color-mix(in srgb, var(--accent-color) 28%, #9ca3af);
  border-radius: 999px;
  border: 4px solid transparent;
  background-clip: padding-box;
}

#typingScreen .typing-paragraph-content::-webkit-scrollbar-button {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

#typingScreen .typing-paragraph-content::-webkit-scrollbar-button:single-button {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

#typingScreen .typing-paragraph-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent-color) 35%, transparent) transparent;

  padding: clamp(16px, 2.7vw, 30px) clamp(20px, 3vw, 42px);
  font-size: clamp(22px, 1.95vw, 34px);
  line-height: 1.78;
  letter-spacing: 0.01em;
  color: color-mix(in srgb, var(--text-primary) 84%, var(--text-secondary));
  border: 2.5px solid color-mix(in srgb, var(--border-color) 84%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg-primary) 92%, transparent);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--bg-primary) 64%, transparent);
}

#typingScreen .line {
  width: min(100%, 74ch);
  margin: 0 auto 0.3em;
  word-break: break-word;
}

#typingScreen .word {
  display: inline;
  padding: 1px 0;
  border-radius: 8px;
  transition: color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

#typingScreen .word.current {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--accent-color) 16%, var(--bg-primary));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent-color) 30%, transparent);
  border-bottom: 2px solid var(--accent-color);
  padding: 1px 4px;
}

#typingScreen .word.correct {
  color: var(--success-color);
}

#typingScreen .word.incorrect {
  color: var(--error-color);
  text-decoration: line-through;
}

#typingScreen .typing-input-wrap {
  position: relative;
  border: 1px solid color-mix(in srgb, var(--border-color) 85%, transparent);
  border-radius: clamp(12px, 1.4vw, 16px);
  background: color-mix(in srgb, var(--bg-secondary) 96%, transparent);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--shadow-dark) 30%, transparent);
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
}

#typingScreen .typing-input-label {
  display: block;
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

#typingScreen .typing-input {
  width: 100%;
  min-height: 98px;
  max-height: min(26vh, 240px);
  border: 1px solid color-mix(in srgb, var(--border-color) 88%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg-primary) 90%, transparent);
  color: var(--text-primary);
  font-size: clamp(16px, 1.5vw, 20px);
  line-height: 1.7;
  padding: 12px 14px;
  resize: none;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

#typingScreen .typing-input:focus {
  border-color: color-mix(in srgb, var(--accent-color) 70%, var(--border-color));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-color) 25%, transparent);
}

#typingScreen .typing-input.wrong-word {
  border-color: var(--error-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--error-color) 23%, transparent);
}

#typingScreen .typing-input.key-pressed {
  border-color: color-mix(in srgb, var(--accent-color) 65%, var(--border-color));
}

#typingScreen .typing-sidebar {
  min-height: 0;
  min-width: 0;
  border-left: 1px solid color-mix(in srgb, var(--border-color) 85%, transparent);
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--bg-secondary) 96%, transparent) 0%,
      color-mix(in srgb, var(--bg-primary) 98%, transparent) 100%);
  padding: clamp(10px, 1.4vw, 12px);
  overflow: auto;
  overflow-x: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent-color) 22%, #b9c4d8) transparent;
}

#typingScreen .typing-sidebar::-webkit-scrollbar {
  width: 7px;
}

#typingScreen .typing-sidebar::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--accent-color) 25%, #a8b4c9);
  border-radius: 999px;
}

#typingScreen .typing-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

#typingScreen .typing-sidebar::-webkit-scrollbar-button {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

#typingScreen .typing-sidebar-collapse {
  position: sticky;
  top: 0;
  width: 100%;
  min-height: 38px;
  padding: 0 13px;
  gap: 9px;
  border-radius: 13px;
  border: 1px solid color-mix(in srgb, var(--accent-color) 36%, var(--border-color));
  background:
    linear-gradient(145deg,
      color-mix(in srgb, var(--bg-secondary) 90%, var(--accent-color) 7%) 0%,
      color-mix(in srgb, var(--bg-primary) 92%, transparent) 100%);
  color: color-mix(in srgb, var(--text-primary) 80%, var(--accent-color) 20%);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, #ffffff 45%, transparent),
    0 8px 16px color-mix(in srgb, var(--shadow-dark) 22%, transparent);
  backdrop-filter: blur(7px);
  cursor: pointer;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  flex-shrink: 0;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

#typingScreen .typing-sidebar-collapse:hover {
  border-color: color-mix(in srgb, var(--accent-color) 58%, var(--border-color));
  color: var(--accent-color);
  background: color-mix(in srgb, var(--bg-secondary) 82%, var(--accent-color) 10%);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, #ffffff 54%, transparent),
    0 10px 18px color-mix(in srgb, var(--shadow-dark) 28%, transparent);
  transform: translateY(-1px);
}

#typingScreen .typing-sidebar-collapse:active {
  transform: translateY(0);
}

#typingScreen .typing-sidebar-collapse svg {
  width: 15px;
  height: 15px;
  padding: 2px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-color) 16%, var(--bg-secondary));
  color: var(--accent-color);
  transition: transform 0.22s ease;
}

#typingScreen .typing-sidebar-collapse-text {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  white-space: nowrap;
}

#typingScreen .typing-sidebar-content {
  display: grid;
  gap: 12px;
  min-height: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#typingScreen .typing-shell.sidebar-collapsed .typing-sidebar-content {
  opacity: 0;
  pointer-events: none;
  transform: translateX(8px);
  height: 0;
  overflow: hidden;
  gap: 0;
}

#typingScreen .typing-shell.sidebar-collapsed .typing-sidebar-collapse {
  position: relative;
  top: auto;
  width: 100%;
  min-height: 100%;
  flex: 1;
  padding: 0;
  border-radius: 0;
  border: 0;
  border-left: 1px solid color-mix(in srgb, var(--border-color) 90%, transparent);
  box-shadow: none;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 10px;
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--bg-secondary) 94%, transparent) 0%,
      color-mix(in srgb, var(--bg-primary) 96%, transparent) 100%);
}

#typingScreen .typing-shell.sidebar-collapsed .typing-sidebar-collapse-text {
  display: inline;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  letter-spacing: 0.16em;
  font-size: 9px;
}

#typingScreen .typing-shell.sidebar-collapsed .typing-sidebar-collapse svg {
  transform: rotate(180deg);
}

#typingScreen .typing-shell.sidebar-collapsed .typing-sidebar {
  padding: 0;
  gap: 0;
  overflow: hidden;
}

#typingScreen .typing-progress-card,
#typingScreen .typing-setting-card,
#typingScreen .typing-actions {
  border: 1px solid color-mix(in srgb, var(--border-color) 82%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg-secondary) 94%, transparent);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--shadow-dark) 30%, transparent);
}

#typingScreen .typing-progress-card {
  padding: 12px 10px;
  display: grid;
  justify-items: center;
}

/* Rotation for #typingScreen .typing-progress-circle moved to SVG attribute for iOS stability */

#typingScreen .typing-progress-bg {
  fill: none;
  stroke: color-mix(in srgb, var(--border-color) 75%, transparent);
  stroke-width: 8;
}

#typingScreen .typing-progress-bar {
  fill: none;
  stroke: #22c55e;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 408;
  stroke-dashoffset: 408;
  transition: stroke 0.4s ease, stroke-dashoffset 0.35s ease;
}

#typingScreen .typing-progress-bar.progress-danger {
  animation: ttgProgressPulse 1s ease-in-out infinite;
}

#typingScreen .typing-progress-text {
  fill: var(--text-primary);
  font-size: 22px;
  font-weight: 800;
  text-anchor: middle;
}

#typingScreen .typing-progress-label {
  margin: 4px 0 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: 700;
}

#typingScreen .typing-setting-card {
  min-height: 54px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

/* Premium Sky Toggle */
#typingScreen .sky-toggle {
  position: relative;
  width: 54px;
  height: 28px;
  cursor: pointer;
  display: block;
}

#typingScreen .sky-toggle input {
  display: none;
}

#typingScreen .sky-toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: linear-gradient(to bottom, #4facfe 0%, #00f2fe 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.15);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.dark-theme #typingScreen .sky-toggle-track {
  background: linear-gradient(to bottom, #1e3a8a 0%, #0f172a 100%);
  border-color: rgba(255, 255, 255, 0.1);
}

#typingScreen .sky-toggle-celestial {
  position: absolute;
  left: 3px;
  top: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #ffb800;
  /* Sun */
  box-shadow: 0 0 10px rgba(255, 184, 0, 0.6), 0 0 16px rgba(255, 153, 0, 0.3);
  transition: transform 0.7s cubic-bezier(0.34, 1.56, 0.64, 1.2),
    background 0.6s ease,
    box-shadow 0.6s ease;
  z-index: 2;
}

.dark-theme #typingScreen .sky-toggle-celestial {
  transform: translateX(26px) rotate(160deg);
  background: #f1f5f9;
  /* Moon */
  box-shadow: inset -5px -2px 0 rgba(15, 23, 42, 0.7), 0 0 10px rgba(241, 245, 249, 0.4);
}

#typingScreen .sky-toggle-stars {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.6s ease-in-out;
  pointer-events: none;
}

.dark-theme #typingScreen .sky-toggle-stars {
  opacity: 1;
}

/* Mini dots for stars in toggle indicator */
#typingScreen .sky-toggle-stars::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 5px;
  width: 2px;
  height: 2px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 8px 10px 0 #fff, 14px 4px 0 #fff, 4px 12px 0 #fff;
  opacity: 0.6;
}

#typingScreen .typing-setting-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 700;
}

#typingScreen .typing-toggle {
  position: relative;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

#typingScreen .typing-toggle input {
  display: none;
}

#typingScreen .typing-toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border-color) 85%, transparent);
  cursor: pointer;
  transition: background 0.2s ease;
}

#typingScreen .typing-toggle-track::before {
  content: "";
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  left: 3px;
  top: 3px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s ease;
}

#typingScreen .typing-toggle input:checked+.typing-toggle-track {
  background: #22c55e;
}

#typingScreen .typing-toggle input:checked+.typing-toggle-track::before {
  transform: translateX(20px);
}

#typingScreen .typing-actions {
  display: grid;
  gap: 10px;
  padding: 10px;
}

#typingScreen .typing-action {
  width: 100%;
  min-height: 44px;
  border: 1px solid color-mix(in srgb, var(--border-color) 78%, transparent);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-primary);
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.16s ease, border-color 0.16s ease, background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
  box-shadow: 0 6px 14px color-mix(in srgb, var(--shadow-dark) 20%, transparent);
  backdrop-filter: blur(0px);
}

.dark-theme #typingScreen .typing-action {
  background: rgba(30, 41, 59, 0.4);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#typingScreen .typing-action:hover {
  transform: translateY(-1px);
  filter: brightness(1.01);
}

#typingScreen .typing-action:active {
  transform: translateY(1px);
}

#typingScreen .typing-action-warning {
  background: linear-gradient(145deg, #f8fafc 0%, #e5e7eb 100%);
  border-color: color-mix(in srgb, #f59e0b 30%, var(--border-color));
  color: #7c4a03;
}

.dark-theme #typingScreen .typing-action-warning {
  background: rgba(251, 191, 36, 0.05);
  border-color: rgba(251, 191, 36, 0.4);
  color: #fbbf24;
}

.dark-theme #typingScreen .typing-action-warning:hover {
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.7);
  box-shadow: 0 0 15px rgba(251, 191, 36, 0.2);
}

#typingScreen .typing-action-secondary {
  background: linear-gradient(145deg, #f8fafc 0%, #e2e8f0 100%);
  border-color: color-mix(in srgb, #3b82f6 32%, var(--border-color));
  color: #1e40af;
}

.dark-theme #typingScreen .typing-action-secondary {
  background: rgba(59, 130, 246, 0.05);
  border-color: rgba(59, 130, 246, 0.4);
  color: #60a5fa;
}

.dark-theme #typingScreen .typing-action-secondary:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.7);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

#typingScreen .typing-action-primary {
  background: linear-gradient(145deg, #edf2ff 0%, #dbe7ff 100%);
  border-color: color-mix(in srgb, #2563eb 42%, var(--border-color));
  color: #1d4ed8;
}

.dark-theme #typingScreen .typing-action-primary {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.5);
  color: #8daeff;
}

.dark-theme #typingScreen .typing-action-primary:hover {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(37, 99, 235, 0.8);
  box-shadow: 0 0 15px rgba(37, 99, 235, 0.3);
}

#typingScreen .typing-action-danger {
  background: linear-gradient(145deg, #fff7f8 0%, #ffe7ea 100%);
  border-color: color-mix(in srgb, #ef4444 40%, var(--border-color));
  color: #b91c1c;
}

.dark-theme #typingScreen .typing-action-danger {
  background: rgba(239, 68, 68, 0.05);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.dark-theme #typingScreen .typing-action-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.7);
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.2);
}

#typingScreen .typing-panel-overlay {
  position: fixed;
  inset: 0;
  border: 0;
  margin: 0;
  padding: 0;
  background: rgba(15, 23, 42, 0.52);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease;
  z-index: 1100;
}

#typingScreen .typing-panel-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

#typingScreen .typing-time-card.time-warning {
  border-color: color-mix(in srgb, #ef4444 70%, var(--border-color));
  box-shadow:
    0 0 0 1px color-mix(in srgb, #ef4444 40%, transparent),
    0 8px 20px color-mix(in srgb, #ef4444 30%, transparent);
}

#typingScreen #liveWPM.wpm-excellent,
#typingScreen #liveAccuracy.accuracy-excellent,
#typingScreen #streakValue.streak-high {
  color: #22c55e;
}

#typingScreen #liveWPM.wpm-good,
#typingScreen #liveAccuracy.accuracy-good,
#typingScreen #streakValue.streak-medium {
  color: #f59e0b;
}

#typingScreen #liveWPM.wpm-poor,
#typingScreen #liveAccuracy.accuracy-poor,
#typingScreen #streakValue.streak-low {
  color: #ef4444;
}

@keyframes ttgProgressPulse {

  0%,
  100% {
    filter: drop-shadow(0 0 0 rgba(239, 68, 68, 0.3));
  }

  50% {
    filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.6));
  }
}

@media (max-width: 1200px) {
  #typingScreen .typing-shell {
    --ttg-sidebar-width: 264px;
  }

  #typingScreen .typing-live-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1024px) {
  #typingScreen {
    --ttg-mobile-tab-bg: color-mix(in srgb, var(--bg-secondary) 96%, transparent);
    --ttg-mobile-tab-border: color-mix(in srgb, var(--border-color) 76%, transparent);
  }

  #typingScreen .typing-shell {
    grid-template-columns: 1fr;
  }

  #typingScreen .typing-topbar {
    padding-right: 0;
    align-items: stretch;
  }

  #typingScreen .typing-topbar .typing-panel-toggle {
    display: inline-flex !important;
    order: 2;
    width: 32px;
    min-width: 32px;
    height: 100%;
    margin-right: -10px;
    border-radius: 14px 0 0 14px;
    padding: 0;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0;
    background: var(--ttg-mobile-tab-bg);
    border: 1px solid var(--ttg-mobile-tab-border);
    border-right: 0;
    box-shadow: none;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    position: relative;
  }

  #typingScreen .typing-topbar .typing-panel-toggle:hover {
    background: var(--ttg-mobile-tab-bg);
    border-color: color-mix(in srgb, var(--accent-color) 50%, var(--ttg-mobile-tab-border));
  }

  #typingScreen .typing-topbar .typing-panel-toggle svg {
    width: 18px;
    height: 18px;
    color: var(--accent-color);
    opacity: 0.85;
    filter: none;
  }

  #typingScreen .typing-panel-toggle-text {
    display: none !important;
  }

  #typingScreen .typing-live-strip {
    order: 1;
  }

  #typingScreen #menuBtn.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(6px);
  }

  #typingScreen .typing-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(304px, 84vw);
    height: var(--ttg-vh);
    z-index: 1200;
    transform: translateX(100%);
    transition: transform 0.24s ease;
    border-left: 1px solid color-mix(in srgb, var(--border-color) 85%, transparent);
    box-shadow: -16px 0 40px color-mix(in srgb, var(--shadow-dark) 50%, transparent);
    padding: max(8px, env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom));
    gap: 10px;
    overflow-y: auto;
  }

  #typingScreen #typingStatsPanel.open {
    transform: none;
  }

  #typingScreen .typing-sidebar-collapse {
    position: fixed;
    top: 0;
    right: min(304px, 84vw);
    bottom: 0;
    width: 32px;
    min-width: 32px;
    height: auto;
    min-height: auto;
    padding: 0;
    border-radius: 14px 0 0 14px;
    justify-content: center;
    align-items: center;
    gap: 0;
    border: 1px solid var(--ttg-mobile-tab-border);
    border-right: 0;
    background: var(--ttg-mobile-tab-bg);
    box-shadow: none;
    opacity: 0;
    pointer-events: none;
    transform: translateX(6px);
    z-index: 1210;
    transition:
      opacity 0.2s ease,
      transform 0.24s ease,
      background 0.2s ease,
      border-color 0.2s ease;
  }

  #typingScreen .typing-sidebar-collapse.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
  }

  #typingScreen .typing-sidebar-collapse:hover {
    background: var(--ttg-mobile-tab-bg);
    border-color: color-mix(in srgb, var(--accent-color) 50%, var(--ttg-mobile-tab-border));
    transform: none;
  }

  #typingScreen .typing-sidebar-collapse svg {
    width: 16px;
    height: 16px;
    padding: 0;
    background: transparent;
    color: var(--accent-color);
  }

  #typingScreen .typing-sidebar-collapse-text {
    display: none;
  }

  #typingScreen .typing-workspace {
    padding: 10px;
    gap: 10px;
  }

  #typingScreen .typing-paragraph-content {
    font-size: clamp(18px, 3.25vw, 24px);
    line-height: 1.72;
    padding: 14px;
  }

  #typingScreen .typing-input {
    min-height: 92px;
    max-height: min(34vh, 220px);
  }
}

@media (min-width: 1025px) {
  #typingScreen .typing-topbar .typing-panel-toggle {
    display: none !important;
  }
}

@media (max-width: 768px) {
  body.results-open #typingScreen .typing-sidebar-collapse,
  body.results-open #typingScreen .typing-topbar .typing-panel-toggle,
  body.results-open #typingScreen #typingPanelOverlay {
    display: none !important;
  }

  #typingScreen .typing-live-card {
    padding: 8px 10px;
    border-radius: 12px;
  }

  #typingScreen .typing-live-label {
    font-size: 10px;
  }

  #typingScreen .typing-live-value {
    font-size: clamp(14px, 3.5vw, 16px);
  }

  #typingScreen #liveWPM {
    font-size: clamp(13px, 3.3vw, 15px);
  }

  #typingScreen .typing-action {
    min-height: 42px;
    font-size: 13px;
  }

  #typingScreen .typing-setting-card {
    min-height: 50px;
    padding: 8px 12px;
  }

  #typingScreen .typing-theme-card {
    min-height: 50px;
  }

  #typingScreen .typing-theme-btn {
    min-height: 30px;
    padding: 0 12px;
    font-size: 10px;
  }

  #typingScreen .typing-paragraph-content {
    padding: 12px;
    line-height: 1.65;
  }

  #typingScreen .typing-input-wrap {
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  }

  #typingScreen .typing-input-label {
    margin-bottom: 4px;
    font-size: 11px;
  }

  #typingScreen .typing-input {
    min-height: 84px;
    line-height: 1.55;
    font-size: 16px;
  }

  #typingScreen.keyboard-open .typing-paragraph-panel {
    min-height: 140px;
  }
}

/* Pause Overlay Polish */
#pauseOverlay {
  backdrop-filter: blur(8px);
  background: color-mix(in srgb, #0f172a 66%, transparent);
}

#pauseOverlay .pause-content {
  width: min(560px, 92vw);
  max-width: 560px;
  border-radius: 26px !important;
  border: 1px solid color-mix(in srgb, var(--accent-color) 48%, var(--border-color)) !important;
  background:
    linear-gradient(155deg,
      color-mix(in srgb, var(--bg-secondary) 96%, transparent) 0%,
      color-mix(in srgb, var(--bg-primary) 96%, transparent) 100%);
  box-shadow: 0 28px 70px color-mix(in srgb, var(--shadow-dark) 54%, transparent) !important;
  padding: clamp(22px, 4vw, 34px) !important;
  animation: none;
}

#pauseOverlay .pause-content::before {
  display: none;
}

#pauseOverlay .pause-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px !important;
  padding: 12px !important;
  border-radius: 16px !important;
  border: 1px solid color-mix(in srgb, var(--border-color) 76%, transparent) !important;
  background: color-mix(in srgb, var(--bg-secondary) 88%, transparent) !important;
}

#pauseOverlay .pause-stat-item {
  border-radius: 12px !important;
  border: 1px solid color-mix(in srgb, var(--border-color) 72%, transparent) !important;
  background: color-mix(in srgb, var(--bg-primary) 94%, transparent) !important;
  padding: 10px 8px !important;
}

#pauseOverlay .pause-icon {
  width: 84px !important;
  height: 84px !important;
  border-radius: 18px !important;
  margin-bottom: 16px !important;
  border: 1px solid color-mix(in srgb, var(--accent-color) 34%, transparent) !important;
  background: color-mix(in srgb, var(--accent-color) 12%, var(--bg-primary)) !important;
  animation: none;
}

#pauseOverlay .pause-icon svg {
  width: 44px !important;
  height: 44px !important;
}

#pauseOverlay h2 {
  font-size: clamp(34px, 6vw, 48px);
  line-height: 1.05;
  margin-bottom: 10px;
  color: var(--text-primary);
}

#pauseOverlay p {
  margin-bottom: 18px;
}

#pauseOverlay #resumeBtn {
  min-height: 48px !important;
  border-radius: 12px !important;
  border: 1px solid color-mix(in srgb, #2563eb 40%, var(--border-color)) !important;
  background: linear-gradient(145deg, #e8f0ff 0%, #dce7ff 100%) !important;
  color: #1d4ed8 !important;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.18) !important;
}

@media (max-width: 560px) {
  #typingScreen .typing-topbar .typing-panel-toggle {
    width: 32px;
    min-width: 32px;
    padding: 0;
    gap: 0;
  }

  #typingScreen .typing-panel-toggle-text {
    display: none !important;
  }

  #typingScreen .typing-live-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  #typingScreen .typing-paragraph-content {
    font-size: clamp(16px, 5vw, 20px);
    line-height: 1.58;
  }

  #typingScreen.keyboard-open .typing-live-label {
    letter-spacing: 0.05em;
  }
}

@media (max-height: 540px) and (orientation: landscape) {
  #typingScreen .typing-workspace {
    grid-template-rows: auto minmax(100px, 1fr) auto;
    gap: 8px;
  }

  #typingScreen .typing-topbar {
    min-height: 52px;
  }

  #typingScreen .typing-live-card {
    padding: 6px 9px;
  }

  #typingScreen .typing-live-label {
    font-size: 9px;
  }

  #typingScreen .typing-live-value {
    font-size: 16px;
  }

  #typingScreen .typing-paragraph-content {
    font-size: 15px;
    line-height: 1.46;
    padding: 10px;
  }

  #typingScreen .typing-input {
    min-height: 62px;
    max-height: 92px;
    font-size: 15px;
  }
}

/* Dashboard Profile Modal: tightened responsive layout */
#profileModal {
  align-items: flex-start;
  padding: clamp(12px, 2.2vh, 28px) clamp(10px, 2vw, 28px) clamp(14px, 3vh, 30px);
}

#profileModal #downloadCertBtn {
  width: 100%;
  margin-top: 10px;
  min-height: 44px;
  border-radius: 12px;
}

#profileModal #wpmImprovement,
#profileModal #accImprovement {
  cursor: pointer;
}

#profileModal .profile-card {
  width: min(1160px, calc(100vw - clamp(24px, 4vw, 70px)));
  max-width: 1160px;
  max-height: min(94dvh, 980px);
  padding: clamp(14px, 1.5vw, 24px);
  border-radius: clamp(18px, 2.1vw, 26px);
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-areas:
    "header header header header header header header header best best best best"
    "heatmap heatmap heatmap heatmap heatmap heatmap heatmap heatmap performance performance performance performance"
    "heatmap heatmap heatmap heatmap heatmap heatmap heatmap heatmap performance performance performance performance"
    "progress progress progress progress progress achievements achievements achievements daily daily daily daily"
    "recent recent recent recent recent recent recent recent community community community community"
    "recent recent recent recent recent recent recent recent danger danger danger danger";
  gap: clamp(10px, 0.95vw, 14px);
  align-content: start;
  align-items: stretch;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  background: linear-gradient(180deg,
      color-mix(in srgb, var(--bg-secondary) 96%, #ffffff),
      color-mix(in srgb, var(--bg-secondary) 90%, var(--bg-primary)));
}

#profileModal .profile-card>#profileCard {
  grid-area: header;
  width: 100%;
  margin: 0;
}

#profileModal .profile-card>.profile-layout-bests {
  grid-area: best;
}

#profileModal .profile-card>.profile-layout-performance {
  grid-area: performance;
}

#profileModal .profile-card>.profile-layout-heatmap {
  grid-area: heatmap;
}

#profileModal .profile-card>.profile-layout-progress {
  grid-area: progress;
}

#profileModal .profile-card>.profile-layout-achievements {
  grid-area: achievements;
}

#profileModal .profile-card>.profile-layout-daily {
  grid-area: daily;
}

#profileModal .profile-card>.profile-layout-community {
  grid-area: community;
}

#profileModal .profile-card>.profile-layout-recent {
  grid-area: recent;
}

#profileModal .profile-card>.profile-layout-danger {
  grid-area: danger;
}

#profileModal .profile-card>.profile-section,
#profileModal .profile-card>details.profile-layout-danger {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: clamp(11px, 1vw, 15px);
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--border-color) 92%, transparent);
  background: linear-gradient(180deg,
      color-mix(in srgb, var(--bg-tertiary) 92%, transparent),
      color-mix(in srgb, var(--bg-secondary) 93%, transparent));
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}

#profileModal #profileCard {
  display: grid;
  grid-template-columns: minmax(80px, 100px) minmax(0, 1fr);
  gap: 10px 16px;
  align-items: start;
  padding: clamp(12px, 1.2vw, 18px);
  border-radius: 18px;
}

#profileModal #profileCard .profile-compact-left {
  width: auto;
}

#profileModal #profileCard .profile-avatar-compact {
  width: 80px;
  height: 80px;
}

#profileModal #profileCard>.compact-xp-row,
#profileModal #profileCard>.compact-bio-wrapper {
  grid-column: 1 / -1;
}

#profileModal .section-title {
  margin-bottom: 9px;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

#profileModal .profile-layout-bests .personal-bests {
  gap: 8px;
  margin-bottom: 8px;
}

#profileModal .profile-layout-bests .best-item {
  min-height: 84px;
  padding: 10px 8px;
  border-radius: 14px;
}

#profileModal .profile-layout-bests .best-value {
  font-size: clamp(1.8rem, 1.7vw, 2.1rem);
}

#profileModal .profile-layout-bests .best-label {
  font-size: 0.66rem;
}

#profileModal .profile-layout-performance {
  display: flex;
  flex-direction: column;
}

#profileModal .profile-layout-performance .profile-stats-grid {
  margin-bottom: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

#profileModal .profile-layout-performance .profile-stat {
  min-height: 84px;
  padding: 9px 7px;
  border-radius: 12px;
}

#profileModal .profile-layout-performance .profile-stat .stat-value {
  font-size: clamp(1.5rem, 1.6vw, 1.95rem);
}

#profileModal .profile-layout-performance .profile-stat .stat-label {
  font-size: 0.66rem;
  letter-spacing: 0.07em;
}

#profileModal .profile-layout-progress .improvement-cards {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

#profileModal .profile-layout-progress .improvement-card {
  min-height: 104px;
  border-radius: 14px;
  padding: 14px 10px !important;
}

#profileModal .profile-layout-achievements {
  display: flex;
}

#profileModal .profile-layout-achievements .achievements-btn {
  width: 100%;
  min-height: 104px;
  height: 100%;
  padding: 14px !important;
  border-radius: 16px !important;
  gap: 10px !important;
}

#profileModal .profile-layout-achievements .achievements-btn-arrow {
  width: 32px;
  height: 32px;
}

#profileModal .profile-layout-daily,
#profileModal .profile-layout-recent {
  display: flex;
  flex-direction: column;
}

#profileModal .profile-layout-daily .daily-claim-section {
  margin-bottom: 8px;
  padding: 9px 11px;
}

#profileModal .profile-layout-daily .daily-tasks-list {
  margin-top: 8px;
  max-height: 190px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

#profileModal .profile-layout-recent .recent-tests-list {
  margin-top: 8px;
  max-height: clamp(360px, 52vh, 560px);
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

#profileModal .profile-layout-recent .no-tests {
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#profileModal .profile-layout-community #discordStatus {
  min-height: 84px;
}

#profileModal .profile-layout-heatmap {
  --heatmap-cell-size: clamp(10px, 0.84vw, 12px);
  --heatmap-cell-gap: clamp(2px, 0.22vw, 3px);
}

#profileModal .profile-layout-heatmap .activity-heatmap-container {
  padding: 11px;
  margin-top: 0;
}

#profileModal .profile-layout-heatmap .heatmap-wrapper {
  padding-bottom: 2px;
  mask-image: none;
  -webkit-mask-image: none;
}

#profileModal .profile-layout-heatmap .heatmap-grid-container {
  gap: 10px;
  width: max-content;
  margin-left: auto;
  margin-right: auto;
}

#profileModal .profile-layout-heatmap .heatmap-days-labels {
  padding-top: 14px;
  font-size: 9px;
}

#profileModal .profile-layout-heatmap .heatmap-months,
#profileModal .profile-layout-heatmap .heatmap-grid {
  gap: var(--heatmap-cell-gap);
  grid-template-columns: repeat(53, var(--heatmap-cell-size));
}

#profileModal .profile-layout-heatmap .heatmap-grid {
  grid-template-rows: repeat(7, var(--heatmap-cell-size));
}

#profileModal .profile-layout-heatmap .heatmap-day {
  width: var(--heatmap-cell-size);
  height: var(--heatmap-cell-size);
}

#profileModal details.profile-layout-danger {
  display: block;
  margin: 0;
  padding: 0;
  border-color: rgba(239, 68, 68, 0.28);
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.06), rgba(239, 68, 68, 0.02));
}

#profileModal details.profile-layout-danger .danger-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
}

#profileModal details.profile-layout-danger .danger-summary::-webkit-details-marker {
  display: none;
}

#profileModal details.profile-layout-danger .danger-summary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(239, 68, 68, 0.32);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #ef4444;
  background: rgba(255, 255, 255, 0.62);
}

#profileModal details.profile-layout-danger[open] .danger-summary-action {
  background: rgba(239, 68, 68, 0.12);
}

#profileModal details.profile-layout-danger .danger-content-panel {
  padding: 0 14px 14px;
  border-top: 1px dashed rgba(239, 68, 68, 0.26);
}

#profileModal details.profile-layout-danger:not([open]) .danger-content-panel {
  display: none;
}

#profileModal details.profile-layout-danger .btn-danger-block {
  margin-top: 10px;
  min-height: 40px;
  border-radius: 11px;
}

@media (max-width: 1024px) and (min-width: 769px) {
  #profileModal {
    padding: 10px 12px 12px;
  }

  #profileModal .profile-card {
    width: min(980px, calc(100vw - 24px));
    max-width: 980px;
    max-height: calc(100dvh - 22px);
    padding: 12px;
    border-radius: 16px;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    grid-template-areas:
      "header header header header header header header header"
      "best best best best performance performance performance performance"
      "heatmap heatmap heatmap heatmap heatmap heatmap heatmap heatmap"
      "progress progress progress progress achievements achievements achievements achievements"
      "recent recent recent recent recent recent recent recent"
      "daily daily daily daily community community community community"
      "danger danger danger danger danger danger danger danger";
    gap: 10px;
  }

  #profileModal #profileCard {
    padding-right: 56px;
  }

  #profileModal .profile-close-btn-curved {
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
  }

  #profileModal .profile-layout-daily .daily-tasks-list {
    max-height: 180px;
  }

  #profileModal .profile-layout-recent .recent-tests-list {
    max-height: clamp(220px, 34vh, 320px);
  }

  #profileModal .profile-layout-recent .no-tests {
    min-height: 170px;
  }
}

@media (max-width: 768px) {
  #profileModal {
    padding: 8px;
  }

  #profileModal .profile-card {
    width: min(680px, 100%);
    max-height: calc(100dvh - 16px);
    padding: 10px;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    overflow-y: auto;
  }

  #profileModal .profile-card>.profile-section,
  #profileModal .profile-card>details.profile-layout-danger {
    padding: 10px;
    border-radius: 13px;
  }

  #profileModal #profileCard {
    grid-template-columns: 60px minmax(0, 1fr);
    gap: 8px 10px;
    padding: 10px;
    border-radius: 13px;
  }

  #profileModal #profileCard .profile-avatar-compact {
    width: 60px;
    height: 60px;
  }

  #profileModal .profile-compact-right {
    gap: 5px;
  }

  #profileModal .compact-top-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
  }

  #profileModal .profile-name-clickable {
    max-width: 100% !important;
    font-size: 1.05rem;
  }

  #profileModal .profile-header-actions {
    margin-top: 0;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
  }

  #profileModal .profile-header-action-btn {
    padding: 5px 8px;
    font-size: 11px;
    min-height: 30px;
  }

  #profileModal #shareProfileBtn.profile-header-action-btn {
    margin-top: 0;
    align-self: auto;
  }

  #profileModal .compact-xp-row {
    margin-top: 2px;
  }

  #profileModal .compact-bio-wrapper {
    height: 32px !important;
  }

  #profileModal .profile-close-btn-curved {
    top: 8px;
    right: 8px;
    border-radius: 10px !important;
  }

  #profileModal .profile-layout-bests .best-item {
    min-height: 74px;
    padding: 9px 6px;
  }

  #profileModal .profile-layout-bests .best-value {
    font-size: 1.75rem;
  }

  #profileModal .profile-layout-performance .profile-stat {
    min-height: 76px;
  }

  #profileModal .profile-layout-progress .improvement-cards {
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #profileModal .profile-layout-progress .improvement-card {
    min-height: 90px !important;
    padding: 12px 9px !important;
  }

  #profileModal .profile-layout-progress .improvement-value {
    font-size: 1.75rem !important;
  }

  #profileModal .profile-layout-achievements .achievements-btn {
    min-height: 92px;
    padding: 12px !important;
  }

  #profileModal .profile-layout-daily .daily-tasks-list,
  #profileModal .profile-layout-recent .recent-tests-list {
    max-height: 210px;
  }
}

@media (max-width: 520px) {
  #profileModal #profileCard {
    grid-template-columns: 66px minmax(0, 1fr);
    gap: 10px 14px;
    padding: 12px 13px 11px 15px;
  }

  #profileModal #profileCard .profile-compact-left {
    width: 66px;
    margin-left: 2px;
    margin-top: 0;
    align-self: center;
    align-items: center;
    justify-content: center;
  }

  #profileModal #profileCard .profile-avatar-compact {
    width: 62px;
    height: 62px;
  }

  #profileModal .profile-compact-right {
    gap: 6px;
  }

  #profileModal .compact-top-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  #profileModal .profile-identity {
    padding-left: 4px;
  }

  #profileModal .profile-name-clickable {
    font-size: 1.1rem !important;
    line-height: 1.1;
  }

  #profileModal .username-display {
    font-size: 0.82rem;
  }

  #profileModal .profile-header-actions {
    width: auto;
    margin-left: 2px;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 6px;
  }

  #profileModal .profile-header-action-btn,
  #profileModal #shareProfileBtn.profile-header-action-btn {
    padding: 5px 8px;
    font-size: 11px;
    min-height: 32px;
  }

  #profileModal .profile-close-btn-curved {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    top: 9px;
    right: 9px;
  }
}

@media (max-width: 420px) {
  #profileModal #profileCard {
    grid-template-columns: 60px minmax(0, 1fr);
    gap: 9px 11px;
    padding: 11px 11px 10px 13px;
  }

  #profileModal #profileCard .profile-compact-left {
    width: 60px;
    margin-left: 1px;
    margin-top: 0;
    align-self: center;
  }

  #profileModal #profileCard .profile-avatar-compact {
    width: 58px;
    height: 58px;
  }

  #profileModal .profile-layout-bests .best-value {
    font-size: 1.55rem;
  }

  #profileModal .profile-layout-performance .profile-stat .stat-value {
    font-size: 1.2rem;
  }
}

@media (max-width: 360px) {
  #profileModal .profile-layout-progress .improvement-cards {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1025px) {
  #profileModal .profile-layout-bests .personal-bests {
    margin-bottom: 14px;
  }

  #profileModal .profile-layout-bests #downloadCertBtn {
    margin-top: 12px;
  }

  #profileModal #profileCard {
    min-height: 268px;
    padding: clamp(16px, 1.5vw, 22px);
    grid-template-columns: minmax(90px, 112px) minmax(0, 1fr);
    gap: 14px 20px;
  }

  #profileModal #profileCard .profile-avatar-compact {
    width: 92px;
    height: 92px;
  }

  #profileModal .profile-layout-progress {
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  #profileModal .profile-layout-progress .improvement-cards {
    flex: 1;
    height: 100%;
    gap: 12px;
    grid-auto-rows: 1fr;
    align-content: stretch;
  }

  #profileModal .profile-layout-progress .improvement-card {
    min-height: 150px;
    height: 100%;
    padding: 18px 12px !important;
  }

  #profileModal .profile-layout-progress .improvement-value {
    font-size: clamp(2rem, 2vw, 2.3rem) !important;
  }
}

/* Atmospheric Animations */
@keyframes sky-twinkle {

  0%,
  100% {
    opacity: 0.3;
    transform: scale(0.8);
  }

  50% {
    opacity: 0.9;
    transform: scale(1);
  }
}
