/* Add Bebas Neue font for section-title headings */
@import url('https://fonts.googleapis.com/css?family=Bebas+Neue&display=swap');

.section-title {
  font-family: 'Bebas Neue', Arial, sans-serif;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 3rem; /* Increase this value as needed */
}

/* Layout Container */
.page-container,
.action-section {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
  padding-left: 24px;
  padding-right: 24px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 250px;
  box-sizing: border-box;
}

/* Grid Layout */
.grid-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px; /* Try increasing this for more space between rows */
  margin-bottom: 2px;
  min-height: 400px; /* Add this to force the grid to take up more space */
}

.guess-row {
  display: flex;
  gap: 2px; /* Try increasing this for more space between cells */
}

.guess-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
}

/* Input Styling */
.dx-texteditor-input {
  text-transform: uppercase !important;
}

.cell-wrapper {
  display: inline-block;
  border-radius: 2px;
  padding: 2px; /* Increase padding */
  min-width: 56px; /* Add min-width */
  min-height: 56px; /* Add min-height */
}

  .cell-wrapper:focus-within {
    outline: 2px solid #2196f3;
    outline-offset: 0;
    border-radius: 2px;
  }

  .cell-wrapper .dx-texteditor {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .cell-wrapper .dx-texteditor-input {
    width: 56px;   /* Increase width */
    height: 56px;  /* Increase height */
    font-size: 2rem; /* Larger font */
    font-weight: bold;
    text-align: center;
    padding: 0;
    box-sizing: border-box;
    border-radius: 4px;
    transition: background-color 0.3s ease, color 0.3s ease, border 0.3s ease;
    text-transform: uppercase;
  }
/* Input Styling by State */
.input-gray {
  background-color: #444 !important;
  color: #fff !important;
  border: 2px solid #222 !important;
  box-shadow: inset 0 0 4px rgba(0,0,0,0.2);
}

.input-yellow {
  background-color: #fdd835 !important;
  color: #000 !important;
  border: 2px solid #c6a700 !important;
  box-shadow: inset 0 0 4px rgba(0,0,0,0.2);
}

.input-green {
  background-color: #66bb6a !important;
  color: #fff !important;
  border: 2px solid #388e3c !important;
  box-shadow: inset 0 0 4px rgba(0,0,0,0.2);
}

/* Button Row */
.button-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  padding-bottom: 24px;
}

.color-selector {
  display: flex;
  gap: .5rem;
  justify-content: center;
  margin-bottom: 1rem;
  width: 100%;           /* Make the container take full width */
  max-width: 400px;      /* Optional: limit max width for aesthetics */
}

.color-btn,
.solve-btn {
  margin-left: 0; /* prevent overflow */
  width: auto;
  max-width: 100%;
  height: 36px;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  box-sizing: border-box;
  transition: all 0.2s ease-in-out;
  letter-spacing: 0.4px;
  position: relative;
  z-index: 10;
  margin-bottom: 16px;
}

.color-btn {
  flex: 1 1 0; /* Allow buttons to grow equally */
  min-width: 0; /* Prevent overflow */
  height: 48px; /* Make buttons taller */
  font-size: 1.1rem; /* Make text larger */
  margin-bottom: 0; /* Remove extra margin if needed */
  min-width: 56px; /* Make buttons a bit larger */
  min-height: 44px; /* Make buttons a bit larger */
  font-size: 1.25rem; /* Larger text */
  padding: 0.5rem 1rem; /* Adjust padding for size */
  border-radius: 8px;
  margin: 0; /* Remove extra margin */
}

  .color-btn:hover,
  .solve-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
  }

  .color-btn.gray {
    background-color: #6c757d;
    color: #fff;
  }

  .color-btn.yellow {
    background-color: #f9c74f;
    color: #000;
  }

  .color-btn.green {
    background-color: #43aa8b;
    color: #fff;
  }

.solve-btn {
  background-color: #0078D4;
  color: #fff;
  width: 100%;
  max-width: 320px;
  height: 36px;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  box-sizing: border-box;
  transition: all 0.2s ease-in-out;
  letter-spacing: 0.4px;
  margin-left: 0; /* REMOVE THIS */
}

  .solve-btn:active {
    background-color: #005A9E;
  }

  /* Game Mode Overrides */
.color-btn.gray.game-check {
  background-color: #2e7d32;
  color: #fff;
  font-weight: bold;
}

