:root {
  --bg: #0f1221;
  --panel: #171a2c;
  --text: #e6e9f0;
  --muted: #a3acc3;
  --accent: #7aa2ff;
  --border: #2a2f47;
  --hover: #202545;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 12px;
}
html, body {
  height: 100%;
  margin: 0;
  box-sizing: border-box;
  font-family: system-ui, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background-image: url("../images/bg.png");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  color: var(--text);
}
*, *::before, *::after { box-sizing: inherit; }

/* TOP-ALIGNED LAYOUT WITH SIDE GUTTERS */
.center {
  min-height: 100svh;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start !important;
  align-content: flex-start !important;
  gap: 12px;
  padding: 24px;
  /* allow more room on desktop so the items table can expand fully */
  max-width: 1400px;
  margin: 0 auto;         /* keep centered, leave viewport edges free */
  padding-left: 16px;
  padding-right: 16px;
}

.site-title {
  display: block;
  width: min(560px, 90%);
  max-width: 100%;
  height: auto;
  margin: 6px auto 4px auto;
  image-rendering: optimizeQuality;
}

/* Page switch buttons (between title and guess box) */
.page-switch {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
  position: relative;
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-decoration: none;
}
.page-btn img { width: 36px; height: 36px; object-fit: contain; }
.page-btn.active { background: #2e7d32; border-color: #2e7d32; }

/* Hard page button (red) */
.page-btn.hard { background: linear-gradient(180deg, #d9534f, #b71c1c); border-color: #9b1414; }
.page-btn.hard img { filter: drop-shadow(0 1px 0 rgba(0,0,0,0.25)); }

/* vertical separator between the two page buttons */

.page-btn { z-index: 2; position: relative; }
.page-switch::after {
  /* horizontal bar centered vertically through the buttons */
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% + 48px); /* extend slightly beyond buttons */
  height: 12px;
  background: #8B5A2B; /* brown separator */
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  pointer-events: none;
  border-radius: 6px;
  z-index: 1;
}

@media (max-width: 420px) {
  .page-switch::after { top: 50%; transform: translate(-50%, -50%); height: 10px; width: calc(100% + 32px); }
  .page-btn { width: 48px; height: 48px; }
  .page-btn img { width:30px; height:30px; }
}


.top-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
  width: min(760px, 90%);
  justify-content: center;
}
.top-row .combo-guess { margin-top: 0; }

.side-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  box-shadow: var(--shadow);
  width: 37px;
  box-sizing: border-box;
  justify-content: center;
}

.icon-btn {
  background: transparent;
  border: none;
  padding: 6px;
  width: 100%;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-btn img { width: 22px; height: 22px; object-fit: contain; }

@media (max-width: 720px) {
  .top-row {
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    gap: 8px;
    width: min(760px, 90%);
    flex-wrap: nowrap;
  }
  .side-box {
    width: 44px;
    flex-direction: column;
    padding: 6px;
    gap: 6px;
    box-sizing: border-box;
    justify-content: center;
  }
  .combo-guess { align-self: stretch; }
  .icon-btn { width: 100%; height: 34px; }
  .guess-actions { max-width: calc(90% - 56px); gap: 8px; }
  .guess-btn { min-width: 0; flex: 1 1 auto; height: 44px; }
  .emojibox img { width: 84px; height: 84px; padding: 6px; }
  .emojibox { margin-top: 12px; padding: 10px; gap: 12px; width: 100%; }
  .emoji-tile { width: 84px; height: 84px; font-size: 36px; }
  .emoji-tile.locked { opacity: 0.95; }
  .emoji-note { font-size: 20px; }
}

.combo {
  z-index: 2;
  width: min(680px, 90%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: relative;
}

/* Daily card (prominent icon on cardGuesser page) */
.daily-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 10px 0;
  /* frame (sharp, not blurred) around the image */
  width: 360px;
  height: 360px;
  padding: 3px; /* thickness of the outline */
  /* use same color as the guess box border so outlines match */
  background: var(--border);
  border-radius: 15px;
  box-sizing: border-box;
  overflow: hidden; /* ensure image stays inside rounded frame */
  position: relative; /* needed so the overlay can be absolutely positioned on top */
}
.daily-card-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* inner rounding so frame is visible */
  border-radius: 12px;
  background: transparent !important;
  box-shadow: none !important;
}
.daily-card-name {
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
  text-align: center;
}

