/* Small compatibility fixes only; original game theme remains in styles.css. */
/* The initial clues must beat the legacy font-size:0 rule, even with a stale v2 stylesheet. */
#sudoku-grid:not(.hide-clue-numbers) input[type='text'].sudoku-cell:disabled {
  font-size: 22px !important; color: black; -webkit-text-fill-color: black; opacity: 1;
}
#sudoku-grid.hide-clue-numbers input[type='text'].sudoku-cell:disabled { font-size: 0 !important; }
/* Keep the original 320px mobile / 500px desktop board, without overflowing narrow screens. */
div#sudoku-grid {
  width: min(320px, 100%); aspect-ratio: 1;
  grid-template-columns: repeat(9, minmax(0, 1fr)); grid-auto-rows: 1fr;
}
#sudoku-grid input.sudoku-cell { width: 100%; height: 100%; min-width: 0; min-height: 0; padding: 0; line-height: normal !important; }
@media (min-width: 768px) { div#sudoku-grid { width: min(500px, 100%); } }
/* Original pastel palette, switched by the original # rotation/mode control. */
#number-buttons:not(.no-rainbow) > button.C1, #sudoku-grid:not(.no-rainbow) input.sudoku-cell.C1 { background: #FFA8A8; }
#number-buttons:not(.no-rainbow) > button.C2, #sudoku-grid:not(.no-rainbow) input.sudoku-cell.C2 { background: #FFD1A8; }
#number-buttons:not(.no-rainbow) > button.C3, #sudoku-grid:not(.no-rainbow) input.sudoku-cell.C3 { background: #FFFFA8; }
#number-buttons:not(.no-rainbow) > button.C4, #sudoku-grid:not(.no-rainbow) input.sudoku-cell.C4 { background: #A8FFA8; }
#number-buttons:not(.no-rainbow) > button.C5, #sudoku-grid:not(.no-rainbow) input.sudoku-cell.C5 { background: #A8D1FF; }
#number-buttons:not(.no-rainbow) > button.C6, #sudoku-grid:not(.no-rainbow) input.sudoku-cell.C6 { background: #A8FFFF; }
#number-buttons:not(.no-rainbow) > button.C7, #sudoku-grid:not(.no-rainbow) input.sudoku-cell.C7 { background: #FFA8FF; }
#number-buttons:not(.no-rainbow) > button.C8, #sudoku-grid:not(.no-rainbow) input.sudoku-cell.C8 { background: #FFA8D1; }
#number-buttons:not(.no-rainbow) > button.C9, #sudoku-grid:not(.no-rainbow) input.sudoku-cell.C9 { background: #A9A8FF; }
#sudoku-grid input.sudoku-cell.selected:not(:disabled) { outline: 2px solid #1d61a0; outline-offset: -3px; }
#sudoku-grid input.sudoku-cell.is-invalid { box-shadow: inset 0 0 0 2px #b62626 !important; }
#game button:disabled, #fund-Wallet:disabled { opacity: .55; filter: none !important; transform: none !important; animation: none !important; cursor: not-allowed; }
#fund-Wallet { background: #5ea3e4; }
/* Avoid cropping the original title, number row, and referral entry at phone widths. */
@media (max-width: 575px) {
  h1#title { font-size: clamp(30px, 9.5vw, 55px); letter-spacing: 2px; }
  div#number-buttons { display: flex; justify-content: center; width: 100%; max-width: 320px; gap: 3px; padding: 5px 0; }
  div#number-buttons > button { flex: 0 1 30px; min-width: 0; margin: 0 !important; }
  div#game-perks { padding: 12px 8px; }
  div#game-perks button { font-size: 11px; margin: 5px 2px !important; }
  div#game-perks > div > button > i { margin: 0; padding: 0 2px; }
  #swapNumbers > i { margin-top: 0 !important; }
  div#gotReferredBy { margin: 20px 0; padding: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
  input#referredBy { flex: 1 1 100%; min-width: 0; width: 100%; font: 16px 'Noto Sans', sans-serif; }
  #gotReferredBy #submitReferral { margin: 0 0 8px; }
  #gotReferredBy > p { flex-basis: 100%; }
  div#buy-sell-tokens { display: flex; width: 100%; }
  div#buy-sell-tokens > button { min-width: 0; flex: 1; }
}
/* Keep the existing optional chat independent from wallet/game loading. */
#chat-button { position: fixed; right: 122px; bottom: 10px; height: 30px; width: 32px; border: 0; padding: 2px; background: #4bbf48; z-index: 3; }
#chat-container { position: fixed; right: 14px; bottom: 65px; width: min(360px, calc(100vw - 28px)); height: min(500px, calc(100dvh - 90px)); display: flex; flex-direction: column; background: #fff; box-shadow: 0 8px 32px #0003; border: 1px solid #bac5d2; z-index: 10000; font-family: 'Noto Sans', sans-serif; }
#chat-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px; background: #5ea3e4; font-size: 12px; }
#chat-header button { font-size: 22px; padding: 0 8px; background: transparent; }
#peer-count { padding: 4px 12px; color: #566476; }
#chat-messages { flex: 1; overflow: auto; padding: 10px; font-size: 12px; overflow-wrap: anywhere; }
#chat-input-container { display: flex; gap: 6px; padding: 10px; }
#chat-input { min-width: 0; flex: 1; padding: 8px; border: 1px solid #cbd2dc; font-size: 14px; }
#chat-input-container button { padding: 8px; background: #5ea3e4; }
@media (prefers-reduced-motion: reduce) {
  #game *, #sudoku-grid, #number-buttons * { animation: none !important; transition: none !important; }
}
