/* Minimal styling for Morse Drill game */
html, body { height: 100%; }
body { -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale; }
#morse-game { margin-top: 16px; }
#morse-game h4 { margin-bottom: 12px; }
/* scale target word responsively between small and large screens */
#target-word { font-size: clamp(28px, 6vw, 56px); font-weight: 700; margin-bottom: 8px; }
#input-display { font-family: monospace; font-size: 1.125rem; }
#buttons button { min-width: 56px; margin-right: 8px; }
#result { margin-top: 10px; font-weight: 600; }
.win { color: green; }
.lose { color: red; }

/* Morse symbol styling for better visibility while keeping meaning */
.morse-symbol { display: inline-block; vertical-align: middle; margin-right: 4px; }
.morse-dot { width: 0.9em; height: 0.9em; background: #222; border-radius: 50%; display: inline-block; margin-right: 6px; }
.morse-dash { width: 1.4em; height: 0.28em; background: #222; display: inline-block; border-radius: 3px; margin-right: 6px; }
.morse-text { font-family: monospace; }

/* Small instruction text */
#instructions { margin-top:8px; color:#333; }

/* Center game area and make instructions coherent */
.morse-center { text-align: center; max-width: 760px; margin: 0 auto; padding: 0 12px; }
.target-label { color:#666; margin-bottom:6px; }
.help-text { color:#444; margin: 0 auto 6px; max-width:720px; }
.inline-instructions { display:inline-flex; align-items:center; gap:8px; margin-bottom:8px; white-space:nowrap; }

.kbd-inline { display:inline-block; padding:3px 6px; background:#efefef; border-radius:4px; border:1px solid #ddd; font-family:monospace; font-weight:700; }
.touch-friendly #buttons { display:flex; justify-content:center; gap:12px; }
#buttons { display:flex; justify-content:center; gap:8px; }
.instr-sep { color:#666; }
.label-small { font-size:12px; color:#333; }
.quick-hint { margin-top:8px; color:#555; font-size:13px; }
.example { margin-top:10px; font-size:13px; color:#444; }
.example-label { font-weight:700; margin-right:6px; }

/* Timer display */
.timer-display { margin-top:8px; font-weight:600; color:#333; }

/* Keyboard-style cheatsheet */
.keyboard-cheatsheet { max-width: 880px; margin: 8px 0 24px; }
.kbd-row { display:flex; justify-content:flex-start; margin-bottom:8px; flex-wrap:nowrap; }
.kbd-key { display:flex; flex-direction:column; align-items:center; justify-content:center; width:110px; height:110px; min-width:110px; margin-right:10px; background:#f7f7f7; border:1px solid #ddd; border-radius:8px; box-shadow:0 1px 0 rgba(0,0,0,0.04); padding:8px; }
.kbd-key .char { font-weight:700; font-size:20px; }
.kbd-key .morse { font-size:14px; color:#333; margin-top:8px; white-space:nowrap; }

/* Row offsets to mimic physical keyboard staggering */
.keyboard-cheatsheet .kbd-row:nth-child(2) { margin-left:8px; }
.keyboard-cheatsheet .kbd-row:nth-child(3) { margin-left:26px; }
.keyboard-cheatsheet .kbd-row:nth-child(4) { margin-left:44px; }

@media (max-width: 1200px) {
 	.keyboard-cheatsheet { max-width:100%; }
 	.kbd-key { width:92px; height:92px; min-width:92px; }
 	.keyboard-cheatsheet .kbd-row:nth-child(2) { margin-left:6px; }
 	.keyboard-cheatsheet .kbd-row:nth-child(3) { margin-left:18px; }
 	.keyboard-cheatsheet .kbd-row:nth-child(4) { margin-left:30px; }
}

/* Make number-row morse text slightly smaller and add horizontal padding
   so numeric Morse codes never appear squeezed inside keys. */
.keyboard-cheatsheet .kbd-row:first-child .morse {
  font-size: 10px;
  padding: 0 10px;
  box-sizing: border-box;
  white-space: nowrap;
}

@media (max-width: 720px) {
 	/* make layout fluid on small devices: keys wrap and take percentage widths */
 	.kbd-row { flex-wrap:wrap; }
 	.kbd-key { flex: 0 0 calc(33.333% - 8px); width: auto; height: auto; min-width:0; margin-right:6px; padding:10px; box-sizing:border-box; }
 	.kbd-key .char { font-size:1.05rem; }
 	.kbd-key .morse { font-size:0.9rem; margin-top:6px; white-space:normal; }
 	.keyboard-cheatsheet .kbd-row:nth-child(2), .keyboard-cheatsheet .kbd-row:nth-child(3), .keyboard-cheatsheet .kbd-row:nth-child(4) { margin-left:0; }

 	/* enlarge interactive buttons and spacing for touch */
 	#buttons { gap:12px; }
 	#buttons button { min-width:64px; padding:10px 14px; font-size:1.05rem; }

 	/* increase visibility and spacing of helper text */
 	.inline-instructions { gap:12px; white-space:normal; }
}

/* Helper class to force touch-friendly layout when running on touch devices */
@media (pointer: coarse) {
  .touch-friendly #buttons button { min-width:72px; padding:12px 16px; font-size:1.1rem; }
  .touch-friendly .kbd-key { padding:12px; }
}

/* Hide keyboard-only hints (Esc / Enter) on touch devices where those keys aren't available */
.touch-friendly .quick-hint { display: none !important; }
@media (pointer: coarse) {
	.quick-hint { display: none !important; }
}

/* Extra adjustments for very small mobile screens (e.g. older iPhones, small viewports) */
@media (max-width: 420px) {
	body { font-size: 16px; }
	#input-display { font-size: 1.125rem; }
	.quick-hint, .example, .target-label
	.inline-instructions { gap:10px; }
	.morse-dot { width: 1.05em; height: 1.05em; }
	.morse-dash { width: 1.8em; height: 0.34em; }
	/* make the main target very prominent on small screens */
	#target-word { font-size: clamp(32px, 10vw, 72px); }
	/* enlarge buttons for easier tapping */
	#buttons button { min-width:72px; padding:10px 14px; font-size:1.05rem; }
	/* reduce cheatsheet visual weight on small devices */
	.keyboard-cheatsheet { opacity: 0.95; }
	.kbd-key { font-size: 0.95rem; }
}

/* Cheatsheet toggle button next to heading */
#cheatsheet-toggle { margin-left:8px; vertical-align:middle; }
#cheatsheet-toggle .glyphicon { margin-top:0; font-size:1.5rem; vertical-align:middle; display:inline-block; }

/* Remove dark focus/selection box on the toggle while keeping accessibility state via aria */
#cheatsheet-toggle:focus, #cheatsheet-toggle:active, #cheatsheet-toggle:focus-visible {
	outline: none !important;
	box-shadow: none !important;
}

/* Prevent mobile tap highlight and accidental text selection when clicking the icon */
#cheatsheet-toggle {
	-webkit-tap-highlight-color: transparent;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}

/* Ensure the inner icon doesn't show any focus ring either */
#cheatsheet-toggle .glyphicon {
	outline: none;
}
