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

:root {
  --btn-offset: 120px;
  --icon-rotation: 0deg;
  --primary-light-hsl: 200, 100%, 91%;
  --primary-hsl: 200, 100%, 50%;
  --primary-dark-hsl: 200, 100%, 6%;
  --success-hsl: 100, 60%, 50%;
  --error-hsl: 0, 60%, 50%;
}

html,
body {
  height: 100%;
  overflow-y: auto;
  background-color: #000;
}

/* Testing for bg resize overscroll behavior added */
body {
  font-family: "Rubik", sans-serif;
  color: #111;
  min-height: 100vh;
  background: #f4f6f8;
  /* overscroll-behavior: none; */
}

body.game-page {
  background: none;
  min-height: 100%;
  padding: 2rem 0;
}

body.game-page::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("../images/old_town_blur.jpg") center / cover no-repeat;
  z-index: -2;
  transform: translateZ(0);
}

body.game-page::after {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  z-index: -1;
}

body.game-page .page-header {
  width: 100%;
  margin-bottom: 1.5rem;
  color: #ffffff;
  text-shadow: 0 0 16px rgba(0, 0, 0, 0.45);
}

body.game-page .page-header h1 {
  margin-bottom: 0.5rem;
  font-size: clamp(2rem, 3vw, 3.5rem);
}

body.game-page .page-header p {
  font-size: 1rem;
  max-width: 800px;
}

body.game-page .hello-words-container {
  display: grid;
  gap: 0.75rem;
  margin: 0.25rem auto;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0.75rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.1);
  padding: 0.5rem;
}

body.game-page .hello-words-top-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

body.game-page .hello-words-top-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

body.game-page .game-info-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

