/* Field Mice home screen v2 (Figma frame 63:322) */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --hv2-font: 'Chillax', system-ui, sans-serif;
  --hv2-panel: rgba(51, 43, 76, 0.92);
  --hv2-ink: #120e1a;
  --hv2-cream: #f4efe6;
  --hv2-accent: #e7c47c;
  --hv2-border: #0a0610;
  /*
   * Menu column is 760px in Figma and everything below scales off it.
   * The stack is ~1.14x the column width tall, so cap by height too and
   * the whole screen fits without scrolling.
   */
  --hv2-col: min(760px, 92vw, 78vh);
  --hv2-col: min(760px, 92vw, 78dvh);
  --hv2-gap: calc(var(--hv2-col) * 0.0316);
  --hv2-row-gap: calc(var(--hv2-col) * 0.0421);
  --hv2-radius: calc(var(--hv2-col) * 0.0316);
}

html, body {
  height: 100%;
}

html:has(body.hv2) {
  background-color: #917bb7;
}

body.hv2.scene-bg {
  font-family: var(--hv2-font);
  color: var(--hv2-cream);
  min-height: 100%;
  display: flex;
  justify-content: center;
  /* "safe" falls back to start when the stack is taller than the viewport */
  align-items: flex-start;
  align-items: safe center;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: transparent;
  --scene-bg-fallback: #917bb7;
  --scene-bg-purple-overlay: rgba(145, 123, 183, 0.35);
}

/* scene.css parks its layers at z-index -2/-1; lift them above the page fill */
body.hv2.scene-bg::before {
  z-index: 0;
}

body.hv2.scene-bg::after {
  z-index: 0;
  background: rgba(145, 123, 183, 0.35);
}

.hv2-home {
  position: relative;
  z-index: 1;
  width: var(--hv2-col);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--hv2-gap);
  padding-block: clamp(16px, 3vh, 48px);
}

.hv2-seo-title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.hv2-logo {
  width: calc(var(--hv2-col) * 0.672);
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.22));
}

.hv2-logo img {
  display: block;
  width: 100%;
  height: auto;
}

.hv2-status {
  font-size: clamp(0.9rem, calc(var(--hv2-col) * 0.0382), 1.9rem);
  font-weight: 700;
  text-align: center;
  text-wrap: balance;
  color: #fff;
  min-height: 1.3em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
}

.hv2-status--ok,
.online-status--ok.hv2-status {
  color: #d8f5c8;
}

.hv2-status--err,
.online-status--err.hv2-status {
  color: #ffd0d0;
  font-size: clamp(0.78rem, calc(var(--hv2-col) * 0.023), 1.1rem);
}

/* ---------- Menu ---------- */
.hv2-menu {
  display: flex;
  flex-direction: column;
  gap: var(--hv2-gap);
  width: 100%;
}

.hv2-menu-row {
  display: flex;
  gap: var(--hv2-row-gap);
  width: 100%;
}

.hv2-menu-row .hv2-menu-btn {
  flex: 1 1 0;
  min-width: 0;
}

.hv2-menu-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--hv2-radius);
  transition: transform 0.12s ease, filter 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.hv2-menu-btn img,
.hv2-menu-btn picture {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  user-select: none;
}

.hv2-menu-btn picture img {
  width: 100%;
  height: auto;
}

/* Hover lift only on fine pointers — avoids sticky hover after tap on touch. */
@media (hover: hover) and (pointer: fine) {
  .hv2-menu-btn:hover:not(:disabled):not([aria-disabled='true']):not(:active) {
    transform: translateY(-3px);
    filter: brightness(1.06) drop-shadow(0 8px 14px rgba(0, 0, 0, 0.3));
  }
}

/* Press feedback for desktop + mobile art (touch and mouse). */
.hv2-menu-btn:active:not(:disabled):not([aria-disabled='true']),
.hv2-menu-btn.is-pressed:not(:disabled):not([aria-disabled='true']) {
  transform: translateY(2px) scale(0.985);
  filter: brightness(0.88);
}

.hv2-menu-btn:focus-visible {
  outline: 4px solid #fff6c8;
  outline-offset: 4px;
}

.hv2-menu-btn:disabled,
.hv2-menu-btn[aria-disabled='true'] {
  cursor: not-allowed;
  filter: grayscale(0.55) brightness(0.8);
  transform: none;
}

.hv2-menu-btn.is-busy {
  animation: hv2BusyPulse 1s ease-in-out infinite;
}

@keyframes hv2BusyPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ---------- Join / waiting panels ---------- */
.hv2-panel {
  display: none;
  flex-direction: column;
  gap: 14px;
  width: min(460px, 100%);
  padding: 22px 22px 20px;
  background: var(--hv2-panel);
  border: 6px solid var(--hv2-border);
  border-radius: 24px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
}

.hv2-panel.visible {
  display: flex;
}

.hv2-input {
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  width: 100%;
  padding: 12px 14px;
  color: var(--hv2-ink);
  background: var(--hv2-cream);
  border: 4px solid var(--hv2-border);
  border-radius: 14px;
  outline: none;
}

