:root {
  --tile-radius: 6px;
  --gap: 2px;
  --app-max-width: 720px;
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --btn-bg: #475569;
  --btn-text: white;
  --accent-blue: #3b82f6;
  --accent-yellow: #fbbf24;
  --accent-teal: #2dd4bf;
  --accent-orange: #f97316;
  --accent-purple: #8b5cf6;
  --accent-red: #e63946;
  --text-light: #e2e8f0;
  --vertical-offset: 210px;
  --side-left-width: 90px;
  --side-right-width: 110px;
  --row-hint-width: 1.25rem;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg-dark);
  font-family: 'Segoe UI', system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===================== BUTTONS ===================== */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border: none;
  cursor: pointer;
  min-width: 48px;
  min-height: 48px;
  color: #3f2e1e;                          /* dark brown for contrast */
  font-size: clamp(1rem, 2.5vh, 1.3rem);
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0) 55%),
    linear-gradient(145deg, #e8d5b5 0%, #d9c29a 100%);
  border-right: 1px solid rgba(139, 100, 60, 0.35);
  border-bottom: 1px solid rgba(139, 100, 60, 0.35);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    0 2px 4px rgba(0, 0, 0, 0.18);
  transition:
    background 0.2s,
    box-shadow 0.2s,
    transform 0.1s;
}

.btn:hover {
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 60%),
    linear-gradient(145deg, #f0e0c8 0%, #e2cda6 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.18),
    0 3px 5px rgba(0, 0, 0, 0.22);
}

.btn:active {
  transform: translateY(2px);
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 55%),
    linear-gradient(145deg, #d9c29a 0%, #cdb289 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.1),
    0 1px 2px rgba(0, 0, 0, 0.15);
  border-right-width: 1px;
  border-bottom-width: 1px;
  transition: transform 0.05s;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: inherit;   /* match the button's shape (circle, pill, etc.) */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='20' viewBox='0 0 80 20'%3E%3Cg fill='none' stroke='%23804a1a' stroke-width='0.8' opacity='0.35'%3E%3Cpath d='M0 5 Q10 0,20 5 T40 5 T60 5 T80 5'/%3E%3Cpath d='M0 15 Q10 10,20 15 T40 15 T60 15 T80 15'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 80px 20px;
  pointer-events: none;
  opacity: 0.25;   /* overall layer opacity, adjust as needed */
  mix-blend-mode: multiply;   /* blends the wavy lines nicely */
}

/* Circular icon button */
.btn-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

/* Pill button (icon + label) */
.btn-pill {
  width: auto;
  height: auto;
  padding: 8px 16px;
  border-radius: 20px;
  gap: 6px;
  white-space: normal;
  word-break: break-word;
  max-width: 160px;
  font-size: clamp(1.1rem, 2.5vh, 1.4rem);
}

/* Tab button (clipboard) */
.btn-tab {
  width: auto;
  height: 48px;
  padding: 6px 10px;
  border-radius: 20px 0 0 20px;
  font-size: clamp(1.1rem, 2.5vh, 1.4rem);
}

/* Square button (profile) */
.btn-square {
  width: clamp(64px, 10vh, 84px);
  height: clamp(64px, 10vh, 84px);
  border-radius: 12px;
  font-size: clamp(1.8rem, 5vh, 2.4rem);
}

/* Journal label/icon */
.journal-icon {
  font-size: 1em;
  line-height: 1;
}