body.game-page .hello-words-status-group {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

body.game-page .hello-words-status {
  font-size: 1rem;
  font-weight: 600;
  color: white;
  white-space: nowrap;
}

body.game-page .hello-words-board-panel {
  display: grid;
  gap: 0.75rem;
  justify-items: center;
}

body.game-page .hello-words-board,
body.game-page .hello-words-tile-bar {
  display: grid;
  width: min(70vw, 62vh);
  max-width: min(70vw, 62vh);
  justify-self: center;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.15rem;
  padding: 0.45rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 0.75rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

body.game-page .hello-words-block,
body.game-page .hello-words-tile {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  background: rgba(239, 239, 239, 0.3);
  user-select: none;
}

body.game-page .hello-words-tile {
  cursor: grab;
  font-weight: 700;
  font-size: 1.4rem;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg, #fff7b8 0%, #f7d76c 100%);
  color: #0f172a;
  border-radius: 0.5rem;
}

body.game-page .hello-words-tile.dragging {
  opacity: 0.65;
  /* transform: translate(-30px, -30px); */
}

.hello-words-tile.mobile-dragging {
  opacity: 0.65;
  transform: translate(-30px, -30px);
}

.ghost {
  position: fixed;
  pointer-events: none;
  opacity: 0.7;
  transform: translate(-50%, -50%);
  z-index: 1000;
}

.hello-words-feedback {
  padding: 0.5rem 0.5rem;
  border-radius: 0.5rem;
  background: rgba(236, 246, 255, 0.95);
  border: 1px solid rgba(14, 165, 233, 0.18);
  color: #0f172a;
  font-size: 1rem;
  min-height: 2.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.feedback-text {
  margin: 0;
  flex: 1;
}

body.game-page .game-info-button {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  padding: 0;
  background: hsl(var(--primary-hsl));
  color: white;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.game-page .hello-words-feedback.error {
  background: rgba(254, 226, 226, 0.95);
  border-color: rgba(248, 113, 113, 0.25);
  color: hsl(var(--error-hsl));
}

body.game-page .hello-words-feedback.success {
  background: rgba(220, 252, 231, 0.95);
  border-color: rgba(34, 197, 94, 0.25);
  color: hsl(var(--success-hsl));
}

body.game-page .game-instructions-panel {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(15, 23, 42, 0.65);
  z-index: 60;
  padding: 1.5rem;
}

body.game-page .game-instructions-panel.show-instructions {
  display: grid;
}

body.game-page .instructions-content {
  max-width: 520px;
  width: 100%;
  background: white;
  padding: 2rem;
  border-radius: 1rem;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.18);
  position: relative;
}

body.game-page .instructions-content h2 {
  margin-top: 0;
  margin-bottom: 1rem;
}

body.game-page .instructions-content ul {
  margin: 1rem 0 0;
  padding-left: 1.25rem;
}

body.game-page .instructions-content li {
  margin-bottom: 0.75rem;
}

.instructions-content {
  max-height: 80vh;
  overflow-y: auto;
}

.instruction-card {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.instruction-card video {
  width: 50%;
  max-width: 320px;
  border-radius: 8px;
  display: block;
}

.instruction-text {
  flex: 1;
}

.instruction-card h3 {
  margin: 0 0 0.25rem;
}

.instruction-card p {
  margin: 0;
}

body.game-page button {
  padding: 0.5rem 0.5rem;
  background: hsl(var(--primary-hsl));
  color: white;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1rem;
  font-weight: bold;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(14, 165, 233, 0.16);
  margin-top: 0.5rem;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

body.game-page button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 35px rgba(59, 130, 246, 0.25);
}

/* =========================
   GAME OVER OVERLAY
========================= */
body.game-page .game-over-window {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.82);
  z-index: 1000;
  padding: 1rem;
  width: 100vw;
  height: 100dvh;
}

body.game-page .hide-game-over {
  display: none;
}

/* =========================
   GAME OVER MAIN CARD
========================= */
body.game-page .game-over-content {
  position: relative;
  width: min(80vw, 460px);
  background: #ffffff;
  border-radius: 1.25rem;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.35);
  animation: gameOverPop 0.2s ease-out;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Title */
body.game-page .game-over-content h2 {
  font-size: 2rem;
  margin: 0;
  color: #0f172a;
}

/* =========================
   GAME OVER SUMMARY LINE
   "You scored X points!"
========================= */
.game-over-summary {
  font-size: 1.25rem;
  color: #0f172a;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: baseline;
}

.game-over-summary .game-over-score {
  font-size: 1.8rem;
  font-weight: 800;
  color: hsl(var(--primary-hsl));
}

/* =========================
   GAME OVER TIME
========================= */
body.game-page .game-time {
  font-size: 1.1rem;
  color: hsl(var(--primary-hsl));
}

/* =========================
   GAME OVER STATS SECTION
========================= */
.game-over-stats {
  background: #b5b5b5;
  border-radius: 0.75rem;
  border: black 2px solid;
  margin-top: 1rem;
  text-align: left;
  padding: 0.5rem;
  line-height: 1.5;
}

.game-stat {
  background: #f1f5f9;
  border-radius: 0.75rem;
  padding: 0.75rem;
  text-align: center;
}

.game-stat-label {
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 0.25rem;
}

.game-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
}

/* =========================
   GAME OVER SCORING GUIDE
========================= */
/* .scoring-guide {
  background: #f1f5f9;
  border-radius: 0.75rem;
  border: black 2px solid;
  margin-top: 1rem;
  text-align: left;
  padding: 0.5rem;
} */

.game-over-title {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: #0f172a;
  text-align: center;
}

.scoring-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  padding: 0.25rem 0;
  color: #334155;
}

/* Stars */
.stars {
  letter-spacing: 2px;
  color: #f59e0b;
  font-size: 1rem;
}

/* =========================
   GAME OVER BUTTON
========================= */
.close-game-over-div {
  display: flex;
  justify-content: end;
}

body.game-page #close-game-over {
  position: absolute;
  top: 1rem;
  right: 1rem;
  border: none;
  background: rgba(15, 23, 42, 0.08);
  border-radius: 25%;
  cursor: pointer;
  color: black;
  margin-top: 0;
  aspect-ratio: 1 / 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.game-page .close-instructions-button {
  position: absolute;
  top: 1rem;
  right: 1rem;
  border: none;
  background: rgba(15, 23, 42, 0.08);
  border-radius: 25%;
  cursor: pointer;
  color: black;
  margin-top: 0;
  aspect-ratio: 1 / 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.game-page #close-game-over:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

/* =========================
   GAME OVER ANIMATION
========================= */
@keyframes gameOverPop {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

body.game-page .bonus {
  background: hsl(var(--success-hsl));
}

body.game-page .disconnected {
  background: rgba(150, 150, 150, 0.5);
  border-color: rgba(25, 25, 25, 0.5);
}

body.game-page .invalid-group {
  background: rgba(150, 150, 150, 0.5);
  border-color: rgba(25, 25, 25, 0.5);
}

body.game-page .spelling {
  background: rgba(255, 0, 0, 0.5);
  border-color: rgba(25, 25, 25, 0.5);
}

@media (max-width: 960px) {
  body.game-page {
    padding: 1rem;
  }

  body.game-page .hello-words-board,
  body.game-page .hello-words-tile-bar {
    width: min(86vw, 58vh);
    max-width: min(86vw, 58vh);
    grid-template-columns: repeat(7, minmax(0, 1fr));
    padding: 0.15rem;
  }
}

.stat-game-id {
  font-size: 0.65rem;
  color: black;
  margin-left: 2rem;
}

.hello-words-lower-actions {
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
}

.new-game-text {
  font-size: 0.9rem;
  color: #64748b;
}

.earned-stars {
  letter-spacing: 2px;
  color: #f59e0b;
  font-size: 1.5rem;
}

.trash-can {
  width: 64px;
  height: 64px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 12px;
  transition: all 0.2s ease;
  position: relative;
  z-index: 9999;
}

.trash-can img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.trash-can.drag-over {
  transform: scale(1.15);
  filter: brightness(1.15);
}