/* Semi-transparent overlay sitting above the image to prevent visual cheating.
   The overlay is a sibling of the img and is not affected by the img's filter blur. */
.daily-card-overlay {
  position: absolute;
  inset: 0; /* top:0; right:0; bottom:0; left:0 */
  background: rgba(0,0,0,0); /* tweak opacity to taste */
  border-radius: 12px; /* match inner image rounding */
  z-index: 2; /* above the image but below any future controls */
  pointer-events: auto; /* capture mouse events so the underlying image can't be directly interacted with */
}

/* removed: no responsive adjustments for .daily-card; it keeps its desktop size */
.combo .input-wrap {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px;
  padding: 12px 14px;
}
.combo input[type="text"] {
  background: transparent; border: none; outline: none; color: var(--text);
  font-size: 18px; padding: 10px 0; caret-color: var(--accent); width: 100%;
}
.combo .kbd {
  color: var(--muted); font-size: 12px; border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 8px;
}

.dropdown {
  position: absolute;
  left: 0; right: 0; top: calc(100% - 2px);
  background: var(--panel); border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius); max-height: 360px; overflow: auto;
  display: none; z-index: 20;
}
.dropdown.open { display: block; }

/* Emoji box: grouped panel with large icons (icons increased by 50%) */
.emojibox {
  display: flex;
  flex-direction: column; /* stack the row and the note */
  gap: 12px;
  justify-content: center;
  align-items: center;
  margin: 24px auto 0 auto;
  width: min(680px, 90%);
  box-sizing: border-box;
  background: linear-gradient(180deg, rgba(23,26,44,0.6), rgba(23,26,44,0.45));
  border: 1px solid var(--border);
  padding: 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.emojibox img {
  width: 108px; /* 72 * 1.5 */
  height: 108px;
  object-fit: contain;
  border-radius: 12px;
  background: transparent;
  border: none;
  padding: 6px;
}

/* horizontal row inside the emojibox to hold emoji tiles */
.emoji-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: center;
  width: 100%;
}

/* Emoji tile (used by monsterGuesser) */
.emoji-tile {
  width: 108px;
  height: 108px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
  color: var(--text);
  box-sizing: border-box;
  transition: background 180ms ease, color 180ms ease;
}
.emoji-tile.locked { color: var(--muted); opacity: 0.9; }

/* Note displayed below emoji tiles */
.emoji-note {
  width: 100%;
  text-align: center;
  margin: 0; /* spacing handled by .emojibox gap */
  color: var(--muted);
  font-size: 18px; /* increased for readability */
}

.results { list-style: none; margin: 0; padding: 6px; }
.guess-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.guess-title {
  font-weight: 900;
  color: var(--text);
  text-align: center;
  font-size: 20px;
  letter-spacing: 0.6px;
  padding: 6px 0;
  border-radius: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}
@media (min-width: 720px) {
  .guess-title { font-size: 22px; padding: 8px 0; }
}

