@import url("https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap");

:root {
  --rc-green-950: #0c2e27;
  --rc-green-900: #123d32;
  --rc-green-800: #18503f;
  --rc-green-700: #21664f;
  --rc-green-600: #2d7a5e;
  --rc-green-100: #dff0e7;
  --rc-green-50: #eef7f2;
  --rc-gold-700: #9c742a;
  --rc-gold-600: #b98b34;
  --rc-gold-500: #d1a347;
  --rc-gold-300: #ead19a;
  --rc-gold-100: #f8edcf;
  --rc-cream: #fbfaf6;
  --rc-paper: #ffffff;
  --rc-ink: #1e2b27;
  --rc-muted: #65736e;
  --rc-line: #dfe7e2;
  --rc-danger: #a33b34;
  --rc-shadow: 0 20px 50px rgba(18, 61, 50, 0.09);
  --rc-shadow-soft: 0 10px 30px rgba(18, 61, 50, 0.07);
  --flip-duration: 0.4s;
  --card-gap: 12px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--rc-cream);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 6%, rgba(223, 240, 231, .92), transparent 30rem),
    radial-gradient(circle at 94% 18%, rgba(248, 237, 207, .78), transparent 28rem),
    var(--rc-cream);
  color: var(--rc-ink);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
select {
  font: inherit;
}

button,
select,
.memory-card {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
select:focus-visible,
.memory-card:focus-visible {
  outline: 3px solid rgba(209, 163, 71, .55);
  outline-offset: 3px;
}

.site-shell {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
}

.game-site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(12, 46, 39, .97);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .08);
  backdrop-filter: blur(14px);
}

.header-inner {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand,
.footer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(255,255,255,.12), rgba(255,255,255,.03));
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .04em;
}

.brand-copy {
  display: grid;
  gap: 2px;
  line-height: 1.1;
}

.brand-copy strong {
  font-size: 17px;
  letter-spacing: -.015em;
}

.brand-copy small,
.header-kicker {
  color: rgba(255, 255, 255, .64);
}

.brand-copy small {
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.header-kicker {
  font-size: 13px;
}

.game-page {
  padding: 48px 0 64px;
}

.game-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 36px;
  padding: 34px 38px;
  border: 1px solid rgba(33, 102, 79, .12);
  border-radius: 28px;
  background: linear-gradient(120deg, rgba(223, 240, 231, .88), rgba(248, 237, 207, .72));
  box-shadow: var(--rc-shadow-soft);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--rc-green-700);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.eyebrow::before {
  width: 22px;
  height: 2px;
  border-radius: 999px;
  background: var(--rc-gold-500);
  content: "";
}

.game-hero h1 {
  margin: 8px 0 8px;
  color: var(--rc-green-950);
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1;
  letter-spacing: -.04em;
}

.game-hero p {
  max-width: 740px;
  margin: 0;
  color: var(--rc-muted);
  font-size: 16px;
}

.hero-symbol {
  width: 108px;
  height: 108px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(185, 139, 52, .2);
  border-radius: 30px;
  background: rgba(255, 255, 255, .76);
  box-shadow: var(--rc-shadow-soft);
}

.hero-symbol span {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: var(--rc-green-900);
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 42px;
  font-weight: 700;
}

.game-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1.05fr) minmax(300px, 1.15fr) minmax(260px, .9fr);
  align-items: end;
  gap: 18px;
  margin-top: 22px;
  padding: 22px;
  border: 1px solid var(--rc-line);
  border-radius: 22px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--rc-shadow-soft);
}

.control-group {
  min-width: 0;
}

.control-group label,
.control-label {
  display: block;
  margin-bottom: 7px;
  color: var(--rc-green-950);
  font-size: 13px;
  font-weight: 800;
}

.control-group small {
  display: block;
  margin-top: 6px;
  color: var(--rc-muted);
  font-size: 12px;
}

#nivelSelect {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cad9d1;
  border-radius: 12px;
  background: #fff;
  color: var(--rc-ink);
  padding: 0 38px 0 13px;
  transition: border-color .18s ease, box-shadow .18s ease;
}

