.game-container {
    max-width: 540px;
    margin: 1rem auto;
}
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
    color: #fff;
}
.badge-time { background: #a40505; }
.badge-wrong { background: #757575; }
.badge-easy { background: #4caf50; }
.badge-medium { background: #2196f3; }
.badge-hard { background: #ff9800; }
.badge-diabolical { background: #f44336; }
.timer { font-size: 0.85rem; font-family: monospace; color: #fff; }
.mistakes-count { font-size: 0.85rem; color: #ffffff; }
.rating-display { color: #fff; background: #0288d1; padding: 0.25rem 0.75rem; border-radius: 20px; font-size: 0.85rem; font-weight: bold; }
.user-status { font-size: 0.8rem; color: #fff; background: #6a1b9a; padding: 0.25rem 0.75rem; border-radius: 20px; }

.board-wrapper { touch-action: manipulation; }
.board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    aspect-ratio: 1;
    border: 3px solid #333;
    background: #fff;
    user-select: none;
}
.cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(16px, 4vw, 28px);
    font-weight: bold;
    border: 1px solid #aaa;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}
.cell:hover { background: #e3f2fd; }
.cell.fixed { color: #111; background: #f5f5f5; cursor: default; }
.cell.fixed:hover { background: #f5f5f5; }
.cell.selected { background: #bbdefb !important; }
.cell.highlight { background: #e8eaf6; }
.cell.same-num { background: #c5cae9; }
.cell.error { color: #d32f2f; background: #ffcdd2; }
.cell.success-flash { animation: flash 0.4s; }
.cell .notes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    width: 100%;
    height: 100%;
}
.cell .notes span {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(7px, 1.5vw, 11px);
    color: #666;
    font-weight: normal;
}

.cell.box-right { border-right: 2px solid #333; }
.cell.box-bottom { border-bottom: 2px solid #333; }
.cell.box-top { border-top: 2px solid #333; }
.cell.box-left { border-left: 2px solid #333; }

.controls {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}
.ctrl-btn {
    padding: 0.8rem 1.2rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}
.ctrl-btn:hover { background: #f0f0f0; border-color: #999; }
.ctrl-btn.active { background: #1a1a2e; color: #fff; border-color: #1a1a2e; }
.ctrl-btn.danger:hover { background: #ffcdd2; }
.ctrl-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.numpad {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 0.3rem;
    margin-top: 0.8rem;
}
.numpad .num-btn {
    padding: 0.8rem 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    font-size: clamp(18px, 4vw, 26px);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.numpad .num-btn:hover { background: #e3f2fd; border-color: #90caf9; }
.numpad .num-btn.completed { opacity: 0.3; pointer-events: none; }
.numpad .num-count {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 0.65rem;
    color: #999;
    font-weight: normal;
}

.numpad-popup {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.5rem;
    background: #fff;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    display: none;
    z-index: 200;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.1);
}
.numpad-popup.show {
    display: block;
    animation: slideUp 0.2s ease-out;
}
.numpad-popup .grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.numpad-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: none;
    z-index: 199;
}
.numpad-overlay.show {
    display: block;
}
.numpad-popup .num-btn {
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    font-size: 26px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.numpad-popup .num-btn:hover { background: #e3f2fd; border-color: #90caf9; }
.numpad-popup .num-btn.completed { opacity: 0.3; pointer-events: none; }
.numpad-popup .num-count {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 0.65rem;
    color: #999;
    font-weight: normal;
}

.bottom-bar {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}
.action-btn {
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: 6px;
    background: #e94560;
    color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}
.action-btn:hover { background: #d73750; }
.action-btn.secondary { background: #1a1a2e; }
.action-btn.secondary:hover { background: #2a2a4e; }

.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    align-items: center;
    justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    max-width: 360px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}
.modal h2 { margin-bottom: 0.5rem; }
.modal p { color: #666; margin-bottom: 1rem; }
.modal .action-btn { margin: 0.3rem; }

.share-item {
    background: #f8f8f8;
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 0.8rem 70px 0.8rem 0.8rem;
    margin: 0.5rem 0;
    word-break: break-all;
    font-family: monospace;
    font-size: 0.8rem;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    min-height: 2.4rem;
    display: flex;
    align-items: center;
}
.share-item:active { transform: scale(0.98); }
.share-item::after {
    content: '点击复制';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: #999;
    font-family: sans-serif;
    white-space: nowrap;
    pointer-events: none;
}
.share-item.copied {
    border-color: #4caf50;
    background: #e8f5e9;
    color: #2e7d32;
}
.share-item.copied::after {
    content: '已复制!';
    color: #4caf50;
}
.share-label {
    font-weight: bold;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    margin-bottom: 0.2rem;
    display: block;
}

.puzzle-rank {
    max-width: 540px;
    margin: 2rem auto;
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.puzzle-rank h3 { margin-bottom: 1rem; }
.puzzle-rank table { width: 100%; border-collapse: collapse; }
.puzzle-rank th, .puzzle-rank td {
    padding: 0.6rem 0.8rem;
    text-align: center;
    border-bottom: 1px solid #f0f0f0;
}
.puzzle-rank th { background: #f8f8f8; }
.rank-1 { color: #ffd700; }
.rank-2 { color: #c0c0c0; }
.rank-3 { color: #cd7f32; }

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
@keyframes flash {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}
@media (max-width: 450px) {
    .controls {
  display: flex;
  justify-content: center;
  gap: 0.3rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.ctrl-btn {
  padding: 0.6rem 1rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}
.action-btn {
  padding: 0.5rem 0.8rem;
}
}