@font-face {
  font-family: 'Ngayogyan';
  src: url('./ngayogyann.ttf') format('truetype');
  font-display: swap;
}

:root {
  --bg-color: #F4ECD8; /* Krem Perkamen Klasik */
  --text-main: #3E2723; /* Cokelat Kayu Gelap */
  --accent-color: #8D6E63;
  --cell-bg: #FFF8E7;
  --cell-focus: #E0D0B8;
  --cell-correct: #C8E6C9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  overflow-x: hidden; /* Mencegah geser horizontal seluruh halaman */
}

.app-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 12px;
}

.app-header {
  text-align: center;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--accent-color);
  padding-bottom: 12px;
}

.app-header h1 {
  font-family: 'Ngayogyan', serif;
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  margin: 0 0 5px 0;
  letter-spacing: 1px;
}

.btn-main-lagi {
  background-color: #5D4037;
  color: #FFF8E7;
  border: none;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: bold;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 6px;
  transition: background-color 0.2s;
}

.btn-main-lagi:hover {
  background-color: #3E2723;
}

/* Tata Letak Utama (Flexbox) */
.app-layout {
  display: flex;
  flex-direction: row;
  gap: 24px;
  align-items: flex-start;
  justify-content: center;
}

.board-section {
  flex: 1 1 480px;
  max-width: 520px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Grid Crossword Fluida (Otomatis Pas Layar HP) */
.grid-container {
  display: grid;
  gap: 2px;
  background-color: var(--text-main);
  padding: 3px;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  margin-bottom: 20px;
  width: 100%;
  max-width: 500px;
  aspect-ratio: 1 / 1; /* Menjaga rasio persegi di semua ukuran layar */
}

.cell-wrapper {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  background-color: #2b1b17;
  position: relative;
  overflow: visible;
}

.cell-wrapper.active {
  background-color: var(--cell-bg);
}

.cell-number {
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: clamp(7px, 1.8vw, 10px);
  font-weight: bold;
  color: var(--text-main);
  pointer-events: none;
  z-index: 2;
}

.cell-input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: 'Ngayogyan', serif;
  /* Ukuran font dinamis menyesuaikan lebar layar HP */
  font-size: clamp(0.95rem, 3.8vw, 1.5rem);
  line-height: 1;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  padding: 0;
}

.cell-input:focus {
  background-color: var(--cell-focus);
}

.cell-input.correct {
  background-color: var(--cell-correct);
  color: #1B5E20;
}

/* Panel Clues / Petunjuk Soal */
.clues-section {
  flex: 1 1 320px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.clues-box {
  background: #FFF8E7;
  border: 1px solid var(--accent-color);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  width: 100%;
}

.clues-box h2 {
  margin-top: 0;
  font-size: 1.1rem;
  border-bottom: 2px dashed var(--accent-color);
  padding-bottom: 4px;
}

.clue-list {
  padding-left: 18px;
  line-height: 1.4;
  margin-bottom: 0;
  font-size: 0.95rem;
}

.clue-list li {
  margin-bottom: 8px;
}

/* Keyboard Virtual Responsif */
.keyboard-container {
  width: 100%;
  background-color: #FFF8E7;
  border: 1px solid var(--accent-color);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.keyboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.85rem;
  font-weight: bold;
}

.btn-clear {
  background-color: #D84315;
  color: white;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.8rem;
}

.keyboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 6px;
}

.key-btn {
  font-family: 'Ngayogyan', serif;
  font-size: clamp(1.1rem, 4.2vw, 1.5rem);
  height: clamp(40px, 9vw, 48px);
  background-color: white;
  border: 1px solid var(--accent-color);
  border-radius: 6px;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: all 0.1s;
}

.key-btn:active {
  transform: scale(0.95);
  background-color: var(--cell-focus);
}

/* Modal Popup Victory */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s;
}

.modal-overlay.hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  background-color: #FFF8E7;
  border: 2px solid var(--accent-color);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  max-width: 360px;
  width: 88%;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.modal-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.modal-card h2 {
  font-family: 'Ngayogyan', serif;
  margin: 0 0 8px 0;
  font-size: 1.6rem;
  color: var(--text-main);
}

.modal-card p {
  margin-bottom: 18px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.btn-primary {
  background-color: #2E7D32;
  color: white;
  border: none;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: bold;
  border-radius: 6px;
  cursor: pointer;
}

/* Media Query untuk HP / Layar Kecil (< 800px) */
@media (max-width: 800px) {
  .app-container {
    padding: 8px;
  }

  .app-layout {
    flex-direction: column;
    align-items: center;
    gap: 16px;
  }

  .board-section, .clues-section {
    max-width: 100%;
    width: 100%;
  }

  .grid-container {
    max-width: 100%; /* Memenuhi lebar layar HP secara proporsional */
  }

  /* Footer Styling */
.app-footer {
  text-align: center;
  margin-top: 30px;
  padding-top: 15px;
  border-top: 1px solid var(--accent-color);
  font-size: 0.9rem;
  color: var(--text-main);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.app-footer p {
  margin: 0;
}
}