#nivelSelect:hover,
#nivelSelect:focus {
  border-color: var(--rc-green-600);
  box-shadow: 0 0 0 4px rgba(45, 122, 94, .09);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.game-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 750;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
}

.game-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.game-button:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.game-button-primary {
  background: var(--rc-green-700);
  color: #fff;
  box-shadow: 0 8px 20px rgba(33, 102, 79, .18);
}

.game-button-primary:hover:not(:disabled) {
  background: var(--rc-green-800);
}

.game-button-secondary {
  border-color: var(--rc-gold-300);
  background: var(--rc-gold-100);
  color: #6f511b;
}

.game-button-secondary:hover:not(:disabled) {
  background: #f3e3b9;
}

.game-button-ghost {
  border-color: #d7dfdb;
  background: #fff;
  color: var(--rc-muted);
}

.game-button-ghost:hover:not(:disabled) {
  border-color: #b9c7c0;
  color: var(--rc-green-900);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  min-height: 74px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 11px 14px;
  border: 1px solid var(--rc-line);
  border-radius: 14px;
  background: var(--rc-green-50);
}

.stat-card span {
  color: var(--rc-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.stat-card strong {
  color: var(--rc-green-950);
  font-size: 24px;
  line-height: 1.15;
}

.stat-card strong small {
  color: var(--rc-muted);
  font-size: 12px;
}

.play-area {
  margin-top: 22px;
  padding: 26px;
  border: 1px solid var(--rc-line);
  border-radius: 24px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--rc-shadow);
}

.play-area-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 16px;
}

.play-area-header h2 {
  margin: 4px 0 0;
  color: var(--rc-green-950);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
  letter-spacing: -.025em;
}

.play-area-header p {
  margin: 0;
  color: var(--rc-muted);
  font-size: 13px;
}

.level-heading-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.level-badge {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  border-radius: 999px;
  background: var(--rc-gold-100);
  color: var(--rc-gold-700);
  padding: 0 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
}

.level-badge[hidden] {
  display: none;
}

.messages:empty {
  display: none;
}

.messages {
  margin-bottom: 18px;
}

.msg,
.alert {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--rc-line);
  border-radius: 14px;
  font-size: 13px;
}

.msg-info {
  background: var(--rc-green-50);
  color: var(--rc-green-800);
  border-color: var(--rc-green-100);
}

.msg-ok {
  background: #edf8f0;
  color: #21613c;
  border-color: #cce7d5;
}

.msg-err {
  background: #fff2f0;
  color: #8a3731;
  border-color: #f0cbc7;
}

.alert-warning {
  margin-top: 10px;
  background: #fff8e8;
  color: #785a20;
  border-color: #f0deb1;
}

.messages h2 {
  margin: 0;
  color: var(--rc-green-950);
  font-size: 18px;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: var(--card-gap);
  max-width: 1120px;
  margin-inline: auto;
}

.memory-card {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  perspective: 1000px;
  border-radius: 18px;
  cursor: pointer;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform var(--flip-duration) cubic-bezier(.2,.75,.25,1);
}

.memory-card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 18px;
  backface-visibility: hidden;
  box-shadow: 0 10px 24px rgba(12, 46, 39, .13);
}

.card-front {
  display: grid;
  place-items: center;
  border: 1px solid rgba(33, 102, 79, .18);
  background:
    radial-gradient(circle at 72% 20%, rgba(248, 237, 207, .72), transparent 34%),
    linear-gradient(145deg, #f7fbf8, #e3f0e9);
  color: var(--rc-green-800);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(38px, 5vw, 62px);
  font-weight: 700;
  user-select: none;
}

.card-front::after {
  position: absolute;
  right: 10px;
  bottom: 9px;
  color: rgba(33, 102, 79, .28);
  content: "RC";
  font-family: Georgia, "Times New Roman", serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
}

.card-back {
  transform: rotateY(180deg);
  background: #fff;
  border: 1px solid rgba(33, 102, 79, .14);
}

.card-back img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.memory-card:not(.flipped):hover .card-inner {
  transform: translateY(-3px);
}

.memory-card.flipped:hover .card-inner {
  transform: rotateY(180deg) translateY(-3px);
}

.memory-card.matched {
  cursor: default;
  pointer-events: none;
}

.memory-card.matched .card-face {
  box-shadow: 0 0 0 3px rgba(209, 163, 71, .45), 0 10px 24px rgba(12, 46, 39, .13);
}

.btn-blink {
  animation: attention-pulse 1.15s ease-in-out infinite;
}

@keyframes attention-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(209, 163, 71, 0);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(209, 163, 71, .18);
  }
}