.guess-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 380px;
}
.guess-btn {
  min-width: 140px;
  height: 48px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  background: var(--hover);
  color: var(--text);
  font-weight: 800;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
}
.clue-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.clue-note { font-size: 12px; color: var(--muted); text-align: center; }
.guess-actions:has(.clue-wrap:nth-child(1):only-child),
.guess-actions:has(.clue-wrap:nth-child(2):only-child) {
  justify-content: center;
}
.guess-actions .clue-wrap:only-child .guess-btn { min-width: 120px; }
.guess-btn[disabled], .guess-btn.locked {
  background: linear-gradient(180deg, #2a2f47, #232735);
  color: #8b8f9e;
  cursor: not-allowed;
  opacity: 0.9;
}

/* Hard mode button (red) */
.btn-hard {
  background: linear-gradient(180deg, #d9534f, #b71c1c);
  color: #fff;
  border: 1px solid #9b1414;
}
.btn-hard:hover { filter: brightness(0.95); }
.btn-hard:active { transform: translateY(1px); }

.combo-guess {
  margin-top: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: inline-flex;
  flex-direction: column;
  width: auto;
  max-width: 90%;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 10; /* lowered */
}

.item {
  display: grid; grid-template-columns: 42px 1fr; align-items: center; gap: 12px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; border: 1px solid transparent;
}
.item:hover { background: var(--hover); border-color: var(--border); }
.item img {
  width: 38px; height: 38px; object-fit: contain; background: #0e1120; border-radius: 6px;
  border: 1px solid var(--border);
}
.item .name { font-size: 15px; line-height: 1.2; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hint { margin-top: 14px; color: var(--muted); font-size: 13px; text-align: center; }
.status { margin-top: 8px; color: #a6f3a6; font-size: 13px; text-align: center; min-height: 1.2em; }

.table-wrap {
  position: relative;
  z-index: 1;
  margin-top: 8px;
  /* allow the table to take full available width inside the center container */
  max-width: 100%;
  min-height: 260px;
  max-height: none;
  overflow-y: visible;
  /* allow horizontal scrolling on narrow viewports (mobile) */
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.table-wrap.visible { opacity: 1; }

.type-yellow, .type-red, .type-green, .type-none { position: relative; }
.cell-match { background: #2e7d32 !important; color: #fff; }
.cell-miss { background: #b71c1c !important; color: #fff; }
.table-panel td, .table-panel th {
  padding: 6px;
  box-sizing: border-box;
  background: rgba(23,26,44,0.9);
  color: var(--text);
  border-radius: 8px;
}
.table-head th { background: var(--hover) !important; color: var(--text) !important; }

.type-yellow { background: transparent; }
.type-red { background: transparent; }
.type-none { background: transparent; }

.cell-arrow-bg {
  position: absolute;
  width: 100px;
  height: 100px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  object-fit: contain;
  opacity: 0.3;
  z-index: 0;
  pointer-events: none;
  display: block;
}
.cell-content {
  position: relative;
  z-index: 1;
  font-weight: bold;
  font-size: 1.1em;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  height: 100%;
}

#itemTable {
  table-layout: fixed;
  width: min(680px, 90%);
  /* allow the table to expand beyond the container width so it can be scrolled
     on small screens where column totals exceed viewport width */
  min-width: max-content;
  max-width: 100%;
  margin: 0 auto;
  border-collapse: separate;
  border-spacing: 6px 6px;
}

@media (max-width: 720px) {
  /* Ensure touch scrolling for the table container on mobile */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
.table-panel { background: transparent; border: none; border-radius: 0; overflow: visible; }
.th-left { padding: 8px; text-align: center; }
.stat-col {
  min-width: 70px;
  max-width: 150px;
  width: 90px;
  height: 44px;
  text-align: center;
  vertical-align: middle;
  padding: 6px;
  box-sizing: border-box;
}
#itemTable th:nth-child(1), #itemTable td:nth-child(1) { width: 280px; }
#itemTable th:nth-child(2), #itemTable td:nth-child(2) { width: 128px; }
#itemTable th:nth-child(3), #itemTable td:nth-child(3) { width: 64px; }
#itemTable th:nth-child(4), #itemTable td:nth-child(4) { width: 64px; }
#itemTable th:nth-child(5), #itemTable td:nth-child(5) { width: 64px; }
#itemTable th:nth-child(6), #itemTable td:nth-child(6) { width: 64px; }
#itemTable th:nth-child(7), #itemTable td:nth-child(7) { width: 64px; }
#itemTable th:nth-child(8), #itemTable td:nth-child(8) { width: 64px; }
#itemTable th:nth-child(9), #itemTable td:nth-child(9) { width: 64px; }
#itemTable th:nth-child(10), #itemTable td:nth-child(10) { width: 128px; }
#itemTable th:nth-child(11), #itemTable td:nth-child(11) { width: 300px; }

.item-icon { width:64px; height:64px; object-fit:contain; background:#0e1120; border:1px solid var(--border); border-radius:6px; }
.icon-cell { width: 96px; text-align: center; }
.item-cell { display: flex; gap: 12px; align-items: center; }
#itemTable th:first-child, #itemTable td:first-child { width: 280px; }
.name-cell {
  text-align: left;
  padding-left: 8px;
  white-space: normal;
  overflow: visible;
  word-break: break-word;
  overflow-wrap: anywhere;
}
#itemTable td.item-cell {
  display: flex;
  gap: 12px;
  align-items: center;
}
#itemTable td.item-cell .name-cell { padding-left: 0; }

.sell-price {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2px;
  margin-bottom: 6px;
}
.sell-price .coin-img, .coin-img { margin-right:6px; width:16px; height:16px; object-fit:contain; }
.sell-rows { display: flex; flex-direction: column; gap: 2px; }
.sell-row { display: flex; flex-direction: row; gap: 0px; align-items: center; }

.table-head { background: var(--hover); opacity: 0; transform: translateY(-6px); }
.table-head.fade-in { animation: headerFade 360ms ease both; }
@keyframes headerFade { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.cell-fade { opacity: 0; transform: translateY(6px); }
.cell-fade.in { animation: cellFade 460ms ease both; }
@keyframes cellFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

#itemTable { display: table; }
#itemTable thead, #itemTable tbody { display: table-row-group; }
#itemTable tr { display: table-row; }
#itemTable th, #itemTable td { display: table-cell; vertical-align: middle; box-sizing: border-box; padding: 6px; }

.table-panel { margin-left: auto; margin-right: auto; }

.goal-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.55);
  z-index: 900; /* lowered */
}
.goal-modal[aria-hidden="false"] { display: flex; }
.goal-panel {
  background: #fff;
  color: #111;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  padding: 18px 20px;
  max-width: 420px;
  width: 92%;
  text-align: center;
  position: relative;
}
.goal-close {
  position: absolute;
  right: 8px;
  top: 8px;
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
}
.goal-title { margin: 6px 0 12px 0; font-size: 20px; color: #111; letter-spacing: 1px; }
.goal-body { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 8px 0; }
.goal-guesses { margin-top: 8px; color: #222; font-size: 15px; }
.goal-guesses strong { font-weight: 900; margin-left: 6px; }
.goal-icon { width: 96px; height: 96px; object-fit: contain; }
.goal-name { font-weight: 700; font-size: 18px; }
.goal-footer { margin-top: 12px; font-size: 14px; color: #333; }
.goal-footer-text { margin-bottom: 8px; }
.goal-timer-wrap { display: flex; justify-content: center; }
.goal-timer { font-size: 32px; font-weight: 800; color: #d9534f; letter-spacing: 1px; }

.site-footer {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 12px 0 20px 0;
  margin-top: 12px;
}
.site-footer .footer-inner {
  width: min(680px, 90%);
  display: flex;
  justify-content: center;
  align-items: center;
}
.site-footer .footer-inner a { display: inline-block; }
.site-footer img { display: block; height: 36px; width: auto; border: 0; }

.privacy-link {
  color: black;
  text-decoration: underline;
  font-size: 13px;
}

.kofi-container {
  max-width: 420px;
  margin: 0 auto;
  scale: 0.1;
  display: flex;
  justify-content: center;
}
@media (max-width: 420px) {
  .kofi-container { width: min(300px, 90%); }
}
.table-wrap::-webkit-scrollbar { height: 0; }
