@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700;800&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --gap: 6px;
  --cell: #a51a22;
  --cell-ink: #ffffff;
  --active: #d2ced3;
  --active-ink: #a51a22;
}

body {
  font-family: sans-serif;
  background:
    radial-gradient(circle at 15% 5%,  #0d2a4a 0%, transparent 50%),
    radial-gradient(circle at 85% 90%, #0a1e38 0%, transparent 42%),
    linear-gradient(140deg, #060f1e 0%, #04090f 100%);
  color: #fff;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(90vw, 700px);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(29, 93, 165, 0.28), transparent 65%);
  filter: blur(60px);
  pointer-events: none;
  z-index: 0;
}

/* Layout Único */
.layout-landscape {
  display: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
  width: min(100vw, 100vh);
  aspect-ratio: 1 / 1;
  padding: 10px;
  border-radius: 18px;
  background: rgba(14, 8, 12, 0.88);
  border: 1px solid rgba(20, 12, 17, 0.96);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  box-sizing: border-box;
}

.cell {
  background: linear-gradient(180deg, #aa1f2a 0%, #9a1720 56%, #8f141d 100%);
  --tile-border: 2px;
  border: var(--tile-border) solid #0f090d;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  user-select: none;
  color: var(--cell-ink);
  transition: background 0.2s, color 0.2s, transform 0.1s, box-shadow 0.2s;
}


.cell.selected {
  background: linear-gradient(180deg, #d7d2d8 0%, #cfcacf 100%);
  color: var(--active-ink);
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), inset 0 -8px 16px rgba(0, 0, 0, 0.07), 0 4px 0 rgba(5, 4, 7, 0.72);
}

.cell.flash {
  animation: flash-cell 0.4s linear;
}

@keyframes flash-cell {
  0% {
    background: #fff;
    opacity: 1;
  }

  100% {
    background: #fa2c3b;
    opacity: 1;
  }
}

.cell .number {
  position: absolute;
  top: 4px;
  left: 6px;
  color: rgba(90, 15, 22, 0.78);
  font-size: clamp(12px, 2vmin, 18px);
  font-weight: bold;
  transition: color 0.2s;
}

.cell.selected .number {
  color: #8d1721;
}

.cell .letter {
  color: var(--cell-ink);
  font-size: clamp(32px, 8vmin, 64px);
  font-weight: bold;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
  transition: color 0.2s;
}

.cell.selected .letter {
  color: var(--active-ink);
}

.status {
  width: 100vmin;
  margin-top: 8px;
  color: #fff;
  font-size: 24px;
  /* tamanho fixo conforme pedido */
  padding: 12px;
}

.status .status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.status .counter {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, opacity 0.2s;
  margin-bottom: 8px;
}

.btn-icon:hover {
  opacity: 0.7;
  transform: scale(1.1);
}

.btn-icon:active {
  transform: scale(0.95);
}

.timer {
  font-size: 24px;
  font-weight: bold;
  color: #fff;
  min-width: 60px;
  text-align: right;
  margin-bottom: 8px;
}

.status .status-title,
#open-words-modal {
  font-weight: 700;
  margin-right: 8px;
  font-size: 24px;
  text-decoration: none !important;
  /* sem decoração */
  color: #fff;
}

.status .counter span {
  font-size: 24px;
}

.status .sep {
  margin: 0 12px;
}

.game-word-live {
  width: 100%;
  text-align: left;
  font-size: 0.82rem;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  line-height: 1.3;
}

.game-word-live strong {
  color: #fff;
}

.game-word-live .modal-open-button {
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}

/* Lista antiga removida em favor do modal */

/* Landscape Layout */
@media (orientation: landscape) {
  .layout-landscape {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0;
    align-items: center;
    width: 100%;
    height: 100vh;
  }


  .landscape-container-1 {
    grid-column: 1;
  }

  .landscape-container-2 {
    grid-column: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
  }

  .landscape-container-3 {
    grid-column: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    height: 100vh;
  }

  /* Contador com 32px, timer e botão com 64px */
  .landscape-container-3 .counter-landscape {
    order: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 6px;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .landscape-container-3 .counter-landscape .game-word-live {
    margin: 0;
  }

  .landscape-container-3 .timer-landscape {
    order: 2;
    font-size: 64px;
    text-align: center;
    margin: auto 0;
  }

  .landscape-container-3 .btn-icon {
    order: 3;
  }

  .landscape-container-3 .btn-icon svg {
    width: 64px;
    height: 64px;
  }
}

/* Portrait Layout */
@media (orientation: portrait) {
  .layout-landscape {
    display: grid;
    grid-template-rows: 1fr auto 1fr;
    gap: 0;
    width: 100%;
    height: 100vh;
  }

  .landscape-container-1 {
    grid-row: 1;
  }

  .landscape-container-2 {
    grid-row: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
  }

  .landscape-container-3 {
    grid-row: 3;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    gap: 16px;
    z-index: 100;
    position: relative;
  }

  /* Elementos reorganizados para portrait */
  .landscape-container-3 .counter-landscape {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 6px;
    order: 2;
  }

  .landscape-container-3 .counter-landscape .game-word-live {
    margin: 0;
  }

  .landscape-container-3 .timer-landscape {
    font-size: 24px;
    font-weight: bold;
    text-align: right;
    order: 3;
  }

  .landscape-container-3 .btn-icon {
    display: flex;
    pointer-events: auto;
    cursor: pointer;
    z-index: 101;
    order: 1;
  }

  .landscape-container-3 .btn-icon svg {
    width: 24px;
    height: 24px;
  }
}

/* Utility classes locais (equivalentes ao usado nas telas) */
.btn {
  display: inline-block;
  width: 100%;
  padding: 14px 20px;
  border-radius: 12px;
  font-weight: 700;
  color: #fff;
  text-align: center;
  text-decoration: none;
}

.btn-link {
  width: auto;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: #fff;
  text-align: left;
  font-weight: inherit;
  cursor: pointer;
}

.text-decoration-none {
  text-decoration: none;
}

.text-center {
  text-align: center;
}

.text-secondary {
  color: #aaa;
}

.fw-bold {
  font-weight: 700;
}

.p-0 {
  padding: 0;
}

.m-0 {
  margin: 0;
}

.mb-3 {
  margin-bottom: 1rem;
}

.w-auto {
  width: auto;
}

.d-grid {
  display: grid;
}

.d-flex {
  display: flex;
}

.vstack {
  display: flex;
  flex-direction: column;
}

.flex-column {
  flex-direction: column;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-3 {
  gap: 1rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  margin: -0.5rem;
}

.row > [class*="col-"] {
  padding: 0.5rem;
}

.g-3 {
  margin: -0.5rem;
}

.g-3 > [class*="col-"] {
  padding: 0.5rem;
}

.col-12 {
  flex: 0 0 100%;
  max-width: 100%;
}

@media (min-width: 768px) {
  .col-md-6 {
    flex: 0 0 50%;
    max-width: 50%;
  }
}

.form-check {
  display: flex;
  align-items: center;
}

.form-switch .form-check-input {
  width: 44px;
  height: 24px;
  appearance: none;
  background: #2b2b2b;
  border: 1px solid #444;
  border-radius: 999px;
  position: relative;
}

.form-switch .form-check-input::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
}

.form-switch .form-check-input:checked {
  background: #ff0000;
  border-color: #ff0000;
}

.form-switch .form-check-input:checked::before {
  transform: translateX(20px);
}

.form-check-input:disabled {
  opacity: 0.8;
  cursor: not-allowed;
}

.form-select {
  min-width: 120px;
  padding: 8px 32px 8px 12px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #151515;
  color: #fff;
}

.modal-open-button {
  border: none;
  background: transparent;
  cursor: pointer;
  color: inherit;
  padding: 0;
  margin: 0;
}

/* Modal local: visual equivalente ao fullscreen escuro */
.local-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: stretch;
  justify-content: stretch;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
}

.local-modal.is-open {
  display: flex;
}

.local-modal-dialog {
  width: 100%;
  height: 100%;
}

.local-modal-content {
  width: 100%;
  height: 100%;
  background-color: #000;
  color: #fff;
  display: flex;
  flex-direction: column;
}

.local-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
}

.local-modal-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
}

.local-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  position: relative;
  cursor: pointer;
}