.game-site-footer {
  border-top: 1px solid rgba(255,255,255,.06);
  background: var(--rc-green-950);
  color: rgba(255,255,255,.68);
}

.footer-inner {
  min-height: 126px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  font-size: 12px;
}

.brand-mark-footer {
  width: 40px;
  height: 40px;
  flex-basis: 40px;
}

.footer-brand strong {
  display: block;
  color: #fff;
  font-size: 15px;
}

.footer-brand span:last-child {
  display: block;
  margin-top: 2px;
}

@media (max-width: 980px) {
  .game-panel {
    grid-template-columns: 1fr 1fr;
  }

  .stats {
    grid-column: 1 / -1;
  }

  .game-grid {
    grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  }
}

@media (max-width: 720px) {
  .site-shell {
    width: min(100% - 28px, 1180px);
  }

  .header-inner {
    min-height: 66px;
  }

  .header-kicker {
    display: none;
  }

  .game-page {
    padding: 22px 0 40px;
  }

  .game-hero {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 25px 22px;
    border-radius: 22px;
  }

  .game-hero p {
    font-size: 14px;
  }

  .hero-symbol {
    display: none;
  }

  .game-panel {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .stats {
    grid-column: auto;
  }

  .play-area {
    padding: 18px 14px;
    border-radius: 20px;
  }

  .play-area-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .game-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .card-face,
  .memory-card {
    border-radius: 13px;
  }

  .footer-inner {
    min-height: 148px;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
  }
}

@media (max-width: 430px) {
  .brand-mark {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  .brand-copy strong {
    font-size: 15px;
  }

  .game-hero h1 {
    font-size: 38px;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
  }

  .stat-card {
    padding: 10px;
  }

  .stat-card strong {
    font-size: 20px;
  }

  .button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .game-button:last-child {
    grid-column: 1 / -1;
  }

  .game-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

/* Modo de jogo em janela dedicada */
@keyframes close-button-pulse {
  0%, 100% {
    box-shadow: 0 8px 20px rgba(201, 54, 45, .22), 0 0 0 0 rgba(201, 54, 45, .22);
  }
  50% {
    box-shadow: 0 10px 24px rgba(201, 54, 45, .30), 0 0 0 6px rgba(201, 54, 45, .10);
  }
}

html.dedicated-game-window,
body.dedicated-game-window {
  min-height: 100%;
}
body.dedicated-game-window {
  min-height: 100dvh;
}
body.dedicated-game-window .game-site-header,
body.dedicated-game-window .game-site-footer {
  display: none !important;
}
body.dedicated-game-window .game-page {
  min-height: 100dvh;
  padding-top: 18px;
  padding-bottom: 28px;
}
body.dedicated-game-window .site-shell {
  width: min(1440px, calc(100% - 24px));
}
body.dedicated-game-window .game-hero {
  display: none !important;
}
body.dedicated-game-window .game-panel {
  margin-top: 0;
}
body.dedicated-game-window #closeBtn,
body.dedicated-game-window #btnFechar {
  border-color: #c9362d !important;
  background: #c9362d !important;
  color: #fff !important;
  animation: close-button-pulse 1.8s ease-in-out infinite;
}
body.dedicated-game-window #closeBtn:hover,
body.dedicated-game-window #btnFechar:hover {
  border-color: #a92d26 !important;
  background: #a92d26 !important;
  color: #fff !important;
}
