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

:root {
  --card-ratio: 1;
}

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

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: #585931;
}

.title-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: var(--grid-width);
  margin: 0 auto;
  padding: 2.5vmin 0 1vmin;
  font-family: 'Bubblegum Sans', sans-serif;
  color: #E3D0A7;
}

.title-group {
  display: flex;
  flex-direction: column;
}

.title {
  font-size: 2.3rem;
  font-weight: bold;
}

.secret-label {
  font-size: 0.8rem;
  color: #585931;
  /*color: #E3D0A7;*/
}

.icon-buttons {
  display: flex;
  gap: 1.5vmin;
}

.icon-btn {
  position: relative;
  width: 4vmin;
  height: 4vmin;
  aspect-ratio: 1;
  border: none;
  border-radius: 1vmin;
  background: #8C8C5F;
  color: #F0E6C8;
  font-size: 2.4vmin;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 1vmin);
  left: 50%;
  transform: translateX(-50%);
  background: #3a2e1f;
  color: #f0e6c8;
  font-family: 'Bubblegum Sans', sans-serif;
  font-size: 0.7rem;
  white-space: nowrap;
  padding: 0.6vmin 1.2vmin;
  border-radius: 0.6vmin;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 60;
}

.icon-btn[data-tooltip]:hover::after,
.icon-btn[data-tooltip]:focus-visible::after {
  opacity: 1;
}

.icon-btn.active {
  background: #c0392b;
  color: #fff;
}

.grid-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
  padding: 1vmin;
}

.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 1vmin;
  width: min(100cqw, calc(100cqh * var(--card-ratio)));
  height: min(100cqh, calc(100cqw / var(--card-ratio)));
}

.grid.locked,
.question-wrap.locked {
  opacity: 0.5;
  pointer-events: none;
}

.question-wrap {
  flex: 0 0 auto;
  width: calc(var(--grid-width) * 1.04);
  height: 27vh;
  margin: 2.5vmin auto 1.5vmin;
  background-image: url('question_bg.PNG');
  background-repeat: no-repeat;
  background-size: 100% 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.question-box {
  display: flex;
  flex-direction: column;
  width: 97%;
  height: 96%;
  overflow: hidden;
}

.question-header {
  position: relative;
  flex: 0 0 16%;
  display: flex;
  align-items: center;
  padding: 0 4%;
}

.question-live-input {
  width: 100%;
  padding-left: 0;
  border: none;
  background: transparent;
  outline: none;
  font-family: 'Bubblegum Sans', sans-serif;
  font-size: 1.2rem;
  font-weight: normal;
  color: #F0E6C8;
}

.question-live-input::placeholder {
  color: rgba(240, 230, 200, 0.6);
}

.blink-cursor {
  position: absolute;
  left: calc(4% - 2px);
  top: 50%;
  width: 2px;
  height: 1.1em;
  transform: translateY(-50%);
  background: #F0E6C8;
  animation: cursor-blink 1s steps(1, start) infinite;
  pointer-events: none;
}

.question-live-input:focus + .blink-cursor,
.question-live-input:not(:placeholder-shown) + .blink-cursor {
  display: none;
}

@keyframes cursor-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.question-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 1.2vmin 4%;
  font-family: 'Bubblegum Sans', sans-serif;
  font-size: 0.95rem;
  color: #3a2e1f;
}

.history-heading {
  flex: 0 0 auto;
  font-weight: bold;
  text-transform: uppercase;
  text-decoration: underline;
  margin-bottom: 0.6vmin;
}

.question-feedback {
  flex: 0 0 auto;
  font-size: 0.85rem;
  color: #8a4a4a;
  min-height: 1.2em;
}

.question-feedback.shake {
  animation: wrong-guess-shake 0.4s ease;
}

.history-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(172, 147, 102, 0.6) transparent;
}

.history-list::-webkit-scrollbar {
  width: 6px;
}

.history-list::-webkit-scrollbar-track {
  background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
  background-color: rgba(172, 147, 102, 0.6);
  border-radius: 999px;
}

.history-list li.question-empty {
  cursor: default;
  color: rgba(58, 46, 31, 0.7);
}

.history-list li {
  display: flex;
  align-items: baseline;
  gap: 0.6vmin;
  padding: 0.5vmin 0;
}

.history-question {
  flex: 0 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-dots {
  flex: 1 1 auto;
  border-bottom: 1px dotted rgba(58, 46, 31, 0.5);
  height: 0;
  min-width: 1vmin;
}

.history-list .answer-yes {
  flex: 0 0 auto;
  color: #3f7a3f;
  font-weight: bold;
}

.history-list .answer-no {
  flex: 0 0 auto;
  color: #8a4a4a;
  font-weight: bold;
}

.cell {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10%;
  background-image: url('card_bg.PNG');
  background-size: 100% 100%;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.cell::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  pointer-events: none;
  background: transparent;
}

.cell[data-mark='red']::after {
  background: rgba(200, 60, 60, 0.5);
}

.cell[data-mark='yellow']::after {
  background: rgba(230, 200, 60, 0.5);
}

.cell[data-mark='green']::after {
  background: rgba(70, 160, 90, 0.5);
}

@keyframes wrong-guess-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6%); }
  40% { transform: translateX(5%); }
  60% { transform: translateX(-4%); }
  80% { transform: translateX(3%); }
}

.cell.wrong-guess {
  animation: wrong-guess-shake 0.4s ease;
}

.cell-art {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  pointer-events: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  position: relative;
  background: #f0e6c8;
  color: #3a2e1f;
  border-radius: 1.5vmin;
  padding: 4vmin;
  min-width: 280px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  overflow-x: hidden;
  font-family: 'Bubblegum Sans', sans-serif;
}