/* Result List Styling */
.results-section {
  margin: 0;
  padding: 0;
  width: 100%;
  margin-top: 4px;
}

.result-listbox {
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 4px;
  background-color: #fafafa;
  font-family: Consolas, monospace;
}

.result-item.empty {
  font-style: italic;
  color: #888;
}

/* Dark Mode Overrides */
[data-bs-theme="dark"] .result-listbox {
  background-color: #2e2e2e;
  color: #fff;
  border-color: #555;
}

[data-bs-theme="dark"] .input-gray {
  background-color: #333 !important;
  border-color: #111 !important;
}

/* Virtual Keyboard Docking */
.game-keyboard {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  max-width: 100%;
  box-sizing: border-box;
  position: fixed;
  bottom: env(safe-area-inset-bottom, 0);
  left: 0;
  right: 0;
  z-index: 1000;
  background-color: var(--keyboard-bg, #f0f0f0);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
  padding-bottom: calc(env(safe-area-inset-bottom, 0) + 55px);
}

/* Key Button Styling */
.key-row {
  display: flex;
  /*flex-wrap:wrap;*/
  justify-content: center;
  gap: 4px;
}

.key-btn {
  width: 36px;
  height: 44px;
  font-size: clamp(14px, 2.5vw, 18px);
  font-weight: bold;
  border-radius: 6px;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  touch-action: manipulation;
  background-color: #e0e0e0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

  .key-btn:active {
    transform: scale(0.95);
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
    background-color: #d0d0d0;
  }

  .key-btn.pressed {
    animation: keyTap 120ms ease;
  }

.key-btn.special-key {
    min-width: 44px;   /* or 40px for even smaller */
    width: 61px;
    height: 57px;
    font-size: 0.95em;
    padding: 0 6px;
}

/* Increase the height of regular keyboard buttons by 20% (but not .special-key) */
.key-btn:not(.special-key) {
  height: 52.8px; /* 44px * 1.2 = 52.8px (original is 44px) */
}

/* Responsive overrides for increased height on small screens */
@media (max-width: 480px) {
  .key-btn:not(.special-key) {
    height: 48px; /* 40px * 1.2 = 48px (original is 40px) */
  }
}
@media (min-width: 481px) and (max-width: 768px) {
  .key-btn:not(.special-key) {
    height: 62.4px; /* 52px * 1.2 = 62.4px (original is 52px) */
  }
}
@media (min-width: 769px) {
  .key-btn:not(.special-key) {
    height: 67.2px; /* 56px * 1.2 = 67.2px (original is 56px) */
  }
}

@keyframes keyTap {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(0.95);
  }

  100% {
    transform: scale(1);
  }
}

/* Flip Animation */
@keyframes flip-green {
  0% {
    transform: rotateX(0deg);
  }

  50% {
    transform: rotateX(90deg);
    background-color: #66bb6a;
    color: #fff;
  }

  100% {
    transform: rotateX(0deg);
    background-color: #66bb6a;
    color: #fff;
  }
}

.flip-green {
  animation: flip-green 600ms ease forwards;
  transform-origin: center;
  backface-visibility: hidden;
}

/* Key Color States */
.key-green {
  background-color: #66bb6a;
  color: #fff;
}

.key-yellow {
  background-color: #fdd835;
  color: #000;
}

.key-gray {
  background-color: #444;
  color: #fff;
}

.special-key {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 0 12px; /* horizontal padding for text breathing room */
  min-width: 72px; /* ensure enough space for "Solve" */
  height: 44px;
  font-size: clamp(14px, 1.5vw, 18px); /* responsive font size */
  font-weight: bold;
  background-color: #1976d2;
  color: white;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: transform 0.1s ease;
  box-sizing: border-box;
  flex-shrink: 0;
  flex-grow: 1;
}
  .special-key:active {
    transform: scale(0.95);
  }

/* Responsive Layout */
@media (max-width: 480px) {
  .cell-wrapper .dx-texteditor-input {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
  }

  .color-selector {
    flex-wrap: wrap;
    justify-content: center;
  }

  .button-row {
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  .solve-btn {
    width: 100%;
    max-width: 240px;
    margin-left: 0;
  }

  .section-title {
    text-align: center;
    font-size: 3rem;
    font-weight: 600;
    color: #333;
    margin: 0;
  }

  [data-bs-theme="dark"] .section-title {
    color: #ddd;
  }

  .page-container,
  .action-section {
    padding-left: 8px;
    padding-right: 8px;
  }

  .button-and-results {
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  .results-section {
    margin-top: 8px;
    padding: 0 8px;
  }

  .result-listbox {
    max-height: 160px;
    font-size: 0.85rem;
  }
}

/* Tablet Layout */
@media (min-width: 481px) and (max-width: 768px) {
  .page-container,
  .action-section {
    padding-left: 16px;
    padding-right: 16px;
  }

  .key-btn {
    width: 42px;
    height: 52px;
    font-size: 17px;
  }

  .solve-btn {
    max-width: 280px;
  }

  .result-listbox {
    max-height: 180px;
    font-size: 0.95rem;
  }
}

/* Desktop Layout */
@media (min-width: 769px) {
  .page-container,
  .action-section {
    padding-left: 24px;
    padding-right: 24px;
  }

  .key-btn {
    width: 48px;
    height: 56px;
    font-size: 18px;
  }

  .solve-btn {
    max-width: 320px;
  }

  .result-listbox {
    max-height: 200px;
    font-size: 1rem;
  }
}

@media (max-width: 1024px) {
  .solve-btn {
    width: 100%;
    max-width: 240px;
  }

  .button-row {
    flex-direction: column;
    align-items: center;
  }
}
/* Landscape Mode Tweaks */
@media (orientation: landscape) and (max-width: 768px) {
  .game-keyboard {
    flex-direction: row;
    /*flex-wrap: wrap;*/
    justify-content: center;
    padding: 8px;
  }

  .key-btn {
    width: 32px;
    height: 40px;
    font-size: 14px;
  }

  .guess-row {
    justify-content: center;
    gap: 6px;
  }
}

/* iPad Pro Portrait (11" and 12.9") */
@media (min-width: 1024px) and (max-width: 1366px) and (orientation: portrait) {
  .page-container,
  .action-section {
    max-width: 900px;
    padding-left: 40px;
    padding-right: 40px;
  }
  .section-title {
    font-size: 3.5rem;
  }
  .cell-wrapper .dx-texteditor-input {
    width: 64px;
    height: 64px;
    font-size: 2.2rem;
  }
  .key-btn, .special-key {
    width: 56px;
    height: 64px;
    font-size: 1.25rem;
  }
  .solve-btn {
    font-size: 1.1rem;
    max-width: 400px;
    height: 44px;
  }
  .result-listbox {
    max-height: 320px;
    font-size: 1.1rem;
  }
  .toast-message {
    font-size: 1.25rem;
    padding: 20px 40px;
  }
}

/* iPad Pro Landscape (11" and 12.9") */
@media (min-width: 1366px) and (orientation: landscape) {
  .page-container,
  .action-section {
    max-width: 1200px;
    padding-left: 60px;
    padding-right: 60px;
  }
  .section-title {
    font-size: 4rem;
  }
  .cell-wrapper .dx-texteditor-input {
    width: 72px;
    height: 72px;
    font-size: 2.5rem;
  }
  .key-btn, .special-key {
    width: 64px;
    height: 72px;
    font-size: 1.35rem;
  }
  .solve-btn {
    font-size: 1.2rem;
    max-width: 480px;
    height: 52px;
  }
  .result-listbox {
    max-height: 400px;
    font-size: 1.2rem;
  }
  .toast-message {
    font-size: 1.35rem;
    padding: 24px 48px;
  }
}

/* iPhone 14 Pro Portrait (393x852) and Landscape (852x393) */
@media (max-width: 430px) and (max-height: 932px) {
  .page-container,
  .action-section {
    padding-left: 4px;
    padding-right: 4px;
    max-width: 100vw;
  }
  .section-title {
    font-size: 2.1rem;
    padding: 0 2px;
    text-align: center;
  }
  .cell-wrapper .dx-texteditor-input {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }
  .key-btn, .special-key {
    width: 30px;
    height: 36px;
    font-size: 0.95rem;
  }
  .solve-btn {
    font-size: 0.95rem;
    max-width: 180px;
    height: 32px;
    padding: 0 8px;
  }
  .result-listbox {
    max-height: 100px;
    font-size: 0.85rem;
  }
  .toast-message {
    font-size: 1rem;
    padding: 10px 12px;
    min-width: 160px;
    max-width: 90vw;
    word-break: break-word;
  }
  .close-button {
    font-size: 18px;
    padding: 4px 8px;
    margin-left: 8px;
  }
}

/* iPhone 14 Pro Landscape */
@media (max-width: 932px) and (max-height: 430px) and (orientation: landscape) {
  .page-container,
  .action-section {
    padding-left: 2px;
    padding-right: 2px;
    max-width: 100vw;
  }
  .section-title {
    font-size: 1.5rem;
    padding: 0 1px;
  }
  .cell-wrapper .dx-texteditor-input {
    width: 28px;
    height: 28px;
    font-size: 0.95rem;
  }
  .key-btn, .special-key {
    width: 24px;
    height: 28px;
    font-size: 0.8rem;
  }
  .solve-btn {
    font-size: 0.85rem;
    max-width: 120px;
    height: 26px;
    padding: 0 4px;
  }
  .result-listbox {
    max-height: 60px;
    font-size: 0.7rem;
  }
  .toast-message {
    font-size: 0.9rem;
    padding: 6px 8px;
    min-width: 120px;
    max-width: 90vw;
    word-break: break-word;
  }
  .close-button {
    font-size: 14px;
    padding: 2px 4px;
    margin-left: 4px;
  }
}

/* iPhone 16 Pro Max Portrait (430x932) and Landscape (932x430) */
@media (max-width: 450px) and (max-height: 950px) {
  .page-container,
  .action-section {
    padding-left: 2px;
    padding-right: 2px;
    max-width: 100vw;
  }
  .section-title {
    font-size: 2.3rem;
    padding: 0 2px;
    text-align: center;
  }
  .cell-wrapper .dx-texteditor-input {
    width: 38px;
    height: 38px;
    font-size: 1.15rem;
  }
  .key-btn, .special-key {
    width: 32px;
    height: 38px;
    font-size: 1rem;
  }
  .solve-btn {
    font-size: 1rem;
    max-width: 200px;
    height: 34px;
    padding: 0 10px;
  }
  .result-listbox {
    max-height: 110px;
    font-size: 0.9rem;
  }
  .toast-message {
    font-size: 1.05rem;
    padding: 12px 14px;
    min-width: 170px;
    max-width: 92vw;
    word-break: break-word;
  }
  .close-button {
    font-size: 20px;
    padding: 5px 10px;
    margin-left: 10px;
  }
}

/* iPhone 16 Pro Max Landscape */
@media (max-width: 950px) and (max-height: 450px) and (orientation: landscape) {
  .page-container,
  .action-section {
    padding-left: 1px;
    padding-right: 1px;
    max-width: 100vw;
  }
  .section-title {
    font-size: 1.7rem;
    padding: 0 1px;
  }
  .cell-wrapper .dx-texteditor-input {
    width: 30px;
    height: 30px;
    font-size: 1rem;
  }
  .key-btn, .special-key {
    width: 26px;
    height: 30px;
    font-size: 0.85rem;
  }
  .solve-btn {
    font-size: 0.9rem;
    max-width: 130px;
    height: 28px;
    padding: 0 5px;
  }
  .result-listbox {
    max-height: 70px;
    font-size: 0.75rem;
  }
  .toast-message {
    font-size: 0.95rem;
    padding: 7px 9px;
    min-width: 130px;
    max-width: 92vw;
    word-break: break-word;
  }
  .close-button {
    font-size: 15px;
    padding: 3px 5px;
    margin-left: 5px;
  }
}

/* iPhone 16 Pro Portrait (393x852) and Landscape (852x393) */
@media (max-width: 400px) and (max-height: 870px) {
  .page-container,
  .action-section {
    padding-left: 3px;
    padding-right: 3px;
    max-width: 100vw;
  }

  .section-title {
    font-size: 2rem;
    padding: 0 2px;
    text-align: center;
  }

  .cell-wrapper .dx-texteditor-input {
    width: 34px;
    height: 34px;
    font-size: 1rem;
  }

  .key-btn, .special-key {
    width: 28px;
    height: 34px;
    font-size: 0.9rem;
  }

  .solve-btn {
    font-size: 0.9rem;
    max-width: 160px;
    height: 28px;
    padding: 0 6px;
  }

  .result-listbox {
    max-height: 90px;
    font-size: 0.8rem;
  }

  .toast-message {
    font-size: 0.95rem;
    padding: 8px 10px;
    min-width: 120px;
    max-width: 90vw;
    word-break: break-word;
  }

  .close-button {
    font-size: 16px;
    padding: 3px 6px;
    margin-left: 6px;
  }
}

/* iPhone 16 Pro Landscape */
@media (max-width: 870px) and (max-height: 400px) and (orientation: landscape) {
  .page-container,
  .action-section {
    padding-left: 1px;
    padding-right: 1px;
    max-width: 100vw;
  }

  .section-title {
    font-size: 1.3rem;
    padding: 0 1px;
  }

  .cell-wrapper .dx-texteditor-input {
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
  }

  .key-btn, .special-key {
    width: 20px;
    height: 24px;
    font-size: 0.7rem;
  }

  .solve-btn {
    font-size: 0.8rem;
    max-width: 90px;
    height: 20px;
    padding: 0 3px;
  }

  .result-listbox {
    max-height: 40px;
    font-size: 0.65rem;
  }

  .toast-message {
    font-size: 0.8rem;
    padding: 4px 6px;
    min-width: 80px;
    max-width: 90vw;
    word-break: break-word;
  }

  .close-button {
    font-size: 12px;
    padding: 2px 3px;
    margin-left: 3px;
  }
}

.toast-message {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #333;
  color: #fff;
  padding: 10px 15px;
  border-radius: 0;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  position: fixed;
  top: 0; /* Stick to the very top */
  left: 0;
  right: 0;
  width: 100vw;
  min-width: 0;
  max-width: 100vw;
  z-index: 1000;
  box-sizing: border-box;
}

.close-button {
  background: none;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  margin-left: 10px;
}

  .close-button:hover {
    color: #ff5c5c;
  }

/* Increase the spacing between keys on the keyboard by 1px in all cases */
.key-row {
  gap: 6px; /* was 4px, now 5px */
}

@keyframes shake {
  10%, 90% {
    transform: translateX(-2px);
  }

  20%, 80% {
    transform: translateX(4px);
  }

  30%, 50%, 70% {
    transform: translateX(-8px);
  }

  40%, 60% {
    transform: translateX(8px);
  }
}

.shake {
  animation: shake 0.5s;
}

body .components-reconnect-modal {
  display: none;
}

@media (max-width: 600px) {
  .modal-dialog {
    width: 98vw !important;
    max-width: 98vw !important;
    min-width: 0 !important;
    left: 50% !important;
    top: 2vw !important;
    transform: translate(-50%, 0) !important;
    padding: 1rem !important;
    font-size: 1rem !important;
    max-height: 96vh !important;
    height: auto !important;
    overflow-y: auto !important;
    border-radius: 8px !important;
  }

  .modal-backdrop {
    min-width: 100vw !important;
    min-height: 100vh !important;
  }
}
.modal-dialog > .solve-btn {
  display: block;
  margin-left: auto;
  margin-right: auto;
  margin-top: 1rem;
}
@media only screen and (max-width: 450px) and (max-height: 450px) and (orientation: landscape) {
  body > :not(.landscape-blocker) {
    display: none !important;
  }

  .landscape-blocker {
    display: flex !important;
    position: fixed;
    z-index: 9999;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #222;
    color: #fff;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    text-align: center;
    padding: 2rem;
  }
}
@media (orientation: landscape) {
  .game-keyboard {
    width: 100vw !important;
    max-width: 100vw !important;
    left: 0 !important;
    right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    justify-content: center !important;
    padding-bottom: calc(env(safe-area-inset-bottom, 0) + 10px) !important;
  }

  .key-row {
    width: 100vw !important;
    justify-content: space-between !important;
    gap: 1vw !important; /* Responsive gap */
    padding-left: 2vw;
    padding-right: 2vw;
  }

  .key-btn:not(.special-key) {
    width: 7vw !important;
    height: 12vh !important;
    font-size: 2.5vw !important;
    min-width: 48px;
    min-height: 48px;
    max-width: 300px;
    max-height: 120px;
  }
  .key-btn.special-key {
    width: 15vw !important;
    height: 18vh !important;
    font-size: 3vw !important;
    min-width: 80px;
    min-height: 72px;
    max-width: 250px;
    max-height: 180px;
  }
}
@media (orientation: landscape) {
  .grid-container {
    margin-bottom: 22vh; /* Reserve space for the keyboard so the last row is always visible */
  }
}
