/* Player identity, tactile feedback, and comfortable touch targets. */
:root { --spring: cubic-bezier(.22, 1, .36, 1); }
button { transition: transform 180ms var(--spring), background-color 180ms ease, box-shadow 180ms ease; }
button:active:not(:disabled):not(.gem) { transform: scale(.97); }
button:disabled { -webkit-tap-highlight-color: transparent; }
body.modal-open { overflow: hidden; }
body { padding-top: env(safe-area-inset-top, 0px); }
.topbar { gap: 22px; }
.profile-button { padding: 5px 13px 5px 5px; gap: 10px; text-align: left; border-color: #d9d0e5; background: #eee8f455; }
.profile-button .player-avatar { width: 38px; height: 38px; flex-shrink: 0; }
.player-avatar { position: relative; isolation: isolate; overflow: hidden; }
.player-avatar > span { display: grid; place-items: center; width: 100%; height: 100%; font: 600 14px var(--display); background: linear-gradient(145deg, #dbcaf7, #baa0e5); color: #554469; }
.player-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.player-avatar.has-photo > span { visibility: hidden; }
.header-player { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.header-player strong { font: 600 12px var(--display); max-width: 125px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0; }
.header-player small { font: 500 8px var(--display); color: #877195; letter-spacing: 1px; }
.profile-chevron { margin-left: 14px; }
.welcome-line { display: flex; align-items: center; gap: 7px; font: 500 11px var(--display); color: #88709f; margin: 0 0 14px; }
.welcome-line > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.welcome-dot { background: #a5bd7b; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.icon-button, .close-button { min-width: 42px; min-height: 42px; }
.close-button { z-index: 4; border-radius: 50%; background: #f4f1e9c9; display: grid; place-items: center; backdrop-filter: blur(8px); }
.tool-button, .text-button { min-height: 44px; }
.board { contain: layout style; }
.board-inner { overflow: clip; overflow-clip-margin: 10px; border-radius: 15px; }
.gem { transition: transform 170ms var(--spring), filter 150ms ease; }
.gem svg { transform-origin: 50% 55%; }
.gem.selected { transform: translateY(-2px) scale(.95); filter: brightness(1.07); outline: 3px solid #fff; }
.gem.selected .smile { stroke-width: 3; }
.gem.selected .eyes { ry: 2; }
.score-burst.show { animation-duration: 600ms; }
.gem.hinted { outline: 3px solid #fff; outline-offset: -1px; }
.gem.popping { animation: jelly-pop 220ms ease-in forwards; }
.gem.preview-gem:nth-child(9n + 2) svg { animation: jelly-idle 7s ease-in-out infinite; }
.gem.preview-gem:nth-child(9n + 11) svg { animation-delay: 1.4s; }
.gem.preview-gem:nth-child(9n + 20) svg { animation-delay: 3s; }
.board-frame { transition: box-shadow 250ms ease; transform-origin: 50% 50%; }
.board-frame.looped .chain-lines polyline { stroke-width: 10; }
.chain-lines polyline { transition: stroke-width 150ms ease; }
.progress-track i { transition: width 450ms var(--spring); }
.run-stats b, .goal-score b, .result-score b, .profile-stats b { font-variant-numeric: tabular-nums; }
.selection-note { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 6px; text-align: left; }
.selection-note button { min-height: 40px; padding: 7px 0 7px 8px; background: none; font-size: 10px; color: #796389; white-space: nowrap; }
.selection-note button:disabled { opacity: .35; }
.button.primary:not(:disabled) { box-shadow: 0 3px 0 #13131d; }
.button.primary:active:not(:disabled) { box-shadow: 0 1px 0 #13131d; transform: translateY(2px) scale(.99); }
.pulse-card:has(.armed) { background: #e2d5f3; border-color: #b6a0d5; }
.toast { bottom: calc(25px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 8px 35px #29283726; }
body.in-run .toast { bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }
.player-dialog { width: min(530px, calc(100% - 28px)); padding: 0 28px 24px; overscroll-behavior: contain; }
.profile-cover { height: 128px; margin: 0 -28px; background: radial-gradient(ellipse at 12% 10%, #e7d7ff 0, transparent 55%), radial-gradient(ellipse at 95% 95%, #cce4c3 0, transparent 55%), #d3c1ec; position: relative; overflow: hidden; }
.profile-cover::after { content: ''; position: absolute; width: 250px; height: 250px; border: 1px solid #fff7; border-radius: 50%; left: calc(50% - 125px); top: -135px; box-shadow: 0 0 0 30px #ffffff18, 0 0 0 60px #ffffff12; }
.profile-cover > span { position: absolute; color: #fff9; font: 500 70px var(--display); transform: rotate(-16deg); }
.profile-cover > span:nth-child(1) { left: 27px; top: 20px; font-size: 43px; }
.profile-cover > span:nth-child(2) { left: 110px; top: -24px; }
.profile-cover > span:nth-child(3) { right: 28px; top: 34px; color: #b09ac988; }
.profile-cover > span:nth-child(4) { right: 122px; top: 17px; font-size: 35px; }
.profile-identity { display: flex; align-items: center; flex-direction: column; text-align: center; margin-top: -46px; position: relative; }
.profile-portrait { width: 94px; height: 94px; border: 5px solid var(--paper); border-radius: 30px; background: #baa0e5; box-shadow: 0 5px 0 #e2d8eb, 0 12px 30px #6c4b8c18; overflow: visible; }
.profile-portrait > span { font-size: 32px; border-radius: 24px; }
.profile-portrait img { border-radius: 24px; }
.portrait-spark { position: absolute; right: -12px; bottom: -8px; width: 31px; height: 31px; border: 3px solid var(--paper); border-radius: 50%; background: var(--lime); font: 500 21px var(--display); display: grid; place-items: center; color: #586636; }
.profile-source { margin-top: 21px; font: 600 8px var(--display); letter-spacing: 2px; color: #8a759d; }
.profile-identity h2 { font-size: 30px; line-height: 1.2; margin: 9px 0 4px; letter-spacing: -1px; max-width: 100%; overflow-wrap: anywhere; }
.profile-identity p { font-size: 12px; margin: 0; overflow-wrap: anywhere; max-width: 100%; }
.profile-rank { background: #e9e2f2; color: #8b6caf; border: 1px solid #dcd0e9; border-radius: 30px; font: 600 9px var(--display); letter-spacing: .7px; padding: 8px 13px; margin-top: 13px; }
.player-dialog .profile-level { gap: 12px; background: #ece7f1; padding: 16px; border: 1px solid #e0d7e8; border-radius: 14px; margin: 24px 0 16px; }
.player-dialog .profile-level > span:first-child { font-size: 35px; padding: 0; background: none; }
.player-dialog .profile-level b { font-size: 17px; }
.player-dialog .profile-level p { font-size: 10px; margin-bottom: 9px; }
.player-dialog .profile-level > .level-destination { padding: 0 0 0 4px; background: none; font: 600 24px var(--display); color: #c1b4ce; }
.profile-stats { gap: 9px; }
.profile-stats > div { padding: 14px 12px; background: #ffffff29; }
.profile-stats b { font-size: 24px; }
.profile-stats small { display: block; margin-top: 5px; letter-spacing: .5px; }
.profile-shortcuts { display: grid; grid-template-columns: 1.15fr 1fr; gap: 10px; margin: 17px 0 25px; }
.profile-shortcuts .button { font-size: 9px; letter-spacing: .5px; padding: 13px 14px; min-height: 45px; }
.profile-shortcuts .button span { font-size: 18px; }
.profile-section-heading { display: flex; gap: 12px; justify-content: space-between; align-items: center; margin: 25px 0 10px; }
.profile-section-heading h3 { margin: 0; font-size: 15px; }
.profile-section-heading > span { font: 500 8px var(--display); color: #99899f; letter-spacing: .6px; white-space: nowrap; }
.achievement { opacity: 1; padding: 12px 0; }
.achievement:not(.earned) { color: #89818e; }
.achievement > span { display: grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0; background: #e9e4ed; border-radius: 11px; font-size: 23px; }
.achievement.earned > span { background: #e1eacb; color: #7f9556; }
.achievement p { color: #8e8295; }
.history-row { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.history-row b { display: block; font: 600 12px var(--display); }
.history-row small { display: block; color: var(--muted); font-size: 10px; margin-top: 5px; }
.history-row > strong { font: 600 20px var(--display); font-variant-numeric: tabular-nums; }
.history-empty { border: 1px dashed #d7cddd; padding: 17px; border-radius: 12px; text-align: center; font-size: 11px; }
.comfort-settings { border: 1px solid #ded6e5; border-radius: 14px; overflow: hidden; }
.setting-row { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; padding: 16px 12px; background: #ffffff25; min-height: 66px; }
.setting-row + .setting-row { border-top: 1px solid #ded6e5; }
.setting-icon { display: grid; place-items: center; font: 500 23px var(--display); color: #a28ab7; width: 27px; flex-shrink: 0; }
.setting-row b { display: block; font: 600 12px var(--display); }
.setting-row small { display: block; font-size: 10px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.switch-track { margin-left: auto; flex-shrink: 0; width: 36px; height: 22px; border-radius: 20px; background: #d8d1df; position: relative; transition: background-color 180ms ease; }
.switch-track::after { content: ''; width: 16px; height: 16px; background: #fff; border-radius: 50%; position: absolute; top: 3px; left: 3px; box-shadow: 0 1px 3px #29283726; transition: transform 220ms var(--spring); }
.setting-row[aria-checked=true] .switch-track { background: #ad93d4; }
.setting-row[aria-checked=true] .switch-track::after { transform: translateX(14px); }
.setting-row:disabled { opacity: .6; }
.player-dialog .storage-note { margin-top: 20px; line-height: 1.7; }
@keyframes jelly-pop {
  0% { transform: scale(.95); opacity: 1; }
  35% { transform: scale(1.16,.85) rotate(-4deg); opacity: 1; }
  60% { transform: scale(.9,1.1) rotate(3deg); opacity: 1; }
  100% { transform: scale(.18); opacity: 0; }
}
@keyframes jelly-idle {
  0%, 84%, 100% { transform: none; }
  88% { transform: rotate(-8deg) scale(1.08,.94); }
  92% { transform: rotate(6deg) scale(.97,1.05); }
  96% { transform: rotate(-2deg); }
}
@media (hover: hover) {
  .profile-button:hover { background: #e7def2; transform: translateY(-2px); }
  .tool-button:hover, .text-button:hover { color: #9372b7; }
  .setting-row:not(:disabled):hover { background: #eae2f2; }
}
@media (max-width: 1000px) { .top-tag { display: none; } }
@media (max-width: 560px) {
  .topbar { height: 80px; gap: 9px; }
  .brand { font-size: 24px; gap: 5px; }
  .brand svg { width: 26px; height: 26px; }
  .brand sup { font-size: 12px; }
  .top-actions { gap: 5px; }
  .profile-button { padding: 0; gap: 7px; background: none; }
  .profile-button .player-avatar { width: 35px; height: 35px; }
  .profile-button > .header-player { display: flex; }
  .header-player strong { max-width: 67px; font-size: 10px; }
  .header-player small { font-size: 7px; letter-spacing: .4px; }
  .profile-chevron { margin-left: 5px; }
  .icon-button { min-width: 38px; min-height: 42px; border-color: transparent; }
  .welcome-line { margin-bottom: 11px; font-size: 10px; }
  .player-dialog { padding: 0 20px 22px; max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); }
  .profile-cover { margin: 0 -20px; height: 112px; }
  .profile-identity h2 { font-size: 27px; }
  .profile-section-heading h3 { font-size: 13px; }
  .profile-section-heading > span { font-size: 7px; }
  .profile-shortcuts { gap: 8px; }
  .profile-shortcuts .button { padding: 12px 10px; font-size: 8px; letter-spacing: .1px; }
  .profile-stats > div { padding: 12px 9px; }
  .profile-stats b { font-size: 22px; }
  .profile-stats small { font-size: 7px; }
  .setting-row { gap: 8px; padding: 14px 10px; }
  .setting-row small { font-size: 9px; }
  .selection-note { gap: 5px; font-size: 8px; }
  .selection-note button { font-size: 9px; }
  .run-panel > .text-button { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 360px) { .profile-button > .header-player { display: none; } }
body.calm-motion *, body.calm-motion *::before, body.calm-motion *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
body.calm-motion .score-burst.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