.journal-label {
  font-weight: 600;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

/* ===================== MENU SCREEN ===================== */
.menu-screen {
  width: 100%;
  max-width: var(--app-max-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
}

/* Header (top row) */
.menu-header {
  width: 100%;
  display: flex;
  align-items: flex-start;      /* top alignment */
  z-index: 2;
}

.header-side {
  flex: 1;
  display: flex;
}

.header-left {
  justify-content: flex-start;
}

.header-right {
  justify-content: flex-end;
}

.header-center {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
}

.header-spacer-left,
.header-spacer-right {
  /* These are empty and automatically sized by the grid */
}

/* Content (title area) */
.menu-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;   /* title starts near top */
  padding-top: 10vh;             /* adjust to taste */
  text-align: center;
}

.menu-title {
  font-size: clamp(2rem, 6vh, 3rem);
  font-weight: 800;
  color: var(--accent-teal);
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  margin: 0;
  letter-spacing: 2px;
}

.menu-subtitle {
  color: var(--text-light);
  font-size: 1rem;
  margin: 0;
  opacity: 0.8;
}

/* Nav buttons (bottom aligned) */
.menu-nav {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: auto;              /* pushes buttons to bottom */
}

.menu-play-btn {
  width: 100%;
  padding: 16px 20px;
  font-size: 1.4rem;
  font-weight: 700;
  border: none;
  border-radius: 50px;
  background: var(--accent-blue);
  color: white;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(59,130,246,0.4);
  transition: transform 0.2s, background 0.2s;
}
.menu-play-btn:hover { background: #2563eb; transform: scale(1.05); }

.menu-daily-btn {
  width: 100%;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  border: 2px dashed #475569;
  border-radius: 50px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.menu-daily-btn:hover { background: #334155; color: white; }

.coming-soon {
  font-size: 0.7rem;
  background: #475569;
  color: #cbd5e1;
  padding: 2px 8px;
  border-radius: 12px;
  margin-left: 8px;
}

/* Footer (reserved) */
.menu-footer {
  height: 20px;                  /* adjust as needed later */
}

/* ======================================================= */
/* ===================== GAME SCREEN ===================== */
/* ======================================================= */

.game-screen {
  width: 100%;
  max-width: var(--app-max-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;   /* top bar top, ad banner bottom */
  padding: 10px 0;
}

.game-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  gap: 8px;
}

.game-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: min(100%, calc(100vh - var(--vertical-offset)));
  gap: 8px;
}

/* Top bar */
.top-bar {
  width: min(100%, calc(100vh - var(--vertical-offset)));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 6px;
  padding: 0 calc(var(--row-hint-width) + var(--gap));
  margin-bottom: 6px;
}

.top-bar-left {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 6px;
}

.top-bar-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.top-bar-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}

/* Game header (level/moves) */
.game-header {
  display: grid;
  grid-template-columns: var(--row-hint-width) 1fr var(--row-hint-width);
  gap: var(--gap);
  width: 100%;
  margin-bottom: 6px;
}

.clipboard-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.cheat-sheet {
  flex: 1 1 auto;
  min-width: 0;
  background: rgba(255, 255, 255, 0.5);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  max-height: 50px;
  margin-left: 1.5rem;
  margin-right: 1rem;
  overflow: hidden;
}

.cheat-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: auto;
  padding: 8px 10px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: var(--text-light);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
}

.cheat-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.5rem;
  width: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 3px;   /* slight rounding, mimics tile */
  background: rgba(0, 0, 0, 0.1);
}

.cheat-tile svg {
  width: 83%;
  height: 83%;
  display: block;
}

.game-header-content {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  color: var(--text-light);
  font-size: clamp(0.9rem, 2.5vh, 1.1rem);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.header-level {
  justify-self: start;
  text-align: left;
}

.header-moves {
  justify-self: end;
  text-align: right;
}

.set-title {
  grid-column: 2;
  text-align: center;
  margin: 0;
  font-size: clamp(1.2rem, 3vh, 1.6rem);
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--accent-teal);
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  pointer-events: none;
}

#level-display { color: var(--accent-orange); margin-left: 4px; }
#moves-count { color: var(--accent-yellow); margin-left: 4px; }

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);   /* <-- ADD THIS */
  gap: var(--gap);
  width: 100%;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
}

.grid-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.grid-row-wrapper {
  display: grid;
  grid-template-columns: var(--row-hint-width) 1fr var(--row-hint-width);
  gap: var(--gap);
  align-items: stretch;
}

.col-hint-wrapper {
  display: grid;
  grid-template-columns: var(--row-hint-width) 1fr var(--row-hint-width);
  gap: var(--gap);
  align-items: start;
}

.col-hint-wrapper.hidden {
  display: none;
}