.hv2-input--code {
  font-size: 1.7rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 10px;
  text-transform: uppercase;
}

.hv2-input--code::placeholder {
  font-size: 1rem;
  letter-spacing: 3px;
}

.hv2-input:focus {
  border-color: var(--hv2-accent);
}

.hv2-btn {
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 12px 18px;
  border-radius: 14px;
  border: 4px solid var(--hv2-border);
  background: var(--hv2-accent);
  color: var(--hv2-ink);
  cursor: pointer;
}

.hv2-btn:hover:not(:disabled) {
  filter: brightness(1.06);
}

.hv2-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.hv2-btn--ghost {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.55);
}

.hv2-btn:focus-visible {
  outline: 2px solid #fff6c8;
  outline-offset: 3px;
}

.hv2-row {
  display: flex;
  gap: 10px;
}

.hv2-row .hv2-btn {
  flex: 1;
}

.hv2-error {
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffb0b0;
  text-align: center;
  min-height: 1.2em;
}

.hv2-panel--waiting {
  align-items: center;
  text-align: center;
}

.hv2-panel--waiting .hv2-btn {
  width: 100%;
}

.hv2-code-label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  opacity: 0.75;
}

.hv2-code {
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: 10px;
  padding: 6px 22px;
  color: var(--hv2-ink);
  background: var(--hv2-cream);
  border: 4px solid var(--hv2-border);
  border-radius: 14px;
}

.hv2-copy-hint {
  font-size: 0.8rem;
  opacity: 0.75;
  cursor: pointer;
}

.hv2-copy-hint:hover {
  opacity: 1;
}

.hv2-waiting-host {
  font-size: 0.95rem;
  font-weight: 600;
}

.hv2-waiting-text {
  font-size: 0.95rem;
  opacity: 0.8;
  animation: hv2Wait 2s ease infinite;
}

@keyframes hv2Wait {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 0.35; }
}

/* ---------- Overlays ---------- */
.hidden {
  display: none !important;
}

.hv2-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 12, 28, 0.66);
  backdrop-filter: blur(4px);
}

.hv2-overlay-panel {
  width: min(460px, 100%);
  max-height: min(92vh, 780px);
  overflow-y: auto;
  padding: 26px 24px 22px;
  color: #fff;
  background: rgba(51, 43, 76, 0.96);
  border: 6px solid var(--hv2-border);
  border-radius: 24px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
}

.hv2-overlay-panel h2 {
  font-size: clamp(1.4rem, 2.4vw, 1.9rem);
  font-weight: 700;
  margin-bottom: 6px;
}

/* Match settings — ids/classes are driven by js/settingsUI.js */
.settings-subtitle {
  font-size: 0.92rem;
  opacity: 0.8;
  line-height: 1.4;
  margin-bottom: 18px;
}

.settings-field {
  margin-bottom: 16px;
}

.settings-field label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.settings-field label span:last-child {
  font-weight: 700;
  color: var(--hv2-accent);
}

.settings-field input[type='range'] {
  width: 100%;
  accent-color: var(--hv2-accent);
}

.settings-username-input {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  width: 100%;
  padding: 10px 12px;
  color: var(--hv2-ink);
  background: var(--hv2-cream);
  border: 4px solid var(--hv2-border);
  border-radius: 12px;
  outline: none;
}

.settings-username-input:focus {
  border-color: var(--hv2-accent);
}

.settings-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  cursor: pointer;
}

.settings-check input {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--hv2-accent);
}

.settings-check-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-check-text small {
  font-size: 0.8rem;
  opacity: 0.75;
  line-height: 1.35;
}

.settings-trump-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.settings-trump-head label {
  margin: 0;
}

.settings-trump-reset,
.settings-trump-filter-btn {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 5px 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  cursor: pointer;
}

.settings-trump-filter {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.settings-trump-filter-btn {
  flex: 1;
  min-width: 0;
}

.settings-trump-filter-btn.active {
  color: var(--hv2-ink);
  background: var(--hv2-accent);
  border-color: var(--hv2-border);
}

.settings-trump-editor {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  max-height: 240px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.06);
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
}

.settings-trump-row {
  display: grid;
  grid-template-columns: 28px 1fr 28px 22px 28px;
  align-items: center;
  gap: 6px;
}

.settings-trump-row.hidden {
  display: none;
}

.settings-trump-thumb {
  width: 28px;
  height: 28px;
  object-fit: contain;
  /* Trump artwork includes its own stroke. */
  background: transparent;
}

.settings-trump-label {
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
}

.settings-trump-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
  color: var(--hv2-accent);
  background: rgba(255, 255, 255, 0.1);
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-radius: 9px;
  cursor: pointer;
}

.settings-trump-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

