* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

html, body, #root {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #fff8e7;
  color: #5d4037;
  touch-action: manipulation;
}

button {
  border: none;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.home-page {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(20px, 5vw, 40px) clamp(12px, 4vw, 24px);
  overflow-y: auto;
}

.home-title {
  font-size: clamp(28px, 8vw, 48px);
  font-weight: 800;
  color: #e6a817;
  margin-bottom: 8px;
}

.home-subtitle {
  font-size: clamp(14px, 3.5vw, 18px);
  color: #8d6e63;
  margin-bottom: clamp(20px, 5vw, 36px);
}

.game-cards {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(12px, 3vw, 20px);
  justify-content: center;
  max-width: 600px;
  width: 100%;
}

.game-card {
  width: clamp(140px, 40vw, 200px);
  background: #f5e6c8;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.game-card:active {
  transform: scale(0.97);
}

.game-card-img {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #faeed8;
}

.game-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-card-placeholder {
  font-size: clamp(36px, 10vw, 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.game-card-info {
  padding: clamp(8px, 2vw, 12px);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.game-card-name {
  font-size: clamp(14px, 3.5vw, 17px);
  font-weight: 600;
}

.game-card-best {
  font-size: clamp(11px, 2.5vw, 13px);
  color: #e6a817;
}
.cross-math {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background: #fff8e7;
  position: relative;
  overflow: hidden;
}

.cross-math-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #f5e6c8;
  flex-shrink: 0;
  min-height: 44px;
}

.cross-math-back {
  color: #8d6e63;
  font-size: clamp(14px, 4vw, 18px);
  background: none;
  padding: 6px 10px;
  border-radius: 6px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cross-math-back:active {
  background: rgba(0,0,0,0.06);
}

.cross-math-title {
  font-size: clamp(16px, 4.5vw, 22px);
  font-weight: 700;
  color: #5d4037;
}

.cross-math-hint-btn {
  font-size: clamp(13px, 3.5vw, 16px);
  color: #e6a817;
  background: rgba(230,168,23,0.1);
  padding: 6px 14px;
  border-radius: 6px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cross-math-hint-btn:active {
  background: rgba(230,168,23,0.25);
}

.cross-math-timer {
  color: #e6a817;
  font-size: clamp(16px, 4vw, 22px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 44px;
  text-align: center;
}

/* Grid area */
.cross-math-grid-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 8px;
}

.cross-math-grid {
  position: relative;
  border-radius: 4px;
}

/* Grid cells */
.grid-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}

.grid-cell-number {
  background: #fff;
  color: #5d4037;
  border: 2px solid #e0d5c0;
}

.grid-cell-number.grid-fixed {
  background: #e8ddd0;
  color: #a08870;
  cursor: default;
}

.grid-cell-number.grid-fillable {
  cursor: pointer;
  border: 2px dashed #c0b090;
}

.grid-cell-number.grid-filled {
  border: 2px solid #e6a817;
  background: #fffbf0;
}

.grid-cell-number.grid-drag-over {
  border: 2px solid #f4c542;
  background: #fff9e6;
  transform: scale(1.05);
}

.grid-cell-operator {
  background: transparent;
  color: #c09030;
  font-size: clamp(12px, 3vw, 18px);
}

.grid-cell-equals {
  background: transparent;
  color: #c09030;
  font-size: clamp(14px, 3.5vw, 20px);
  font-weight: 700;
}

/* Invalid equation styling */
.grid-cell-operator.invalid,
.grid-cell-equals.invalid {
  color: #e53935;
}

.grid-cell-number.invalid-operation {
  border-color: #e53935;
  background: #ffebee;
}

/* Card pool */
.cross-math-pool {
  flex-shrink: 0;
  background: #f5e6c8;
  padding: 0 0 8px 0;
  min-height: 56px;
}

.cross-math-pool-label {
  font-size: 12px;
  color: #8d6e63;
  padding: 4px 12px 2px;
}

.cross-math-pool-scroll {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 2px 12px 4px;
  overflow-y: auto;
  max-height: 140px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.cross-math-pool-scroll::-webkit-scrollbar {
  display: none;
}

.pool-card {
  flex-shrink: 0;
  width: clamp(44px, 10vw, 56px);
  height: clamp(44px, 10vw, 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fffbf0;
  color: #5d4037;
  font-size: clamp(16px, 4vw, 22px);
  font-weight: 700;
  border-radius: 8px;
  touch-action: none;
  transition: transform 0.1s, opacity 0.15s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.pool-card:active {
  transform: scale(0.95);
}

/* Drag ghost */
.drag-ghost {
  position: fixed;
  z-index: 1000;
  width: clamp(48px, 12vw, 64px);
  height: clamp(48px, 12vw, 64px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f4c542;
  color: #5d4037;
  font-size: clamp(18px, 5vw, 26px);
  font-weight: 700;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

/* Result modal */
.result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.result-modal {
  background: #fff8e7;
  border: 2px solid #e6a817;
  border-radius: 16px;
  padding: clamp(20px, 5vw, 32px);
  text-align: center;
  min-width: clamp(260px, 70vw, 360px);
}

.result-modal h2 {
  color: #e6a817;
  font-size: clamp(20px, 5vw, 28px);
  margin-bottom: 16px;
}

.result-modal .result-time {
  font-size: clamp(28px, 7vw, 42px);
  font-weight: 700;
  color: #5d4037;
  margin-bottom: 8px;
}

.result-modal .result-best {
  font-size: clamp(14px, 3.5vw, 18px);
  color: #8d6e63;
  margin-bottom: 4px;
}

.result-modal .result-new-record {
  color: #e6a817;
  font-size: clamp(16px, 4vw, 22px);
  font-weight: 700;
  margin: 12px 0;
}

.result-modal button {
  margin-top: 20px;
  padding: 12px 32px;
  font-size: clamp(16px, 4vw, 20px);
  font-weight: 600;
  border-radius: 10px;
  background: #e6a817;
  color: #fff;
}

.result-modal button:active {
  background: #d4950f;
}

.result-modal .result-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}

.result-modal .result-btn-secondary {
  background: #e0d5c0;
  color: #5d4037;
}
