/* Уникальный префикс poly-app для всех стилей */
.poly-app-container {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    max-width: 600px;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.poly-app-container * {
    box-sizing: border-box;
}

.poly-canvas {
    border: 1px solid #999;
    background: white;
    width: 450px;
    height: 450px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    margin: 20px auto;
    display: block;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.poly-canvas.anim-rotate-cw {
    animation: rotateCW 0.3s ease-out;
}

.poly-canvas.anim-rotate-ccw {
    animation: rotateCCW 0.3s ease-out;
}

.poly-canvas.anim-flip-h {
    animation: flipH 0.3s ease-out;
}

.poly-canvas.anim-flip-v {
    animation: flipV 0.3s ease-out;
}

.poly-canvas.anim-flip-d1 {
    animation: fadeOutIn 0.3s ease-out;
}

.poly-canvas.anim-flip-d2 {
    animation: fadeOutIn 0.3s ease-out;
}

@keyframes rotateCW {
    0% { transform: rotate(0deg) scale(1); opacity: 1; }
    50% { transform: rotate(-45deg) scale(0.8); opacity: 0.6; }
    100% { transform: rotate(0deg) scale(1); opacity: 1; }
}

@keyframes rotateCCW {
    0% { transform: rotate(0deg) scale(1); opacity: 1; }
    50% { transform: rotate(45deg) scale(0.8); opacity: 0.6; }
    100% { transform: rotate(0deg) scale(1); opacity: 1; }
}

@keyframes flipH {
    0% { transform: scaleX(1); opacity: 1; }
    50% { transform: scaleX(0); opacity: 0.3; }
    100% { transform: scaleX(1); opacity: 1; }
}

@keyframes flipV {
    0% { transform: scaleY(1); opacity: 1; }
    50% { transform: scaleY(0); opacity: 0.3; }
    100% { transform: scaleY(1); opacity: 1; }
}

@keyframes fadeOutIn {
    0% { opacity: 1; }
    50% { opacity: 0.2; }
    100% { opacity: 1; }
}

.poly-controls {
    margin: 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.poly-input-group {
    width: 100%;
    max-width: 500px;
}

.poly-textarea {
    width: 100%;
    height: 150px;
    font-family: 'Courier New', monospace;
    padding: 10px;
    border: 1px solid #ccc;
    background: #fff;
    font-size: 14px;
    line-height: 1.4;
    resize: vertical;
}

.poly-button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 10px 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    background: #fff;
}

.poly-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    cursor: pointer;
    background: #4CAF50;
    color: white;
    border: none;
    font-size: 22px;
    transition: background 0.3s;
    border-radius: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.poly-btn:hover {
    background: #45a049;
}

.poly-btn:active {
    background: #3d8b40;
}

.poly-btn:focus {
    outline: none;
    background: #4CAF50;
}

.poly-btn-random {
    background: #008CBA;
}

.poly-btn-magic {
    background: #9C27B0;
}

.poly-btn-knight {
    background: #FF5722;
}

.poly-btn-symmetric {
    background: #00BCD4;
}

.poly-btn-spiral {
    background: #4CAF50;
}

.poly-btn-target {
    background: #E91E63;
}

.poly-btn-hilbert {
    background: #8BC34A;
}

.poly-btn-snake {
    background: #FF9800;
}

.poly-btn-diagonal {
    background: #FFC107;
}

.poly-btn-copy {
    background: #FF9800;
}

.poly-btn-save {
    background: #9C27B0;
}

.poly-btn-svg {
    background: #607D8B;
}

.poly-transform-group {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    background: #fff;
    padding: 10px 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.poly-transform-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    cursor: pointer;
    background: #555;
    color: white;
    border: none;
    font-size: 20px;
    transition: background 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: normal;
}

.poly-transform-btn:hover {
    background: #777;
}

.poly-transform-btn:focus {
    outline: none;
    background: #555;
}

.poly-transform-btn.rotate-cw { background: #2196F3; }
.poly-transform-btn.rotate-cw:hover { background: #0b7dda; }
.poly-transform-btn.rotate-ccw { background: #2196F3; }
.poly-transform-btn.rotate-ccw:hover { background: #0b7dda; }
.poly-transform-btn.flip-h { background: #FF9800; }
.poly-transform-btn.flip-h:hover { background: #e68900; }
.poly-transform-btn.flip-v { background: #FF9800; }
.poly-transform-btn.flip-v:hover { background: #e68900; }
.poly-transform-btn.flip-d1 { background: #9C27B0; }
.poly-transform-btn.flip-d1:hover { background: #7B1FA2; }
.poly-transform-btn.flip-d2 { background: #9C27B0; }
.poly-transform-btn.flip-d2:hover { background: #7B1FA2; }
.poly-transform-separator {
    width: 1px;
    height: 30px;
    background: #ccc;
    margin: 0 5px;
}

.poly-line-control {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #fff;
    padding: 10px 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.poly-line-control label {
    font-weight: bold;
    min-width: 80px;
    text-align: center;
    font-size: 20px;
}

.poly-line-control input {
    width: 200px;
}

.poly-line-value {
    font-weight: bold;
    min-width: 40px;
    text-align: center;
}

.poly-color-input {
    width: 40px;
    height: 40px;
    border: 2px solid #333;
    cursor: pointer;
    transition: transform 0.2s;
    padding: 0;
    background: #FF4444;
}

.poly-color-input:hover {
    transform: scale(1.05);
}

.poly-color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.poly-color-input::-webkit-color-swatch {
    border: none;
}

.poly-size-row {
    display: flex;
    align-items: center;
    gap: 20px;
    background: #fff;
    padding: 10px 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    flex-wrap: wrap;
    justify-content: center;
}

.poly-size-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.poly-size-control span {
    font-weight: bold;
    font-size: 18px;
}

.poly-size-control input {
    width: 70px;
    padding: 5px;
    font-size: 14px;
    border: 1px solid #ccc;
}

.poly-checkbox-group {
    display: flex;
    align-items: center;
    gap: 20px;
}

.poly-checkbox-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 18px;
}

.poly-checkbox-group input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
}

.poly-generation-group {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    background: #fff;
    padding: 10px 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.poly-generation-group2 {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    background: #fff;
    padding: 10px 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.poly-gen-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    cursor: pointer;
    color: white;
    border: none;
    font-size: 20px;
    transition: background 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.poly-gen-btn:hover {
    filter: brightness(0.9);
}

.poly-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #4CAF50;
    color: white;
    padding: 12px 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 10000;
    font-size: 14px;
    max-width: 300px;
    word-wrap: break-word;
    border-radius: 0;
}

.poly-notification.show {
    transform: translateX(0);
}

.poly-notification.error {
    background: #f44336;
}