.settings-trump-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.settings-trump-count {
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.settings-trump-hint {
  font-size: 0.78rem;
  opacity: 0.75;
  line-height: 1.35;
  margin-top: 6px;
}

.settings-trump-hint--warn {
  color: #ffb0b0;
  font-weight: 600;
  opacity: 1;
}

.settings-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.settings-actions .hv2-btn {
  flex: 1;
}

/* ---------- Trump reference (markup built by js/trumpCards.js) ---------- */
.hv2-trump-ref-panel {
  width: min(900px, 100%);
}

.hv2-trump-ref-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}

.hv2-trump-ref-intro {
  font-size: 0.92rem;
  opacity: 0.8;
  line-height: 1.4;
  margin-bottom: 16px;
}

.trump-ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.trump-ref-card {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.07);
  border: 3px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
}

.trump-ref-card--modifier {
  border-color: rgba(231, 196, 124, 0.5);
}

.trump-ref-card--action {
  border-color: rgba(162, 170, 255, 0.5);
}

.trump-ref-thumb {
  width: 46px;
  height: 46px;
  /* Art already has its own stroke — no CSS frame/clip that thickens or shears it. */
  background: transparent;
}

.trump-ref-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.trump-ref-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.trump-ref-name {
  font-size: 0.98rem;
  font-weight: 700;
}

.trump-ref-desc {
  font-size: 0.82rem;
  opacity: 0.82;
  line-height: 1.35;
}

.trump-ref-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}

.trump-ref-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.trump-ref-tag--category {
  background: rgba(231, 196, 124, 0.28);
}

.trump-ref-tag--shop {
  background: rgba(162, 170, 255, 0.28);
}

.trump-ref-tag--plus {
  background: rgba(231, 196, 124, 0.4);
}

.trump-ref-tag--rare {
  background: rgba(146, 213, 150, 0.35);
}

.trump-ref-tag--target {
  background: rgba(231, 124, 183, 0.3);
}

/* ---------- Music chrome (css/style.css is not loaded here) ---------- */
.hv2-music {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
}

.music-mute-top {
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  line-height: 1;
  color: #fff;
  background: rgba(51, 43, 76, 0.85);
  border: 3px solid var(--hv2-border);
  border-radius: 12px;
  cursor: pointer;
}

.music-now-playing {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  background: rgba(51, 43, 76, 0.85);
  border: 3px solid var(--hv2-border);
  border-radius: 14px;
}

.music-np-thumb {
  width: 34px;
  height: 34px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.music-np-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.music-np-label {
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.65;
}

.music-np-title {
  font-size: 0.82rem;
  font-weight: 700;
}

.music-np-artist {
  font-size: 0.72rem;
  opacity: 0.75;
}

/* ---------- Mobile warning (markup injected by js/mobileWarning.js) ---------- */
.mobile-pc-warning {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 12, 28, 0.78);
}

.mobile-pc-warning__panel {
  width: min(380px, 100%);
  padding: 24px 22px;
  text-align: center;
  color: #fff;
  background: rgba(51, 43, 76, 0.96);
  border: 6px solid var(--hv2-border);
  border-radius: 24px;
}

.mobile-pc-warning__badge {
  font-size: 2.2rem;
  margin-bottom: 6px;
}

.mobile-pc-warning__title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.mobile-pc-warning__body,
.mobile-pc-warning__hint {
  font-size: 0.92rem;
  line-height: 1.45;
  opacity: 0.85;
  margin-bottom: 12px;
}

.mobile-pc-warning__btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  width: 100%;
  padding: 12px 18px;
  color: var(--hv2-ink);
  background: var(--hv2-accent);
  border: 4px solid var(--hv2-border);
  border-radius: 14px;
  cursor: pointer;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .music-now-playing {
    display: none;
  }
}

/* Phones: swap to *-mobile.svg art (taller touch targets) via <picture>.
   Keep Practice / Trumps side-by-side so row height stays near Create/Find/How. */
@media (max-width: 560px) {
  :root {
    --hv2-col: min(760px, 94vw, 70vh);
    --hv2-col: min(760px, 94vw, 70dvh);
  }

  .hv2-menu-row {
    flex-direction: row;
    gap: var(--hv2-row-gap);
  }
}

/*
 * Short/landscape screens: fitting the whole stack would shrink the buttons
 * past readable, so relax the height cap and trade logo size for scroll.
 */
@media (max-height: 560px) {
  :root {
    --hv2-col: min(760px, 92vw, 150vh);
  }

  .hv2-logo {
    width: min(calc(var(--hv2-col) * 0.672), 46vh);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hv2-menu-btn,
  .hv2-menu-btn:hover,
  .hv2-menu-btn:active,
  .hv2-menu-btn.is-pressed {
    transform: none;
    transition: none;
  }

  /* Keep brightness press feedback even when motion is reduced. */
  .hv2-menu-btn:active:not(:disabled):not([aria-disabled='true']),
  .hv2-menu-btn.is-pressed:not(:disabled):not([aria-disabled='true']) {
    filter: brightness(0.88);
  }

  .hv2-menu-btn.is-busy,
  .hv2-waiting-text {
    animation: none;
  }
}
