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

:root {
  --board-size: min(95vw, 600px);
  --cell-size: calc(var(--board-size) / 15);
  --color-3l: #4CAF50;
  --color-2l: #42A5F5;
  --color-2w: #EF5350;
  --color-3w: #FF9800;
  --color-center: #AB47BC;
  --color-placed: #C39B7A;
  --color-suggestion: #FF0000;
  --color-selected: #FF0000;
}

body {
  font-family: 'Comic Sans MS', 'Comic Sans', sans-serif;
  background: #f5f5f5;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 10px;
  -webkit-user-select: none;
  user-select: none;
}

h1 {
  font-size: 1.4rem;
  margin-bottom: 8px;
  color: #333;
}

/* Toolbar */
#toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

#board-type {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #999;
  background: #fff;
  cursor: pointer;
}

#save-slots {
  display: flex;
  gap: 4px;
}

.slot-btn {
  font-family: inherit;
  width: 30px;
  height: 30px;
  border: 2px solid #999;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.slot-btn:hover {
  background: #e0e0e0;
}

.slot-btn.active {
  border-color: #333;
  background: #333;
  color: #fff;
}

/* Import Board button in toolbar */
.import-toolbar-btn {
  font-family: inherit;
  font-size: 0.8rem;
  padding: 4px 10px;
  height: 30px;
  border: 2px solid #42A5F5;
  border-radius: 4px;
  background: #42A5F5;
  color: #fff;
  cursor: pointer;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  white-space: nowrap;
}

.import-toolbar-btn:hover {
  background: #1E88E5;
  border-color: #1E88E5;
}

/* Board */
#board-container {
  position: relative;
}

#board {
  display: grid;
  grid-template-columns: repeat(15, var(--cell-size));
  grid-template-rows: repeat(15, var(--cell-size));
  border: 2px solid #333;
  background: #333;
  gap: 1px;
}

.cell {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: calc(var(--cell-size) * 0.5);
  cursor: pointer;
  position: relative;
  font-weight: bold;
  transition: opacity 0.1s;
}

.cell:hover {
  opacity: 0.85;
}

/* Bonus squares */
.cell.bonus-3l {
  background: var(--color-3l);
  color: #fff;
  font-size: calc(var(--cell-size) * 0.35);
  font-weight: normal;
}

.cell.bonus-2l {
  background: var(--color-2l);
  color: #fff;
  font-size: calc(var(--cell-size) * 0.35);
  font-weight: normal;
}

.cell.bonus-2w {
  background: var(--color-2w);
  color: #fff;
  font-size: calc(var(--cell-size) * 0.35);
  font-weight: normal;
}

.cell.bonus-3w {
  background: var(--color-3w);
  color: #fff;
  font-size: calc(var(--cell-size) * 0.35);
  font-weight: normal;
}

.cell.bonus-center {
  background: var(--color-center);
  color: #fff;
  font-size: calc(var(--cell-size) * 0.45);
}

/* Letter states */
.cell.has-letter {
  background: var(--color-placed);
  color: #000;
  font-size: calc(var(--cell-size) * 0.55);
}

.cell.suggestion {
  color: var(--color-suggestion);
  font-size: calc(var(--cell-size) * 0.55);
}

.cell.selected {
  box-shadow: inset 0 0 0 3px var(--color-selected);
}

/* Letter value subscript */
.cell .letter-val {
  position: absolute;
  bottom: 1px;
  right: 2px;
  font-size: calc(var(--cell-size) * 0.22);
  font-weight: normal;
  opacity: 0.7;
}

/* Controls */
#controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  width: var(--board-size);
}

#hand-input {
  font-family: inherit;
  font-size: 1.2rem;
  padding: 8px 12px;
  border: 2px solid #999;
  border-radius: 4px;
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 4px;
  font-weight: bold;
  min-width: 0;
  outline: none;
  transition: border-color 0.15s;
}

#hand-input:focus {
  border-color: #42A5F5;
}

