/*
  This stylesheet defines a dark, greyscale aesthetic for the game.  
  The palette uses subtle contrasts so that coloured feedback (orange, green) stands out.  
  The layout is responsive and fills the viewport, maintaining a pleasing aspect ratio on most screens.
*/
body {
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
  background-color: #0e0e0e;
  color: #e0e0e0;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Container encapsulating all screens */
#app {
  width: 100%;
  max-width: 900px;
  padding: 20px;
  box-sizing: border-box;
}

/* Generic screen styles */
.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.hidden {
  display: none;
}

.title {
  margin-top: 0;
  margin-bottom: 1.25rem;
  font-size: 2rem;
  color: #ffffff;
}

.form-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  max-width: 300px;
}

label {
  margin-bottom: .25rem;
  font-weight: bold;
}

.select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  border: 1px solid #444;
  background-color: #202020;
  color: #e0e0e0;
  appearance: none;
}

.primary-btn {
  padding: .625rem 1.25rem;
  border: none;
  border-radius: 6px;
  background-color: #444;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.primary-btn:hover {
  background-color: #666;
}

.score-display {
  margin-top: .625rem;
  font-size: 1rem;
  color: #aaaaaa;
}

/* Game board styles */
.board-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 1.25rem;
}

.row {
  display: flex;
  justify-content: center;
  margin-bottom: .25rem;
}

.cell {
  width: 45px;
  height: 45px;
  border: 2px solid #444;
  margin: .125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  text-transform: uppercase;
  font-weight: bold;
  user-select: none;
}

/* Cell states */
.cell.correct {
  background-color: #0f5132; /* dark green */
  border-color: #0f5132;
  color: #fff;
}
.cell.present {
  background-color: #66410f; /* dark orange */
  border-color: #66410f;
  color: #fff;
}
.cell.absent {
  background-color: #333;
  border-color: #333;
  color: #777;
}

/* Game information */
.game-info {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.game-settings {
  font-size: 0.9rem;
  color: #888;
}

/* Keyboard styling */
.keyboard-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 1.25rem;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  margin-bottom: .25rem;
}

.key {
  background-color: #2a2a2a;
  color: #ddd;
  border: none;
  border-radius: 4px;
  margin: .25rem;
  padding: 0.625rem;
  min-width: 40px;
  text-align: center;
  font-size: 1rem;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease;
}

.key:hover {
  background-color: #555;
}

.key.correct {
  background-color: #0f5132;
  color: #fff;
}

.key.present {
  background-color: #66410f;
  color: #fff;
}

.key.absent {
  background-color: #333;
  color: #777;
}

/* Hint panel styling */
.hint-panel {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-top: 1.25rem;
}