.modal.tutorial-modal {
  width: calc(var(--grid-width) * 1.05);
  max-width: 95vw;
}

.modal h2 {
  margin-bottom: 2vmin;
}

.modal p {
  margin-bottom: 2vmin;
}

.modal ul {
  margin: 3vmin 2.5vmin 4vmin
}

.modal ul li {
  margin-bottom: 1vmin;
}

.modal-close {
  position: absolute;
  top: 1.5vmin;
  right: 1.5vmin;
  width: 3vmin;
  height: 3vmin;
  min-width: 24px;
  min-height: 24px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #3a2e1f;
  font-size: 1.4rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.modal-close:hover {
  background: rgba(58, 46, 31, 0.1);
}

.modal input[type='text'],
.modal textarea {
  display: block;
  width: 100%;
  padding: 1.2vmin;
  border-radius: 0.5vmin;
  border: 1px solid #ac9366;
  font-size: 1rem;
  margin-bottom: 2vmin;
  box-sizing: border-box;
  font-family: inherit;
  resize: vertical;
}

.modal button.primary {
  background: #ac9366;
  color: #f0e6c8;
  border: none;
  padding: 1.2vmin 2.5vmin;
  border-radius: 0.5vmin;
  font-weight: bold;
  cursor: pointer;
}

.leaderboard-list {
  list-style: none;
  width: calc(100% - 3.5vmin);
  margin-bottom: 2vmin;
  margin-left: -1.5vmin;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2vmin;
  padding: 0.8vmin 0.5vmin;
  border-bottom: 1px solid rgba(172, 147, 102, 0.3);
}

.leaderboard-list li.me {
  font-weight: bold;
  color: #7a4b2a;
}

.leaderboard-list li.stat-highlight {
  font-weight: bold;
}

.playtest-section {
  margin-top: 1vmin;
  padding-top: 2vmin;
  border-top: 1px dashed rgba(172, 147, 102, 0.5);
}

.playtest-section h3 {
  font-size: 0.85rem;
  color: #8a4a4a;
  margin-bottom: 1vmin;
}

.playtest-section ol {
  margin: 0 0 2vmin 4vmin;
  font-size: 0.85rem;
}

.playtest-section li {
  margin-bottom: 0.6vmin;
}

.tutorial-visual {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 18vh;
  margin-bottom: 1.5vmin;
}

.tutorial-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 3.4vmin;
  height: 3.4vmin;
  min-width: 28px;
  min-height: 28px;
  border: none;
  background: transparent;
  color: #3a2e1f;
  font-size: 2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
}

.tutorial-arrow:hover {
  color: #7a4b2a;
}

.tutorial-arrow:disabled {
  opacity: 0;
  pointer-events: none;
}

.tutorial-arrow-prev {
  left: 0;
}

.tutorial-arrow-next {
  right: 0;
}

.tutorial-image {
  max-height: 100%;
  max-width: 55%;
  object-fit: contain;
}

.tutorial-marks {
  display: flex;
  gap: 2vmin;
}

.tutorial-mock-cell {
  position: relative;
  width: 12vmin;
  height: 12vmin;
  min-width: 60px;
  min-height: 60px;
  box-sizing: border-box;
  background-image: url('card_bg.PNG');
  background-size: 100% 100%;
  border-radius: 8px;
  padding: 10%;
}

.tutorial-mock-cell img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tutorial-mock-cell::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  pointer-events: none;
}

.tutorial-mock-cell[data-mark='red']::after {
  background: rgba(200, 60, 60, 0.5);
}

.tutorial-mock-cell[data-mark='yellow']::after {
  background: rgba(230, 200, 60, 0.5);
}

.tutorial-mock-cell[data-mark='green']::after {
  background: rgba(70, 160, 90, 0.5);
}

.tutorial-mark-labels {
  display: flex;
  gap: 2vmin;
  justify-content: center;
  font-size: 0.7rem;
  margin-top: 0.8vmin;
}

.tutorial-mark-labels span {
  width: 12vmin;
  min-width: 60px;
  text-align: center;
}

.tutorial-shake-demo {
  animation: wrong-guess-shake 1.4s ease-in-out infinite;
}

.tutorial-question-box {
  width: 92%;
  height: 27vh;
  background-image: url('question_bg.PNG');
  background-repeat: no-repeat;
  background-size: 100% 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

.tutorial-ask-demo {
  flex: 0 0 16%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 4%;
  font-family: 'Bubblegum Sans', sans-serif;
  font-size: 0.95rem;
  color: #f0e6c8;
  box-sizing: border-box;
}

.tutorial-history-demo {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 1.2vmin 4%;
  font-size: 1.2rem;
  color: #3a2e1f;
  box-sizing: border-box;
}

.tutorial-history-demo li {
  display: flex;
  align-items: baseline;
  gap: 0.6vmin;
  padding: 0.4vmin 0;
}

.tutorial-ask-cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  margin-left: 3px;
  vertical-align: middle;
  background: #f0e6c8;
}

.tutorial-highlight {
  color: #3f7a3f;
  font-weight: bold;
}

.tutorial-dots {
  display: flex;
  justify-content: center;
  gap: 1vmin;
  margin: 2vmin 0;
}

.tutorial-dot {
  width: 1.2vmin;
  height: 1.2vmin;
  min-width: 8px;
  min-height: 8px;
  border-radius: 50%;
  background: rgba(58, 46, 31, 0.25);
  cursor: pointer;
}

.tutorial-dot.active {
  background: #ac9366;
}

.tutorial-nav {
  display: flex;
  justify-content: center;
  gap: 2vmin;
}

.tutorial-nav:not(:empty) {
  margin-top: 1vmin;
}

.tutorial-nav button.primary {
  flex: 0 0 auto;
}