.local-modal-close::before,
.local-modal-close::after {
  content: "";
  position: absolute;
  top: 15px;
  left: 6px;
  width: 20px;
  height: 2px;
  background: #fff;
}

.local-modal-close::before {
  transform: rotate(45deg);
}

.local-modal-close::after {
  transform: rotate(-45deg);
}

#words-modal-list div {
  font-size: 24px;
  line-height: 1.25;
}

.modal-title {
  font-size: 24px;
}

/* Ajuste de gap em telas muito estreitas */
@media (max-width: 420px) {
  :root {
    --gap: 3px;
  }
}

/* Home (index) styles, scoped to avoid conflicts with game styles */
.home-page {
  font-family: 'Sora', sans-serif;
  background: radial-gradient(circle at 20% 0%, #12243c 0%, transparent 48%),
    radial-gradient(circle at 85% 10%, #2b1d14 0%, transparent 36%),
    linear-gradient(140deg, #080d14 0%, #060910 100%);
  color: #eef3f8;
  min-height: 100vh;
  overflow: hidden;
}

.home-page .bg-scene {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 100%;
}

.home-page .bg-scene::before {
  content: '';
  position: absolute;
  width: min(72vw, 720px);
  aspect-ratio: 1 / 1;
  border-radius: 32px;
  background: linear-gradient(145deg, rgba(255, 59, 48, 0.2), rgba(0, 0, 0, 0.1));
  filter: blur(8px);
}

.home-page .board-wrap {
  position: relative;
  z-index: 2;
  width: min(76vw, 620px);
  transform: perspective(1100px) rotateX(7deg) rotateZ(-7deg);
  transform-style: preserve-3d;
  opacity: 0.9;
}

.home-page .home-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(56px, 1fr));
  gap: 10px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(14, 8, 12, 0.88);
  border: 1px solid rgba(20, 12, 17, 0.96);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.home-page .home-grid .cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  border: 2px solid #0f090d;
  background: linear-gradient(180deg, #aa1f2a 0%, #9a1720 56%, #8f141d 100%);
  color: var(--cell-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
}

.home-page .home-grid .cell .number {
  position: absolute;
  top: 5px;
  left: 7px;
  font-size: 0.68rem;
  font-weight: 700;
  color: rgba(90, 15, 22, 0.78);
  opacity: 1;
}

.home-page .home-grid .cell .letter {
  font-size: clamp(1.35rem, 2.9vw, 2.6rem);
  font-weight: 800;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

.home-page .home-grid .cell.is-active {
  background: #ffffff !important;
  color: #a51a22 !important;
  transform: translateZ(0) translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), inset 0 -8px 16px rgba(0, 0, 0, 0.07), 0 4px 0 rgba(5, 4, 7, 0.72);
}

.home-page .home-grid .cell.is-active .letter {
  color: #a51a22 !important;
}

.home-page .home-grid .cell.is-found {
  animation: pulse-found 0.52s ease;
}

@keyframes pulse-found {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.08);
  }

  100% {
    transform: scale(1);
  }
}

.home-page .word-live {
  margin-top: 14px;
  text-align: center;
  font-size: 0.82rem;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
}

.home-page .word-live strong {
  color: #fff;
}

.home-page .page-content {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 24px;
}

.home-page .challenge-text {
  font-size: clamp(1.02rem, 2.1vw, 1.25rem);
  font-weight: 500;
  color: #eef3f8;
  text-shadow: 0 2px 14px rgba(6, 12, 21, 0.55);
  max-width: 52ch;
}

.home-page .cta-row {
  display: flex;
  justify-content: center;
  margin-top: 1.2em;
}

.home-page .btn {
  display: inline-flex;
  width: auto;
  align-items: center;
  justify-content: center;
  padding: 14px 22px;
  border-radius: 14px;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.home-page .btn.primary {
  background: linear-gradient(140deg, #ff5147, #ff2f2f);
  color: #fff;
  box-shadow: 0 15px 40px rgba(255, 47, 47, 0.25);
}

@media (max-width: 980px) {
  .home-page .bg-scene::before {
    width: min(92vw, 560px);
  }

  .home-page .board-wrap {
    width: min(88vw, 540px);
    transform: perspective(1000px) rotateX(6deg) rotateZ(-5deg);
    opacity: 0.92;
  }

  .home-page .page-content {
    gap: 12px;
    padding: 16px;
  }
}