/* NYT Games Typography System */
@import url('https://fonts.googleapis.com/css2?family=Libre+Franklin:wght@400;600;700&family=Imperial:wght@400;600&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Libre Franklin', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #ffffff;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    color: #000000;
}

.game-container {
    background: #ffffff;
    border: 1px solid #d3d6da;
    border-radius: 8px;
    padding: 32px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    width: 100%;
    text-align: center;
}

header h1 {
    font-family: 'Libre Franklin', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #000000;
    font-size: 2.5em;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

header p {
    font-family: 'Imperial', Georgia, 'Times New Roman', serif;
    color: #565656;
    font-size: 1.1em;
    margin-bottom: 32px;
    font-weight: 400;
}

/* NYT-style separator line */
header::after {
    content: '';
    display: block;
    width: 240px;
    height: 1px;
    background: #000000;
    margin: 16px auto 24px auto;
}

.game-board {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 30px 0;
}

.circle-container {
    position: relative;
    width: min(350px, 90vmin);
    height: min(350px, 90vmin);
    aspect-ratio: 1 / 1;
    margin: 0 auto;
}

.circle {
    position: absolute;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.3s ease;
    transform-origin: center;
}

.circle:hover {
    transform: scale(1.02);
}

.circle-outer {
    width: 92%;
    height: 92%;
    top: 4%;
    left: 4%;
    border: 2px solid #000000;
    background: #ffffff;
}

.circle-middle {
    width: 68%;
    height: 68%;
    top: 16%;
    left: 16%;
    border: 2px solid #000000;
    background: #ffffff;
}

.circle-inner {
    width: 44%;
    height: 44%;
    top: 28%;
    left: 28%;
    border: 2px solid #000000;
    background: #ffffff;
}

.circle-center {
    width: 20%;
    height: 20%;
    top: 40%;
    left: 40%;
    border: 2px solid #000000;
    background: #ffffff;
    cursor: pointer;
    transition: transform 0.3s ease;
    transform-origin: center;
}

.circle-center:hover {
    transform: scale(1.02);
}

.circle-core {
    width: 6%;
    height: 6%;
    top: 47%;
    left: 47%;
    background: #f7da21;
    border: 2px solid #000000;
    cursor: default;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.circle-core:hover {
    transform: none;
}

.circle-segment {
    position: absolute;
    width: 40px;
    height: 40px;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Libre Franklin', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 600;
    color: #000000;
    text-shadow: none;
    background: #ffffff;
    border-radius: 50%;
    border: 2px solid #000000;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    z-index: 10;
    transition: all 0.2s ease;
    cursor: pointer;
}

.circle-segment:hover {
    background: #f0f0f0;
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.circle-segment:active {
    background: #e0e0e0;
    transform: translate(-50%, -50%) scale(0.95);
}

.circle-outer .circle-segment,
.circle-middle .circle-segment,
.circle-inner .circle-segment,
.circle-center .circle-segment {
    font-size: 1.2em;
    width: 40px;
    height: 40px;
}

/* Circle segments positioning - Cardinal directions with perfect alignment */
/* Using transform: translate(-50%, -50%) to center segments on their positions */

/* Outer circle segments positioning */
/* North */
.circle-outer .circle-segment:nth-child(1) {
    top: 0%;
    left: 50%;
    transform: translate(-50%, -50%);
}
/* East */
.circle-outer .circle-segment:nth-child(2) {
    top: 50%;
    left: 100%;
    transform: translate(-50%, -50%);
}
/* South */
.circle-outer .circle-segment:nth-child(3) {
    top: 100%;
    left: 50%;
    transform: translate(-50%, -50%);
}
/* West */
.circle-outer .circle-segment:nth-child(4) {
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
}

/* Middle circle segments positioning */
/* North */
.circle-middle .circle-segment:nth-child(1) {
    top: 0%;
    left: 50%;
    transform: translate(-50%, -50%);
}
/* East */
.circle-middle .circle-segment:nth-child(2) {
    top: 50%;
    left: 100%;
    transform: translate(-50%, -50%);
}
/* South */
.circle-middle .circle-segment:nth-child(3) {
    top: 100%;
    left: 50%;
    transform: translate(-50%, -50%);
}
/* West */
.circle-middle .circle-segment:nth-child(4) {
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
}

/* Inner circle segments positioning */
/* North */
.circle-inner .circle-segment:nth-child(1) {
    top: 0%;
    left: 50%;
    transform: translate(-50%, -50%);
}
/* East */
.circle-inner .circle-segment:nth-child(2) {
    top: 50%;
    left: 100%;
    transform: translate(-50%, -50%);
}
/* South */
.circle-inner .circle-segment:nth-child(3) {
    top: 100%;
    left: 50%;
    transform: translate(-50%, -50%);
}
/* West */
.circle-inner .circle-segment:nth-child(4) {
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
}

/* Center circle segments positioning */
/* North */
.circle-center .circle-segment:nth-child(1) {
    top: 0%;
    left: 50%;
    transform: translate(-50%, -50%);
}
/* East */
.circle-center .circle-segment:nth-child(2) {
    top: 50%;
    left: 100%;
    transform: translate(-50%, -50%);
}
/* South */
.circle-center .circle-segment:nth-child(3) {
    top: 100%;
    left: 50%;
    transform: translate(-50%, -50%);
}
/* West */
.circle-center .circle-segment:nth-child(4) {
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
}

.word-display {
    margin: 16px 0;
    padding: 12px;
    background: #f6f7f8;
    border: 1px solid #d3d6da;
    border-radius: 6px;
    font-family: 'Libre Franklin', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.95em;
    font-weight: 600;
    color: #000000;
    display: none;
    transition: all 0.3s ease;
}

.word-display.show {
    display: block;
    animation: slideDown 0.3s ease-out;
}

.word-line {
    margin: 8px 0;
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid #d3d6da;
    border-radius: 4px;
    font-family: 'Libre Franklin', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 600;
    color: #000000;
    transition: all 0.2s ease;
}

.word-complete {
    background: #6aaa64 !important;
    border-color: #6aaa64 !important;
    color: #ffffff !important;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 32px;
    flex-wrap: wrap;
    gap: 12px;
}

button {
    font-family: 'Libre Franklin', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #ffffff;
    color: #000000;
    border: 2px solid #000000;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

button:hover {
    background: #000000;
    color: #ffffff;
}

button:active {
    transform: translateY(1px);
}

#spin-btn {
    display: none;
}

.score {
    background: #f6f7f8;
    border: 1px solid #d3d6da;
    padding: 12px 16px;
    border-radius: 6px;
    color: #000000;
    font-family: 'Libre Franklin', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 600;
    font-size: 14px;
}

.win-message {
    position: fixed;
    top: 65%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #ffffff;
    border: 1px solid #d3d6da;
    padding: 32px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    text-align: center;
    display: none;
    z-index: 1000;
    max-width: 400px;
    width: 90%;
}

.win-message.show {
    display: block;
    animation: popIn 0.5s ease-out;
}

.win-message h2 {
    font-family: 'Libre Franklin', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #000000;
    margin-bottom: 16px;
    font-size: 1.8em;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.win-message p {
    font-family: 'Imperial', Georgia, 'Times New Roman', serif;
    color: #565656;
    margin-bottom: 24px;
    font-size: 1.1em;
    line-height: 1.4;
}

.win-message button {
    margin: 8px auto 0 auto;
    display: block;
    text-align: center;
}

.tomorrow-text {
    font-family: 'Imperial', Georgia, 'Times New Roman', serif;
    color: #888888;
    font-size: 0.9em;
    font-style: italic;
    margin-top: 16px;
    margin-bottom: 0;
    line-height: 1.3;
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes slideDown {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.rotating {
    animation: rotate 0.5s ease-in-out;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .game-container {
        padding: 15px;
        margin: 5px;
        max-width: 95vw;
    }
    
    header h1 {
        font-size: 1.8em;
    }
    
    header p {
        font-size: 1em;
        margin-bottom: 20px;
    }
    
    .game-board {
        margin: 20px 0;
    }
    
    /* Mobile letter sizing - consistent sizes across all circles */
    .circle-outer .circle-segment,
    .circle-middle .circle-segment,
    .circle-inner .circle-segment,
    .circle-center .circle-segment {
        font-size: 1.1em;
        width: 32px;
        height: 32px;
    }
    
    .controls {
        flex-direction: row;
        gap: 8px;
        margin-top: 20px;
        justify-content: center;
    }
    
    button {
        flex: 1;
        max-width: 90px;
        padding: 8px 12px;
        font-size: 11px;
    }
    
    .word-display {
        margin: 15px 0;
        padding: 12px;
        font-size: 1em;
    }
    
    .word-line {
        padding: 6px;
        margin: 3px 0;
    }
}

@media (max-width: 320px) {
    .game-container {
        padding: 10px;
        margin: 2px;
    }
    
    header h1 {
        font-size: 1.5em;
    }
    
    /* Extra small mobile letter sizing - consistent sizes across all circles */
    .circle-outer .circle-segment,
    .circle-middle .circle-segment,
    .circle-inner .circle-segment,
    .circle-center .circle-segment {
        font-size: 0.9em;
        width: 24px;
        height: 24px;
    }
    
    .word-display {
        font-size: 0.9em;
        padding: 10px;
    }
    
    button {
        padding: 8px 16px;
        font-size: 0.9em;
    }
}

/* Share Modal Styles */
.share-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.share-modal.show {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

.share-modal-content {
    background: #ffffff;
    border: 1px solid #d3d6da;
    border-radius: 12px;
    padding: 24px;
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease-out;
    text-align: center;
}

.share-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #d3d6da;
}

.share-modal-header h3 {
    font-family: 'Libre Franklin', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 1.4em;
    font-weight: 700;
    color: #000000;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #f0f0f0;
    color: #000;
}

.share-preview {
    text-align: center;
    margin: 20px 0;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

#share-canvas {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.share-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
    width: 100%;
    align-items: center;
}

.share-btn {
    font-family: 'Libre Franklin', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #ffffff;
    color: #000000;
    border: 2px solid #d3d6da;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0 auto;
    text-align: center;
}

.share-btn:hover {
    background: #f8f9fa;
    border-color: #000000;
}

.share-btn.primary {
    background: #000000;
    color: #ffffff;
    border-color: #000000;
}

.share-btn.primary:hover {
    background: #333333;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile responsiveness for share modal */
@media (max-width: 480px) {
    .share-modal-content {
        padding: 20px;
        margin: 10px;
        width: calc(100% - 20px);
    }
    
    .share-modal-header h3 {
        font-size: 1.2em;
    }
    
    .share-options {
        gap: 16px;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        width: 100% !important;
    }
    
    .share-btn {
        padding: 14px 20px;
        font-size: 14px;
        min-height: 48px;
        width: 100% !important;
        max-width: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        margin: 0 auto !important;
        box-sizing: border-box !important;
    }
}

/* iPhone specific fixes */
@media screen and (max-device-width: 480px) and (-webkit-min-device-pixel-ratio: 2) {
    .share-modal-content {
        text-align: center !important;
    }
    
    .share-options {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
    }
    
    .share-btn {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        display: block !important;
        text-align: center !important;
        justify-content: center !important;
        align-items: center !important;
    }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    .circle:hover {
        transform: none;
    }
    
    .circle:active {
        transform: scale(0.98);
    }
    
    .circle-segment:hover {
        background: #ffffff;
        transform: translate(-50%, -50%);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    }
    
    .circle-segment:active {
        background: #e0e0e0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    
    button:hover {
        transform: none;
    }
    
    button:active {
        transform: scale(0.95);
    }
    
    .share-btn:hover {
        background: #ffffff;
        border-color: #d3d6da;
    }
    
    .share-btn.primary:hover {
        background: #000000;
    }
}