#solve-btn {
  font-family: inherit;
  font-size: 1rem;
  padding: 8px 20px;
  border: none;
  border-radius: 4px;
  background: #4CAF50;
  color: #fff;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.15s;
  white-space: nowrap;
}

#solve-btn:hover {
  background: #43A047;
}

#solve-btn:disabled {
  background: #999;
  cursor: not-allowed;
}

/* Status bar */
#status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: var(--board-size);
  margin-top: 6px;
  font-size: 0.85rem;
  color: #666;
  min-height: 24px;
}

#score-display {
  font-weight: bold;
  color: #4CAF50;
  font-size: 1rem;
}

/* Result navigation */
#result-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 6px;
  width: var(--board-size);
}

#result-counter {
  font-size: 0.85rem;
  font-weight: bold;
  color: #333;
  min-width: 50px;
  text-align: center;
}

.result-nav-btn {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 5px 14px;
  border: 2px solid #4CAF50;
  border-radius: 4px;
  background: #fff;
  color: #4CAF50;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.15s;
}

.result-nav-btn:hover:not(:disabled) {
  background: #4CAF50;
  color: #fff;
}

.result-nav-btn:disabled {
  border-color: #ccc;
  color: #ccc;
  cursor: not-allowed;
}

/* Wildcard suggestion tile */
.cell.suggestion.wildcard {
  color: #FF6600;
}

/* Bottom actions */
#actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.action-btn {
  font-family: inherit;
  font-size: 0.8rem;
  padding: 4px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  color: #666;
  transition: all 0.15s;
}

.action-btn:hover {
  background: #eee;
  border-color: #999;
}

/* Hidden input for mobile keyboard — must stay on-screen for iOS keyboard to appear */
#hidden-keyboard-input {
  position: fixed;
  bottom: 0;
  left: 50%;
  opacity: 0;
  width: 1px;
  height: 1px;
  border: none;
  padding: 0;
  pointer-events: none;
  z-index: -1;
}

/* Navigation */
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 700px;
  padding: 8px 16px;
  margin-bottom: 8px;
}

.nav-brand {
  font-weight: bold;
  font-size: 1rem;
  color: #333;
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 16px;
}

.nav-links a {
  color: #666;
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
  color: #333;
}

/* Tagline */
.tagline {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 8px;
}

/* Intro blurb on homepage */
.intro-blurb {
  max-width: 700px;
  text-align: left;
  margin-bottom: 12px;
  padding: 0 8px;
}

.intro-blurb p {
  color: #555;
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 6px;
}

.intro-blurb .intro-links {
  color: #666;
  font-size: 0.82rem;
}

.intro-blurb a {
  color: #42A5F5;
  text-decoration: none;
}

.intro-blurb a:hover {
  text-decoration: underline;
}

/* Info Sections */
.info-section {
  width: var(--board-size);
  max-width: 700px;
  margin-top: 32px;
  text-align: left;
}

.info-section h2 {
  font-size: 1.2rem;
  color: #333;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #eee;
}

/* Instructions */
.instructions-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.instruction-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.step-number {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #4CAF50;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.85rem;
}

.instruction-step strong {
  display: block;
  margin-bottom: 2px;
  color: #333;
}

.instruction-step p {
  color: #666;
  font-size: 0.85rem;
  line-height: 1.4;
}

/* Features Grid */
.features-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.feature-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 14px;
}

