:root {
  --highlight: #3AA0FF;
  --highlight-dark: #1B4B81;
  --highlight-light: #A5D8FF;
  --foam: #F5FBFF;
  --surface: rgba(255, 255, 255, 0.92);
  --background: linear-gradient(180deg, #E6F4FF 0%, #F9FBFE 60%, #F2F6FF 100%);
  --text: #0B315A;
  --muted: #4F6682;
  --shadow: rgba(14, 54, 96, 0.18);
  --ark-wood: #B9824A;
  --ark-dark: #8D6233;
  --water: linear-gradient(120deg, rgba(58, 160, 255, 0.18), rgba(27, 75, 129, 0.2));
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: 'Quicksand', 'Inter', sans-serif;
  background: var(--background);
  color: var(--text);
  line-height: 1.6;
}

a {
  color: inherit;
}

a:hover,
a:focus {
  text-decoration: none;
}

.sky-ornaments {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.65);
  filter: blur(24px);
  border-radius: 50%;
}

.cloud--one {
  width: 220px;
  height: 120px;
  top: 40px;
  left: 10%;
}

.cloud--two {
  width: 180px;
  height: 100px;
  top: 120px;
  right: 8%;
}

.cloud--three {
  width: 260px;
  height: 140px;
  top: 260px;
  left: 18%;
}

.rainbow-accent {
  position: absolute;
  bottom: 12%;
  right: 15%;
  width: 340px;
  height: 160px;
  background: conic-gradient(from 120deg, rgba(58, 160, 255, 0) 0deg, rgba(58, 160, 255, 0.5) 160deg, rgba(255, 166, 83, 0.6) 260deg, rgba(58, 160, 255, 0) 360deg);
  filter: blur(42px);
  opacity: 0.6;
}

.app-header {
  position: relative;
  background: linear-gradient(145deg, rgba(58, 160, 255, 0.95) 0%, rgba(27, 75, 129, 0.95) 96%);
  color: #fff;
  padding: 1.6rem 1.25rem 0.6rem;
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: flex-start;
  z-index: 1;
  box-shadow: 0 20px 40px rgba(20, 63, 110, 0.24);
}

.app-header::before {
  content: '';
  position: absolute;
  inset: -40% -10% 40% -10%;
  background: radial-gradient(70% 50% at 50% 30%, rgba(245, 251, 255, 0.75), rgba(245, 251, 255, 0));
  opacity: 0.65;
}

.branding {
  flex: 1 1 260px;
  position: relative;
  z-index: 1;
}

.home-link {
  display: inline-block;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.85);
}

.home-link:hover,
.home-link:focus {
  color: #fff;
}

