/* Word Search: Ocean of Softwares */
.ws {
  --navy-900: #0b2447;
  --navy-800: #19376d;
  --navy-700: #1c4483;
  --navy-500: #3d76c9;
  --gold: #f2b134;
  --bg: #f3f6fb;
  --card: #ffffff;
  --text: #13233f;
  --muted: #5b6b85;
  --border: #dbe3ef;
  width: 100%;
  max-width: 1000px;
  margin: 18px auto;
  padding: 20px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 14px 36px rgba(11, 36, 71, 0.12);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  line-height: 1.5;
  box-sizing: border-box;
}
.ws *, .ws *::before, .ws *::after { box-sizing: border-box; }
.ws button, .ws select { font: inherit; }
.ws button:focus-visible, .ws select:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.ws-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 14px; }
.ws-title h1 { margin: 0; font-size: clamp(26px, 3.6vw, 34px); color: var(--navy-900); letter-spacing: -0.4px; line-height: 1.1; }
.ws-title h1 span { color: var(--gold); }
.ws-title p { margin: 3px 0 0; color: var(--muted); font-size: 15px; }

.ws-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.ws-select {
  appearance: none; -webkit-appearance: none;
  padding: 8px 34px 8px 12px; border-radius: 11px; border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-weight: 600; font-size: 14.5px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--navy-700) 50%), linear-gradient(135deg, var(--navy-700) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.ws-seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border); }
.ws-seg button { border: 0; background: transparent; color: var(--muted); font-weight: 700; font-size: 14px; padding: 7px 13px; border-radius: 9px; cursor: pointer; }
.ws-seg button.active { background: var(--navy-700); color: #fff; }

.ws-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.ws-stat { text-align: center; padding: 8px 6px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border); }
.ws-stat b { display: block; font-size: 24px; font-weight: 800; color: var(--navy-700); font-variant-numeric: tabular-nums; line-height: 1.2; }
.ws-stat.best b { color: #b97c06; }
.ws-stat span { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); }