.feature-card strong {
  display: block;
  color: #333;
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.feature-card p {
  color: #666;
  font-size: 0.8rem;
  line-height: 1.4;
}

/* FAQ */
.faq-section details {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fff;
}

.faq-section summary {
  padding: 12px 14px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.9rem;
  color: #333;
}

.faq-section details[open] summary {
  border-bottom: 1px solid #e0e0e0;
}

.faq-section details p {
  padding: 12px 14px;
  color: #666;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Footer */
.site-footer {
  width: 100%;
  max-width: 700px;
  margin-top: 40px;
  padding: 20px 16px;
  border-top: 1px solid #ddd;
  text-align: center;
  font-size: 0.8rem;
  color: #999;
}

.site-footer a {
  color: #666;
  text-decoration: none;
}

.site-footer a:hover {
  color: #333;
}

.footer-disclaimer {
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #f0f0f0;
  border-radius: 6px;
  font-size: 0.72rem;
  line-height: 1.5;
  color: #777;
  text-align: left;
}

.footer-disclaimer p {
  margin-bottom: 6px;
}

.footer-disclaimer p:last-child {
  margin-bottom: 0;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 8px;
}

/* Content Pages (About, Privacy) */
.page-body {
  align-items: stretch;
}

.page-content {
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px;
  text-align: left;
}

.page-content h1 {
  font-size: 1.6rem;
  margin-bottom: 8px;
  text-align: left;
}

.page-content .last-updated {
  color: #999;
  font-size: 0.8rem;
  margin-bottom: 24px;
}

.page-content section {
  margin-bottom: 24px;
}

.page-content h2 {
  font-size: 1.1rem;
  color: #333;
  margin-bottom: 8px;
}

.page-content h3 {
  font-size: 0.95rem;
  color: #555;
  margin: 12px 0 6px;
}

.page-content p {
  color: #555;
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 8px;
}

.page-content ul {
  padding-left: 20px;
  margin-bottom: 8px;
}

.page-content li {
  color: #555;
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 4px;
}

.page-content a {
  color: #42A5F5;
  text-decoration: none;
}

.page-content a:hover {
  text-decoration: underline;
}

/* Mobile keyboard toolbar — hidden by default, shown via JS */
#mobile-keyboard-toolbar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: #e8e8e8;
  border-top: 1px solid #ccc;
  padding: 6px 12px;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

#mobile-keyboard-toolbar.visible {
  display: flex;
}

.kb-toolbar-btn {
  width: 36px;
  height: 36px;
  border: 1px solid #bbb;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.kb-toolbar-btn:active {
  background: #d0d0d0;
}

/* D-pad layout */
.kb-dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.kb-dpad-row {
  display: flex;
  gap: 2px;
}

.kb-dpad-spacer {
  width: 36px;
  height: 36px;
}

/* Zoom button group */
.kb-zoom-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kb-toolbar-sep {
  width: 1px;
  height: 50px;
  background: #ccc;
  align-self: center;
}

/* Import Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #eee;
}

.modal-header h3 {
  font-size: 1rem;
  color: #333;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #999;
  padding: 0 4px;
  line-height: 1;
}

.modal-close:hover {
  color: #333;
}

.modal-body {
  padding: 16px;
}

.modal-instructions {
  font-size: 0.82rem;
  color: #555;
  margin-bottom: 10px;
  line-height: 1.4;
}

.prompt-box {
  position: relative;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.prompt-box pre {
  font-family: inherit;
  font-size: 0.78rem;
  color: #444;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
  padding-right: 50px;
  line-height: 1.4;
}

.copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  font-family: inherit;
  font-size: 0.72rem;
  padding: 3px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  color: #555;
  transition: all 0.15s;
}

.copy-btn:hover {
  background: #eee;
}

#import-textarea {
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  width: 100%;
  padding: 10px;
  border: 2px solid #ddd;
  border-radius: 6px;
  resize: vertical;
  line-height: 1.3;
  letter-spacing: 2px;
  outline: none;
  transition: border-color 0.15s;
}

#import-textarea:focus {
  border-color: #42A5F5;
}

.import-error {
  color: #EF5350;
  font-size: 0.8rem;
  margin-top: 6px;
  min-height: 1.2em;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #eee;
}

.import-apply-btn {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 6px 16px;
  border: none;
  border-radius: 4px;
  background: #4CAF50;
  color: #fff;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.15s;
}

.import-apply-btn:hover {
  background: #43A047;
}

.create-board-option {
  font-style: italic;
  color: #666;
}

/* Board editor button in toolbar */
.board-editor-btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: bold;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #f5f5f5;
  cursor: pointer;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.board-editor-btn:hover {
  background: #e0e0e0;
  border-color: #999;
}

/* Board editor modal */
.board-editor-modal-content {
  max-width: 540px;
}

.board-editor-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.board-editor-name-row label {
  font-size: 0.82rem;
  color: #555;
  white-space: nowrap;
}

.board-editor-name-row input {
  flex: 1;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 5px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  outline: none;
}

.board-editor-name-row input:focus {
  border-color: #42A5F5;
}

.board-editor-palette {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.palette-btn {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: bold;
  padding: 5px 10px;
  border: 2px solid #ccc;
  border-radius: 4px;
  background: #f5f5f5;
  color: #555;
  cursor: pointer;
  transition: all 0.15s;
}

.palette-btn:hover {
  border-color: #888;
}

.palette-btn.active {
  border-color: #333;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.2);
}

.palette-btn.bonus-2l { background: #81D4FA; color: #0D47A1; }
.palette-btn.bonus-3l { background: #66BB6A; color: #1B5E20; }
.palette-btn.bonus-2w { background: #EF9A9A; color: #B71C1C; }
.palette-btn.bonus-3w { background: #FFB74D; color: #E65100; }

.board-editor-options {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.editor-checkbox {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: #555;
  cursor: pointer;
  user-select: none;
}

.editor-checkbox input {
  cursor: pointer;
}

.board-editor-grid {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  gap: 1px;
  background: #ccc;
  border: 1px solid #ccc;
  border-radius: 4px;
  overflow: hidden;
  max-width: 100%;
  aspect-ratio: 1;
}

.editor-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  font-weight: bold;
  cursor: pointer;
  background: #fff;
  color: #888;
  user-select: none;
  transition: background 0.1s;
  min-width: 0;
}

.editor-cell:hover {
  opacity: 0.8;
}

.editor-cell.bonus-2l { background: #81D4FA; color: #0D47A1; }
.editor-cell.bonus-3l { background: #66BB6A; color: #1B5E20; }
.editor-cell.bonus-2w { background: #EF9A9A; color: #B71C1C; }
.editor-cell.bonus-3w { background: #FFB74D; color: #E65100; }
.editor-cell.bonus-center { background: #CE93D8; color: #4A148C; }

.board-editor-footer {
  justify-content: space-between;
}

.board-editor-footer-right {
  display: flex;
  gap: 8px;
}

.board-editor-delete-btn {
  background: #EF5350;
  color: #fff;
  border-color: #EF5350;
}

.board-editor-delete-btn:hover {
  background: #E53935;
  border-color: #E53935;
}

/* Board container scrollable for zoom */
#board-container {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* Word list styles (word-lists.html) */
.word-list-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 16px;
}

.word-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.82rem;
  color: #555;
}

.word-chip strong {
  color: #333;
  font-size: 0.85rem;
}

.word-list-table {
  margin: 10px 0 16px;
  overflow-x: auto;
}

.word-list-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.word-list-table th {
  background: #f5f5f5;
  padding: 8px 12px;
  text-align: left;
  font-size: 0.82rem;
  color: #555;
  border-bottom: 2px solid #e0e0e0;
}

.word-list-table td {
  padding: 6px 12px;
  border-bottom: 1px solid #eee;
  color: #555;
}

.word-list-table tr:hover {
  background: #fafafa;
}

/* Practice page */
.practice-page {
  max-width: 600px;
}

.practice-setup {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 20px;
  margin: 16px 0;
}

.setup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.setup-row label {
  font-size: 0.9rem;
  color: #333;
  font-weight: bold;
}

.setup-row select {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.practice-start-btn {
  font-family: inherit;
  font-size: 1rem;
  padding: 10px 28px;
  border: none;
  border-radius: 6px;
  background: #4CAF50;
  color: #fff;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.15s;
  display: block;
  width: 100%;
  margin-top: 8px;
}

.practice-start-btn:hover {
  background: #43A047;
}

.practice-start-btn.secondary {
  background: #fff;
  color: #4CAF50;
  border: 2px solid #4CAF50;
}

.practice-start-btn.secondary:hover {
  background: #f0f9f0;
}

.practice-tiles {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.practice-tile {
  width: 48px;
  height: 48px;
  background: #C39B7A;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: bold;
  color: #000;
  position: relative;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.practice-tile sub {
  position: absolute;
  bottom: 3px;
  right: 5px;
  font-size: 0.6rem;
  font-weight: normal;
  opacity: 0.7;
}

.practice-stats {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 12px 0;
}

.practice-stat {
  font-size: 0.9rem;
  font-weight: bold;
  color: #333;
  background: #f5f5f5;
  padding: 4px 12px;
  border-radius: 4px;
}

.practice-stat.timer-warning {
  color: #EF5350;
  background: #fde8e8;
}

.practice-input-row {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.practice-input-row input {
  font-family: inherit;
  font-size: 1.1rem;
  padding: 8px 12px;
  border: 2px solid #ccc;
  border-radius: 6px;
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: bold;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}

.practice-input-row input:focus {
  border-color: #42A5F5;
}

.practice-submit-btn {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  background: #4CAF50;
  color: #fff;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.15s;
  white-space: nowrap;
}

.practice-submit-btn:hover {
  background: #43A047;
}

.practice-giveup-btn {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 8px 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  color: #666;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.practice-giveup-btn:hover {
  background: #eee;
  border-color: #999;
}

.practice-feedback {
  min-height: 1.4em;
  font-size: 0.88rem;
  font-weight: bold;
  text-align: center;
  margin: 4px 0;
}

.practice-feedback.success {
  color: #4CAF50;
}

.practice-feedback.error {
  color: #EF5350;
}

.practice-found h3 {
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 8px;
}

.practice-found .found-words-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.word-chip.missed {
  background: #fde8e8;
  border-color: #f5c6c6;
}

/* Results */
.results-summary {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 20px 0;
}

.result-stat {
  text-align: center;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 16px 20px;
  flex: 1;
}

.result-number {
  display: block;
  font-size: 1.8rem;
  font-weight: bold;
  color: #4CAF50;
}

.result-label {
  font-size: 0.78rem;
  color: #888;
  margin-top: 2px;
}

.missed-words {
  margin: 20px 0;
}

.missed-words h3 {
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 8px;
}

.missed-subtitle {
  font-weight: normal;
  font-size: 0.78rem;
  color: #999;
}

.missed-words .found-words-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.practice-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.practice-actions .practice-start-btn {
  flex: 1;
}

.practice-info {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 2px solid #eee;
}

.practice-info h2 {
  font-size: 1.1rem;
  color: #333;
  margin-bottom: 8px;
}

.practice-info p {
  color: #555;
  font-size: 0.88rem;
  line-height: 1.6;
  margin-bottom: 8px;
}

.practice-info ul {
  padding-left: 20px;
  margin-bottom: 8px;
}

.practice-info li {
  color: #555;
  font-size: 0.88rem;
  line-height: 1.6;
  margin-bottom: 4px;
}

.practice-info a {
  color: #42A5F5;
  text-decoration: none;
}

.practice-info a:hover {
  text-decoration: underline;
}

/* ===== Tool Tabs ===== */
.tool-tabs-wrapper {
  width: 100%;
  max-width: 700px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 12px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.tool-tabs-wrapper::-webkit-scrollbar {
  display: none;
}

.tool-tabs {
  display: flex;
  gap: 0;
  min-width: max-content;
  border-bottom: 2px solid #e0e0e0;
}

.tool-tab {
  font-family: inherit;
  font-size: 0.82rem;
  padding: 8px 16px;
  border: none;
  background: none;
  cursor: pointer;
  color: #888;
  font-weight: bold;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.tool-tab:hover {
  color: #555;
}

.tool-tab.active {
  color: #4CAF50;
  border-bottom-color: #4CAF50;
}

/* Tool Panels */
.tool-panel {
  display: none;
  width: 100%;
  max-width: 700px;
}

.tool-panel.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Solver panel keeps original layout */
#panel-solver.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Tool content wrapper for non-solver panels */
.tool-content {
  width: 100%;
  max-width: 600px;
  padding: 0 16px;
  text-align: left;
}

.tool-content h2 {
  font-size: 1.2rem;
  color: #333;
  margin-bottom: 6px;
}

.tool-desc {
  color: #666;
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 16px;
}

/* Tool input rows */
.tool-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}

.tool-input-row input[type="text"] {
  font-family: inherit;
  font-size: 1.1rem;
  padding: 8px 12px;
  border: 2px solid #ccc;
  border-radius: 6px;
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: bold;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}

.tool-input-row input[type="text"]:focus {
  border-color: #42A5F5;
}

.tool-input-row select {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 8px 10px;
  border: 2px solid #ccc;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.tool-action-btn {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  background: #4CAF50;
  color: #fff;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.15s;
  white-space: nowrap;
}

.tool-action-btn:hover {
  background: #43A047;
}

.tool-note {
  color: #888;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

/* Word Validator results */
.validator-valid {
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  border-radius: 8px;
  padding: 16px;
  font-size: 1rem;
  color: #2e7d32;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.validator-invalid {
  background: #fde8e8;
  border: 1px solid #f5c6c6;
  border-radius: 8px;
  padding: 16px;
  font-size: 1rem;
  color: #c62828;
}

.validator-score {
  font-size: 1.2rem;
  font-weight: bold;
  color: #4CAF50;
}

.validator-valid-small {
  color: #4CAF50;
  font-size: 0.82rem;
  font-weight: bold;
}

.validator-invalid-small {
  color: #EF5350;
  font-size: 0.82rem;
  font-weight: bold;
}

/* Anagram results */
.anagram-results-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 400px;
  overflow-y: auto;
}

/* Dictionary Browser */
.browser-letters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}

.browser-letter-btn {
  font-family: inherit;
  width: 32px;
  height: 32px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: bold;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.browser-letter-btn:hover {
  background: #f0f0f0;
  border-color: #999;
}

.browser-letter-btn.active {
  background: #4CAF50;
  color: #fff;
  border-color: #4CAF50;
}

.browser-words {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 500px;
  overflow-y: auto;
}

/* Responsive */
@media (max-width: 640px) {
  :root {
    --board-size: 100vw;
  }

  body {
    padding: 0;
  }

  h1 {
    font-size: 1.1rem;
    margin: 6px 0;
  }

  #toolbar {
    margin-bottom: 4px;
    padding: 0 4px;
  }

  #controls {
    padding: 0 4px;
  }

  #status-bar {
    padding: 0 8px;
  }

  .slot-btn {
    width: 26px;
    height: 26px;
    font-size: 0.75rem;
  }

  .site-nav {
    padding: 6px 8px;
  }

  .nav-links {
    gap: 10px;
  }

  .nav-links a {
    font-size: 0.75rem;
  }

  .info-section {
    padding: 0 8px;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }

  .site-footer {
    padding: 16px 8px;
  }

  .page-content {
    padding: 12px 8px;
  }

  .tool-tab {
    font-size: 0.75rem;
    padding: 6px 12px;
  }

  .tool-content {
    padding: 0 8px;
  }

  .tool-input-row {
    flex-wrap: wrap;
  }

  .tool-input-row input[type="text"] {
    font-size: 1rem;
  }

  .browser-letter-btn {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
  }

  /* Board container zoomed */
  #board-container {
    width: 100vw;
    max-height: 70vh;
    overflow: auto;
  }

  #board-container.zoomed {
    max-height: 50vh;
  }
}