.branding h1 {
  margin: 0.25rem 0 0;
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tagline {
  margin: 0.45rem 0 0;
  font-size: clamp(0.85rem, 3vw, 1rem);
  color: rgba(255, 255, 255, 0.9);
  max-width: 42ch;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.difficulty-control {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.difficulty-label {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(13, 44, 79, 0.68);
  font-weight: 600;
}

.difficulty-segments {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.35rem;
  padding: 0.35rem;
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(245, 251, 255, 0.95), rgba(165, 216, 255, 0.85));
  box-shadow: 0 10px 24px rgba(11, 53, 94, 0.14);
}

.difficulty-option {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  padding: 0.55rem 0.85rem;
  text-align: left;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.difficulty-option__label {
  font-size: 1rem;
  color: var(--highlight-dark);
}

.difficulty-option__meta {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(13, 44, 79, 0.6);
}

.difficulty-option.is-active {
  background: linear-gradient(145deg, rgba(58, 160, 255, 0.18), rgba(27, 75, 129, 0.15));
  border-color: rgba(27, 75, 129, 0.35);
  box-shadow: 0 10px 20px rgba(27, 75, 129, 0.18);
}

.difficulty-option:focus-visible {
  outline: 3px solid var(--highlight);
  outline-offset: 3px;
}

.hud {
  display: flex;
  gap: 1.2rem;
  background: rgba(10, 46, 86, 0.35);
  border-radius: 18px;
  padding: 0.75rem 1.1rem;
  backdrop-filter: blur(8px);
}

.hud-block {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.hud-label {
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(245, 251, 255, 0.75);
}

.hud-value {
  font-size: 1.2rem;
  font-weight: 600;
  color: #fff;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: clamp(0.8rem, 2.4vw, 1.4rem);
  padding: clamp(0.35rem, 2vw, 1.2rem) clamp(1rem, 3vw, 2.5rem) 3rem;
  position: relative;
  z-index: 1;
}

.puzzle-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.2rem;
  max-width: 820px;
}

.meta-card {
  background: rgba(255, 255, 255, 0.82);
  border-radius: 18px;
  padding: 1.1rem 1.2rem;
  border: 1px solid rgba(165, 216, 255, 0.42);
  box-shadow: 0 18px 36px rgba(18, 65, 110, 0.16);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 96px;
}

.meta-card--accent {
  background: linear-gradient(140deg, rgba(58, 160, 255, 0.35), rgba(27, 75, 129, 0.35));
  border-color: rgba(27, 75, 129, 0.45);
  color: #fff;
}

.meta-card--accent .meta-label {
  color: rgba(245, 251, 255, 0.82);
}

.meta-card--accent .meta-value {
  color: rgba(255, 255, 255, 0.96);
}

.meta-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(13, 44, 79, 0.62);
  font-weight: 600;
}

.meta-value {
  font-size: 1.35rem;
  font-weight: 700;
}

.game-stage {
  display: grid;
  gap: 1.2rem;
  grid-template-columns: 1fr;
  align-items: start;
  max-width: 1080px;
}

.control-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(165, 216, 255, 0.45);
  border-radius: 22px;
  padding: 1rem 1.2rem;
  box-shadow: 0 18px 32px rgba(18, 65, 110, 0.16);
  max-width: 820px;
}

.control-panel .difficulty-control {
  min-width: 200px;
}


.ark-frame {
  position: relative;
  padding: clamp(1.5rem, 3vw, 2.5rem);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 30px;
  border: 1px solid rgba(165, 216, 255, 0.45);
  box-shadow: 0 28px 48px rgba(18, 65, 110, 0.16);
}

.card-grid {
  --columns: 4;
  display: grid;
  gap: clamp(0.5rem, 2vw, 0.9rem);
  justify-content: center;
  justify-items: center;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  width: 100%;
}

.card {
  position: relative;
  border: 0;
  padding: 0;
  width: 100%;
  max-width: 120px;
  aspect-ratio: 3 / 4;
  border-radius: 18px;
  cursor: pointer;
  background: transparent;
  perspective: 900px;
  transition: transform 0.2s ease;
  container-type: inline-size;
}

.card:focus-visible {
  outline: 3px solid var(--highlight);
  outline-offset: 4px;
}

.card[disabled] {
  cursor: default;
}

.card-inner {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transform-style: preserve-3d;
  transition: transform 0.45s ease, box-shadow 0.35s ease;
  background: transparent;
  box-shadow: 0 12px 24px rgba(18, 65, 110, 0.16);
}

.card-face {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  padding: 0.65rem;
}

.card-face--front {
  background: linear-gradient(145deg, rgba(27, 75, 129, 0.12), rgba(58, 160, 255, 0.32));
  border: 2px solid rgba(27, 75, 129, 0.15);
}

.card-face--front::after {
  content: '⛵';
  font-size: clamp(2rem, 6vw, 3.2rem);
  opacity: 0.7;
  line-height: 1;
  display: block;
}

.card-face--back {
  background: linear-gradient(160deg, rgba(245, 251, 255, 0.95), rgba(165, 216, 255, 0.85));
  border: 2px solid rgba(27, 75, 129, 0.18);
  transform: rotateY(180deg);
  gap: 0;
}

.card-emoji {
  font-size: clamp(2rem, 6vw, 3.2rem);
  line-height: 1;
  display: block;
}

@supports (font-size: 1cqw) {
  .card-face--front::after,
  .card-emoji {
    font-size: clamp(2rem, 100cqw, 5rem);
  }
}

.card.is-flipped .card-inner,
.card.is-matched .card-inner {
  transform: rotateY(180deg);
}

.card.is-matched .card-inner {
  box-shadow: 0 18px 28px rgba(58, 160, 255, 0.25);
}

.card.is-matched .card-face--back {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.96), rgba(173, 232, 255, 0.85));
  border-color: rgba(58, 160, 255, 0.35);
}

.fact-panel {
  background: rgba(255, 255, 255, 0.88);
  border-radius: 24px;
  padding: 1.4rem 1.6rem;
  border: 1px solid rgba(165, 216, 255, 0.45);
  box-shadow: 0 20px 36px rgba(18, 65, 110, 0.14);
  max-width: 720px;
}

.fact-heading {
  margin: 0 0 0.6rem;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.fact-copy {
  margin: 0;
  font-size: 1rem;
  color: var(--text);
}

.action-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.action-row button {
  border: 0;
  border-radius: 16px;
  padding: 0.8rem 1.6rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.action-row button:disabled {
  cursor: default;
  opacity: 0.5;
}

.action-row .accent {
  background: linear-gradient(145deg, rgba(58, 160, 255, 0.9), rgba(27, 75, 129, 0.9));
  color: #fff;
  box-shadow: 0 18px 32px rgba(18, 65, 110, 0.24);
}

.action-row .secondary {
  background: rgba(255, 255, 255, 0.9);
  color: var(--highlight-dark);
  border: 1px solid rgba(27, 75, 129, 0.18);
  box-shadow: 0 12px 26px rgba(18, 65, 110, 0.14);
}

.action-row button:not(:disabled):hover,
.action-row button:not(:disabled):focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(18, 65, 110, 0.24);
}

.tip-deck {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
  max-width: 900px;
}

.tip-card {
  background: rgba(255, 255, 255, 0.84);
  border-radius: 20px;
  padding: 1.3rem 1.4rem;
  border: 1px solid rgba(165, 216, 255, 0.35);
  box-shadow: 0 18px 36px rgba(18, 65, 110, 0.14);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.tip-icon {
  font-size: 1.8rem;
}

.tip-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--highlight-dark);
}

.tip-copy {
  margin: 0;
  font-size: 0.98rem;
  color: var(--muted);
}

.app-footer {
  padding: 2rem 1.5rem 2.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

@media (max-width: 600px) {
  .control-panel {
    padding: 0.9rem 1rem;
  }
}

@media (max-width: 480px) {
  .card-grid {
    gap: 0.4rem;
  }

  .card {
    max-width: 72px;
  }

  .card-face {
    padding: 0.45rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