.row-hint-panel {
  display: grid;
  grid-template-rows: repeat(10, 1fr);
  gap: var(--gap);
}

.row-hint-spacer {
  /* empty spacer, same width as row-hint-panel */
}

/* Column hint panel (existing) – now inside middle column */
.row-col-hint {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: var(--gap);
  width: 100%;
}

.count-value {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-red);
  background: transparent;
  border-radius: 4px;
  padding: 4px 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* hints row */
.hints-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 0;
}

/* grid tiles */
.tile {
  aspect-ratio: 1 / 1;
  perspective: 800px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: transform 0.1s;
}

.tile:active {
  transform: scale(0.96);
  transition: transform 0.08s;
}

.tile-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.tile.flipped .tile-inner {
  animation: tile-flip 0.5s cubic-bezier(0.34, 1.1, 0.64, 1) forwards;
}

@keyframes tile-flip {
  0% {
    transform: rotateY(0deg) translateY(0) scale(1);
  }
  35% {
    transform: rotateY(95deg) translateY(-2px) scale(1.02);
  }
  70% {
    transform: rotateY(180deg) translateY(0) scale(0.99);
  }
  100% {
    transform: rotateY(180deg) translateY(0) scale(1);
  }
}

.tile-face {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: var(--tile-radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

.tile-front {
  background:
    repeating-linear-gradient(
      90deg,
      rgba(139, 69, 19, 0.08) 0px,
      rgba(139, 69, 19, 0.08) 1px,
      transparent 1px,
      transparent 4px
    ),
    linear-gradient(145deg, #f5deb3 0%, #deb887 100%);
  border-right: 4px solid rgba(139, 69, 19, 0.45);
  border-bottom: 4px solid rgba(139, 69, 19, 0.45);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.tile-back {
  background:
    linear-gradient(145deg, #f5deb3 0%, #deb887 100%);
  border-right: 4px solid rgba(139, 69, 19, 0.45);
  border-bottom: 4px solid rgba(139, 69, 19, 0.45);
  transform: rotateY(180deg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.x-icon {
  position: relative;
  width: 80%;
  height: 80%;
}
.x-icon::before,
.x-icon::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 3px;
  background: #7b3f00;
  border-radius: 2px;
}
.x-icon::before { transform: translate(-50%, -50%) rotate(45deg); }
.x-icon::after { transform: translate(-50%, -50%) rotate(-45deg); }

.flag-icon {
  font-size: clamp(1rem, 2.5vh, 1.5rem);
  line-height: 1;
}

@keyframes pop {
  0% { transform: scale(0) rotate(-20deg); opacity: 0; }
  50% { transform: scale(1.6) rotate(10deg); opacity: 1; }
  70% { transform: scale(0.9) rotate(-2deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.tile-back.revealed .flag-icon { display: none; }
.tile-back.revealed .icon {
  animation: pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* hints buttons */
.icon-btn {
  width: clamp(44px, 8vh, 52px);
  height: clamp(44px, 8vh, 52px);
  min-width: 44px;
  min-height: 44px;
  aspect-ratio: 1 / 1;
  border: none;
  border-radius: 50%;
  background: var(--bg-card);
  color: white;
  font-size: clamp(1rem, 2.5vh, 1.4rem);
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  transition: transform 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.icon-btn:hover { transform: translateY(-2px); background: #334155; }
.icon-btn:active { transform: translateY(0); }
.icon-btn.disabled {
  opacity: 0.45;
  filter: grayscale(0.5);
  /* pointer-events: none;  <-- remove this line */
}

#add-moves-btn { background: var(--accent-yellow); color: #0f172a; }
#add-moves-btn:hover { background: #f59e0b; }

.hint-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--accent-red);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Ad banner */
.ad-banner {
  width: 100%;
  height: 40px;
  background: #2d3b4f;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 0.8rem;
  letter-spacing: 1px;
  border: 1px dashed #475569;
  flex-shrink: 0;
}

/* Clipboard slide-out panel */
.clipboard-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(320px, 85vw);
  background: var(--bg-card);
  box-shadow: -4px 0 20px rgba(0,0,0,0.5);
  z-index: 90;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}
.clipboard-panel.open { transform: translateX(0); }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #475569;
}
.panel-header h2 { margin: 0; font-size: 1.2rem; color: var(--text-light); }

.close-panel-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}
.close-panel-btn:hover { color: white; }

.clipboard-list {
  list-style: none;
  margin: 0;
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.clipboard-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid #334155;
  color: var(--text-light);
  font-size: 1rem;
}
.clipboard-list li:last-child { border-bottom: none; }

.check-icon {
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 1.2rem;
}
.clipboard-list li.found .check-icon { opacity: 1; }

/* Modal styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: pointer;
}
.modal-overlay.hidden { display: none; }

.modal-content {
  background: var(--bg-card);
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
  color: white;
  max-width: 90%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  cursor: default;
}
#modal-message { font-size: 1.4rem; margin-bottom: 1rem; }

.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  margin-top: 1rem;
}

.modal-button {
  padding: 0.6rem 1.5rem;
  background: var(--accent-blue);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  transition: background 0.2s;
  width: 100%;
  max-width: 250px;
}
.modal-button:hover { background: #2563eb; }
.modal-button.secondary { background: #475569; }
.modal-button.secondary:hover { background: #64748b; }

.play-icon { margin-right: 6px; }

/* ======================================================= */
/* ============ OCEAN "SET" BACKGROUNDS ================== */
/* ======================================================= */

.bg-atlantic {
  background: linear-gradient(180deg, #1e3a8a 0%, #0ea5e9 100%),
              url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' opacity='0.15'><path d='M10,80 Q30,40 50,70 T90,60 V100 H0 Z' fill='white'/></svg>");
  background-size: cover, contain;
  background-blend-mode: normal, overlay;
}

.bg-arctic {
  background: linear-gradient(180deg, #e0f2fe 0%, #0ea5e9 100%),
              url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' opacity='0.25'><polygon points='20,85 30,20 40,85' fill='white'/><polygon points='45,85 55,30 65,85' fill='white'/><polygon points='70,85 80,40 90,85' fill='white'/></svg>");
  background-size: cover, contain;
  background-blend-mode: normal, overlay;
}

.bg-pacific {
  background: linear-gradient(180deg, #0c4a6e 0%, #38bdf8 100%),
              url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' opacity='0.1'><ellipse cx='30' cy='30' rx='20' ry='8' fill='white'/><ellipse cx='70' cy='40' rx='15' ry='6' fill='white'/><ellipse cx='50' cy='20' rx='18' ry='7' fill='white'/></svg>");
  background-size: cover, contain;
  background-blend-mode: normal, overlay;
}

.bg-indian {
  background: linear-gradient(180deg, #164e63 0%, #06b6d4 100%),
              url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' opacity='0.2'><path d='M10,80 Q20,50 40,60 T60,70 T90,50 V100 H0 Z' fill='white'/><circle cx='50' cy='20' r='10' fill='white'/></svg>");
  background-size: cover, contain;
  background-blend-mode: normal, overlay;
}

.bg-southern {
  background: linear-gradient(180deg, #1e293b 0%, #64748b 100%),
              url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' opacity='0.15'><polygon points='20,85 30,15 40,85' fill='white'/><polygon points='45,85 55,25 65,85' fill='white'/><polygon points='70,85 80,35 90,85' fill='white'/></svg>");
  background-size: cover, contain;
  background-blend-mode: normal, overlay;
}

/* ======================================================= */
/* ================= MEDIA INQUIRIES ===================== */
/* ======================================================= */

/* Responsive adjustments */
@media (max-width: 420px) {
  .btn-tab {
    width: auto;             /* keep natural width */
    height: clamp(44px, 5vh, 48px)
    border-radius: 20px 0 0 20px;   /* flat on left, rounded on right */
    padding: 6px 10px;
  }
  .top-bar-right { gap: 4px; }
  :root {
    --side-left-width: 90px;
    --side-right-width: 90px;
  }
}