/* cosy-crossword/cosy-crossword.css */
:root {
  --game-accent: #3730A3;
  --game-accent-dim: rgba(55, 48, 163, 0.15);
  --game-accent-contrast: #ffffff;
}

[data-context="phone"] {
  --game-accent: #3730A3;
}

[data-context="projector"] {
  --game-accent: #312E81;
}

/* Crossword Container & Layout */
.cw-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
  box-sizing: border-box;
}

.cw-header-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.cw-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.cw-game-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #1e1b4b;
}

.cw-level-badge {
  background: var(--game-accent-dim);
  color: var(--game-accent);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

/* Grid Box */
.cw-grid-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.cw-grid-wrapper {
  overflow-x: auto;
  max-width: 100%;
  padding: 0.5rem;
}

.cw-grid {
  display: grid;
  gap: 3px;
  background: #1e1b4b;
  padding: 6px;
  border-radius: 8px;
  user-select: none;
}

/* Crossword Cell Tiles */
.cw-cell {
  position: relative;
  width: 44px;
  height: 44px;
  background: #f8fafc;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  color: #1e1b4b;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.cw-cell.black {
  background: #1e1b4b;
  cursor: default;
}

.cw-cell-num {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 0.65rem;
  font-weight: 700;
  color: #64748b;
  line-height: 1;
  pointer-events: none;
}

.cw-cell-letter {
  display: inline-block;
  line-height: 1;
  text-transform: uppercase;
}

.cw-cell.selected {
  background: #e0e7ff;
  outline: 2px solid var(--game-accent);
  z-index: 2;
}

.cw-cell.active-word {
  background: #eef2ff;
}

.cw-cell.correct {
  background: #e0e7ff;
  color: #3730A3;
}

/* Stamped Ink Texture & Opacity Pulse */
@keyframes inkStampPulse {
  0% {
    transform: scale(1.15) rotate(-2deg);
    opacity: 0.5;
    background-color: #c7d2fe;
    box-shadow: inset 0 0 8px rgba(55, 48, 163, 0.4);
  }
  50% {
    transform: scale(0.96) rotate(1deg);
    opacity: 0.85;
    background-color: #a5b4fc;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
    background-color: #e0e7ff;
    box-shadow: inset 0 0 0px transparent;
  }
}

.ink-stamp-pulse {
  animation: inkStampPulse var(--motion-duration-fast, 150ms) cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Cascading Word Stamp Animation */
@keyframes cascadeStamp {
  0% {
    transform: scale(1.2);
    box-shadow: 0 0 12px var(--game-accent);
    background: #a5b4fc;
  }
  100% {
    transform: scale(1);
    box-shadow: none;
    background: #e0e7ff;
  }
}

.cw-cell.word-stamped {
  animation: cascadeStamp 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Active Clue Highlight */
.cw-clue-highlight {
  outline: 3px solid var(--game-accent) !important;
  border-color: var(--game-accent) !important;
  box-shadow: 0 0 12px rgba(55, 48, 163, 0.3) !important;
  transition: all 0.3s ease;
}

/* Online Multi-player Cell Border Tints & Avatar Chips */
.player-border-p1 {
  border: 2px solid #4F46E5 !important;
  box-shadow: 0 0 6px rgba(79, 70, 229, 0.4);
}

.player-border-p2 {
  border: 2px solid #059669 !important;
  box-shadow: 0 0 6px rgba(5, 150, 105, 0.4);
}

.player-border-p3 {
  border: 2px solid #D97706 !important;
  box-shadow: 0 0 6px rgba(217, 119, 6, 0.4);
}

.player-border-p4 {
  border: 2px solid #E11D48 !important;
  box-shadow: 0 0 6px rgba(225, 29, 72, 0.4);
}

.cw-avatar-chip {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  font-size: 8px;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 3;
}

.chip-p1 { background: #4F46E5; }
.chip-p2 { background: #059669; }
.chip-p3 { background: #D97706; }
.chip-p4 { background: #E11D48; }

/* Clues Section Layout */
.cw-clues-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.cw-clues-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.cw-clues-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #1e1b4b;
  margin-bottom: 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--game-accent-dim);
}

.cw-clue-item {
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.88rem;
  color: #334155;
  cursor: pointer;
  margin-bottom: 0.3rem;
  transition: all 0.2s ease;

}

.cw-clue-item:hover {
  background: #f1f5f9;
}

.cw-clue-item.active {
  background: var(--game-accent-dim);
  color: var(--game-accent);
  font-weight: 700;
}

.cw-clue-item.completed {
  text-decoration: line-through;
  opacity: 0.5;
}

/* Phone Layout Context Improvements */
[data-context="phone"] .cw-container {
  padding: 0.5rem;
  gap: 0.75rem;
  padding-bottom: 180px; /* Space for sticky clue & thumb-zone keyboard */
}

[data-context="phone"] .cw-clues-container {
  grid-template-columns: 1fr;
}

[data-context="phone"] .cw-grid-card {
  padding: 0.75rem 0.5rem;
}

[data-context="phone"] .cw-cell {
  width: 34px;
  height: 34px;
  font-size: 1rem;
}

[data-context="phone"] .cw-cell-num {
  font-size: 0.55rem;
  top: 1px;
  left: 2px;
}

/* Sticky Bottom Thumb-zone Dock & TurnBanner Clue Header */
.cw-phone-dock {
  display: none;
}

[data-context="phone"] .cw-phone-dock {
  display: flex;
  flex-direction: column;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: #ffffff;
  border-top: 2px solid var(--game-accent);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.15);
}

.cw-sticky-clue-banner {
  width: 100%;
  box-sizing: border-box;
}

.cw-keyboard-thumbzone {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  background: #f1f5f9;
}

.cw-kb-row {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.cw-kb-key {
  flex: 1;
  max-width: 36px;
  height: 42px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 800;
  color: #1e1b4b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  user-select: none;
}

.cw-kb-key:active {
  background: var(--game-accent);
  color: #ffffff;
}

.cw-kb-key.wide {
  max-width: 56px;
  font-size: 0.8rem;
}