.ws-msg { margin: 0 0 12px; padding: 9px 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border); font-weight: 600; font-size: 15px; min-height: 42px; }
.ws-msg.good { border-color: #5fd4c4; background: #ebfbf8; color: #0d5b51; }
.ws-msg.warn { border-color: var(--gold); background: #fff7e6; color: #7a5200; }

.ws-main { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 18px; align-items: start; }
.ws-board {
  position: relative; width: 100%; max-width: 600px; margin: 0 auto; aspect-ratio: 1 / 1;
  border-radius: 16px; padding: 10px;
  background: linear-gradient(160deg, var(--navy-900), var(--navy-800));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.ws-board svg, .ws-grid { position: absolute; inset: 10px; width: calc(100% - 20px); height: calc(100% - 20px); }
.ws-board svg { pointer-events: none; z-index: 1; overflow: visible; }
.ws-board svg line { stroke-width: 0.78; stroke-linecap: round; opacity: 0.6; }
.ws-board svg line.found { animation: ws-draw 0.35s ease-out; }
.ws-board svg line.revealed { opacity: 0.45; }
.ws-board svg line.sel { opacity: 1; }
@keyframes ws-draw { from { opacity: 0; } to { opacity: 0.6; } }
.ws-grid {
  z-index: 2; display: grid; user-select: none; -webkit-user-select: none; touch-action: none; cursor: pointer;
}
.ws-cell {
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-family: "Segoe UI", system-ui, Arial, sans-serif;
  font-size: clamp(14px, 2.6vw, 25px); border-radius: 50%;
}
.size-11 .ws-cell { font-size: clamp(13px, 2.2vw, 22px); }
.size-14 .ws-cell { font-size: clamp(12px, 1.8vw, 19px); }
.ws-cell.tap { box-shadow: inset 0 0 0 2px var(--gold); background: rgba(242, 177, 52, 0.25); }
.ws-cell.hint { animation: ws-hint 0.6s ease-in-out 3; background: rgba(242, 177, 52, 0.55); }
@keyframes ws-hint { 50% { transform: scale(1.25); } }

.ws-side { display: flex; flex-direction: column; gap: 12px; }
.ws-side h2 { margin: 0; font-size: 16px; color: var(--navy-900); text-transform: uppercase; letter-spacing: 0.6px; }
.ws-words { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ws-words li {
  padding: 6px 8px; border-radius: 9px; background: var(--bg); border: 1px solid var(--border);
  font-weight: 700; font-size: 13.5px; letter-spacing: 0.4px; text-align: center; overflow-wrap: anywhere;
}
.ws-words li.found { text-decoration: line-through; color: var(--muted); border-color: var(--wc, var(--gold)); box-shadow: inset 4px 0 0 var(--wc, var(--gold)); }
.ws-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ws-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 12px; border-radius: 11px; border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-weight: 700; font-size: 14.5px; cursor: pointer;
}
.ws-btn:hover { border-color: var(--navy-500); }
.ws-btn.primary { background: var(--navy-700); border-color: var(--navy-700); color: #fff; }
.ws-btn.primary:hover { background: var(--navy-900); }
.ws-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.ws-tip { margin: 0; font-size: 13px; color: var(--muted); }
.ws-print-title { display: none; }

/* Win modal */
.ws-modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(11, 36, 71, 0.55); backdrop-filter: blur(3px); }
.ws-modal.hidden { display: none; }
.ws-modal-card { width: 100%; max-width: 400px; background: #fff; border-radius: 20px; padding: 24px 22px; text-align: center; box-shadow: 0 24px 60px rgba(11, 36, 71, 0.35); animation: ws-pop 0.22s ease-out; }
.ws-modal-card h2 { margin: 0; font-size: 28px; color: var(--navy-900); }
.ws-modal-card p { margin: 4px 0 14px; color: var(--muted); }
.ws-modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ws-note { min-height: 1.4em; margin: 10px 0 4px !important; font-weight: 700; color: #b97c06 !important; }
.ws-modal-actions { display: flex; justify-content: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
@keyframes ws-pop { from { transform: scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }

/* Dark mode support for the shared site theme */
body.oos-dark .ws, body[data-theme="dark"] .ws { --bg: #0b1c33; --card: #0f2240; --text: #e8eef8; --muted: #9fb0ca; --border: #1f3a63; }

@media (max-width: 820px) {
  .ws { margin: 8px auto; padding: 14px 12px; border-radius: 16px; }
  .ws-main { grid-template-columns: 1fr; }
  .ws-board { padding: 6px; border-radius: 12px; }
  .ws-board svg, .ws-grid { inset: 6px; width: calc(100% - 12px); height: calc(100% - 12px); }
  .ws-words { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ws-buttons { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ws-btn { padding: 8px 6px; font-size: 13.5px; }
  .ws-controls { width: 100%; }
  .ws-title p { display: none; }
  .ws-head { margin-bottom: 10px; }
  .ws-stat { padding: 6px 4px; }
  .ws-stat b { font-size: 20px; }
  .ws-stat span { font-size: 11px; }
  .ws-msg { font-size: 14px; padding: 8px 12px; min-height: 0; margin-bottom: 10px; }
  .ws-select { flex: 1 1 140px; }
  .size-8 .ws-cell { font-size: 22px; }
  .size-11 .ws-cell { font-size: 18px; }
  .size-14 .ws-cell { font-size: 15px; }
}
@media (max-width: 420px) {
  .ws-words { grid-template-columns: 1fr 1fr; }
  .ws-buttons { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .ws *, .ws *::before, .ws *::after { animation: none !important; transition: none !important; }
}

/* Printable puzzle: only the grid, title and word list */
@media print {
  @page { margin: 14mm; }
  body.oos-game { background: #fff !important; }
  .oos-bar, .oos-content, .oos-footer, .ws-head, .ws-stats, .ws-msg, .ws-buttons, .ws-tip, .ws-modal { display: none !important; }
  .oos-stage { min-height: 0 !important; display: block !important; padding: 0 !important; }
  .ws { box-shadow: none; border: 0; padding: 0; margin: 0 auto; max-width: none; }
  .ws-print-title { display: block; margin: 0 0 10px; font-size: 22px; text-align: center; color: #000; }
  .ws-main { display: block; }
  .ws-board { background: #fff !important; max-width: 160mm; padding: 0; border: 2px solid #000; border-radius: 6px; }
  .ws-board svg { display: none; }
  .ws.answers .ws-board svg { display: block !important; inset: 0; width: 100%; height: 100%; }
  .ws.answers .ws-board svg line { opacity: 0.35 !important; stroke: #888 !important; }
  .ws-board .ws-grid { inset: 0; width: 100%; height: 100%; }
  .ws-cell { color: #000 !important; font-size: 15pt !important; background: none !important; box-shadow: none !important; }
  .ws-side { margin-top: 10mm; }
  .ws-side h2 { color: #000; }
  .ws-words { grid-template-columns: repeat(4, 1fr); }
  .ws-words li { background: #fff !important; border: 1px solid #999; color: #000 !important; text-decoration: none !important; box-shadow: none !important; }
}