/* Group score display and help button */
.score-help {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* Icon button used for help and modal controls */
.icon-btn {
  background-color: #222;
  color: #ddd;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 0.375rem 0.625rem;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1;
}
.icon-btn:hover {
  background-color: #333;
}

.ad-btn {
  background-color: #222;
  color: #ddd;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 0.375rem 0.625rem;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1;
}
.ad-btn:hover {
  background-color: #333;
}

/* Modal backdrop and content */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-backdrop.hidden {
  display: none !important;
}

.modal {
  background: #161616;
  color: #eee;
  border: 1px solid #333;
  border-radius: 12px;
  width: min(680px, 92vw);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid #2a2a2a;
}
.modal-body {
  padding: 14px 16px;
  overflow-y: auto;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0.75rem 1rem;
  border-top: 1px solid #2a2a2a;
}
.modal-screen.hidden {
  display: none !important;
}

/* Legend styling used in How to play */
.legend {
  list-style: none;
  margin: .5rem 0 0;
  padding: 0;
}
.legend li {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: .25rem 0;
}
.legend-box {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 4px;
}
.legend-box.correct { background-color: #0f5132; }
.legend-box.present { background-color: #66410f; }
.legend-box.absent  { background-color: #333; border: 1px solid #333; }

/* Sections and lists in How to play */
.section {
  margin-top: .625rem;
  margin-bottom: .25rem;
  font-size: 1rem;
  font-weight: 600;
}
.bullets {
  margin: 0 0 .5rem 1.125rem;
  padding: 0;
  list-style: disc;
}
.bullets li {
  margin: .25rem 0;
}

.hint-btn {
  width: 100%;                 /* растягиваем по колонке */
  min-height: 56px;            /* одинаковая высота */
  text-align: left;            /* как на примере */
  padding: 0.625rem 0.75rem;
  display: flex;
  border: none;
  border-radius: 4px;               /* две строки: текст + стоимость */
  flex-direction: column;
  justify-content: center;
  background-color: #2a2a2a;
  color: #ddd;
}

.hint-btn:hover {
  background-color: #555;
}
.hint-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.hint-btn .cost {
  display: block;
  font-size: 0.8rem;
  color: #888;
  margin-top: 0.125rem;
}

/* Hint output */
.hint-output {
  margin-top: 0.625rem;
  font-size: 0.9rem;
  color: #aaa;
  min-height: 1.2rem;
  text-align: center;
  max-width: 80%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 6px;
  row-gap: 6px;
  margin-top: 1.25rem;
}

.hints-list{display:flex;flex-direction:column;gap:6px;margin-top:0.5rem}
.hint-row{padding:.5rem 0.625rem;border:1px solid var(--c-border,#2a2a2a);border-radius:10px;background:var(--c-surface-2,#161616);font-size:14px;line-height:1.3}
.hint-btn[disabled]{opacity:.5;cursor:not-allowed}

/* Win screen styling */
#win-screen {
  padding: 2.5rem 1.25rem;
  box-sizing: border-box;
}

#win-screen p {
  font-size: 1.2rem;
  margin: 10px 0;
}

@media (max-width: 600px) {
  .cell {
    width: 35px;
    height: 35px;
    font-size: 1.2rem;
  }
  .key {
    padding: 8px;
    min-width: 28px;
    font-size: 0.8rem;
  }
  .hint-btn {
    min-width: 120px;
    font-size: 0.75rem;
  }
}

/* ------------------------------------------------------------------------- */

/* Ad prompt overlay. This appears when a user can choose to watch an ad or skip. */
#ad-prompt-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}
#ad-prompt {
  background: #161616;
  color: #eee;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  width: min(340px, 90%);
  text-align: center;
}
#ad-prompt h4 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 1.2rem;
}
#ad-prompt p {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  color: #ccc;
}
#ad-prompt .buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
#ad-prompt .buttons button {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
}
#ad-prompt .buttons button.primary {
  background-color: #444;
  color: #fff;
}
#ad-prompt .buttons button.secondary {
  background-color: #222;
  color: #fff;
}
#ad-prompt .buttons button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}



/* базовое — даём контейнерам 100% высоты без vh */
html, body { height: 100%; margin: 0; }
#app { height: 100%; }

/* любой экран: растягивается на доступные 100% */
.screen { display: none; min-height: 100%; width: 100%; }
/* показываем активный экран */
.screen:not(.hidden) { display: flex; }

/* старт/финиш — по центру без position/vh */
#start-screen, #win-screen { justify-content: center; align-items: center; }

/* игра — колонкой: инфо | поле | подсказки | клавиатура */
#game-screen { flex-direction: column; min-height: fit-content; }



:root { --ui-scale: 1; }

/* масштабируем только экраны игры/старт/финиш, модалку — нет */
.screen { transform-origin: top center; }

/* Если zoom поддерживается — используем его */
@supports (zoom: 1) {
  .screen { zoom: var(--ui-scale); }
}

/* Фолбэк: через transform + компенсация ширины */
@supports not (zoom: 1) {
  .screen {
    transform: scale(var(--ui-scale));
    width: calc(100% / var(--ui-scale));
  }
}

/* Модалка — неизменная (во весь вьюпорт) */
#modal-overlay { zoom: 1 !important; transform: none !important; }
