/* Fonts */
@import url('https://fonts.googleapis.com/css2?family=Muli:wght@900&display=swap');

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --success-light: #d1fae5;
    --danger-color: #ef4444;
    --danger-light: #fee2e2;
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

body,
input,
button {
    font-family: 'Muli', sans-serif;
    font-weight: 900;
    color: var(--text-dark);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: linear-gradient(160deg, #667eea 0%, #764ba2 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow-x: hidden;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(255, 255, 255, 0.06) 0%, transparent 50%);
    pointer-events: none;
    animation: float 20s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

h1 {
    font-size: 42px;
    font-weight: bold;
    margin-bottom: 15px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 1px;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.1));
    animation: titleGlow 3s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% { filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.1)); }
    50% { filter: drop-shadow(2px 2px 8px rgba(37, 99, 235, 0.2)); }
}

#game-date {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 15px;
}

#game-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    width: 80%;
    max-width: 1000px;
    margin: 20px auto;
    padding: 40px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 24px;
    box-shadow: 
        var(--shadow-xl), 
        0 0 0 1px rgba(0, 0, 0, 0.05),
        0 0 40px rgba(102, 126, 234, 0.15);
    text-align: center;
    animation: slideIn 0.5s ease-out;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

#game-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 70%
    );
    animation: shimmer 6s infinite;
    pointer-events: none;
}

@keyframes shimmer {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

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

#game-info {
    font-size: 20px;
    font-weight: bold;
    color: var(--primary-color);
}

#message-container {
    font-size: 26px;
    font-weight: bold;
    color: var(--primary-color);
    margin: 20px 0 10px;
    min-height: 30px;
    animation: fadeIn 0.3s ease-in;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#message-container:not(:empty) {
    padding: 12px 24px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.05), rgba(139, 92, 246, 0.05));
    border-radius: 12px;
    display: inline-block;
}

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

#instructions {
    font-size: 16px;
    color: var(--text-light);
    margin-top: 5px;
    line-height: 1.6;
}

.highlight {
    color: var(--primary-color);
    font-weight: bold;
    text-transform: uppercase;
    padding: 3px 8px;
    background: var(--primary-light);
    border-radius: 6px;
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.1);
    display: inline-block;
    animation: highlightGlow 2s ease-in-out infinite;
}

@keyframes highlightGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(37, 99, 235, 0.1); }
    50% { box-shadow: 0 0 15px rgba(37, 99, 235, 0.2); }
}


#after-game {
    display: flex;
    justify-content: center;
    align-items: center;
    column-gap: 25px;
}

#chain-count {
    font-size: 16px;
    font-weight: bold;
    color: #0056b3;
    margin: 10px 0;
}

/* Word Styles */
#start-word,
#end-word {
    font-size: 20px;
    font-weight: bold;
    color: var(--primary-color);
    margin: 10px 0;
    display: inline-block;
    width: 48%;
}

#chain-count {
    font-size: 16px;
    font-weight: 600;
    color: var(--secondary-color);
    margin: 15px 0;
    padding: 12px 24px;
    background: var(--primary-light);
    border-radius: 12px;
    display: inline-block;
    box-shadow: 
        0 2px 8px rgba(139, 92, 246, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(139, 92, 246, 0.2);
    animation: chainCountGlow 2s ease-in-out infinite;
}

@keyframes chainCountGlow {
    0%, 100% { box-shadow: 0 2px 8px rgba(139, 92, 246, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
    50% { box-shadow: 0 2px 16px rgba(139, 92, 246, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
}

/* Chain Styles */
#chain-container,
#example-chain-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 50px;
    max-width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
    border-radius: 12px;
    margin: 12px 0;
}

.word-box {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 24px;
    min-width: 90px;
    width: fit-content;
    height: fit-content;
    position: relative;
    flex-shrink: 0;
    border: 3px solid var(--primary-color);
    border-radius: 14px;
    background: linear-gradient(135deg, #ffffff 0%, var(--primary-light) 100%);
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 0.5px;
    box-shadow: 
        var(--shadow-md),
        0 0 20px rgba(37, 99, 235, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: popIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.word-box:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 
        var(--shadow-lg),
        0 0 30px rgba(37, 99, 235, 0.4),
        0 0 60px rgba(37, 99, 235, 0.2);
    border-color: var(--secondary-color);
}

.word-box.deadend {
    background: linear-gradient(135deg, var(--danger-color) 0%, #dc2626 100%) !important;
    border-color: var(--danger-color) !important;
    color: white !important;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.word-box.correct {
    background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%) !important;
    border-color: var(--success-color) !important;
    color: white !important;
    animation: bounce 0.6s;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.word-box:not(:last-child)::after {
    content: '→';
    color: var(--primary-color);
    position: absolute;
    right: -38px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
    animation: arrowPulse 2s ease-in-out infinite;
    z-index: 1;
}

@keyframes arrowPulse {
    0%, 100% { opacity: 0.7; transform: translateY(-50%) scale(1); }
    50% { opacity: 1; transform: translateY(-50%) scale(1.1); }
}

/* Form Styles */
.form-component {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    width: 100%;
}

#word-input {
    padding: 12px 18px;
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
    -webkit-appearance: none;
    appearance: none;
}

#word-input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 
        0 0 0 4px rgba(139, 92, 246, 0.15),
        0 0 20px rgba(139, 92, 246, 0.3),
        var(--shadow-md);
    transform: translateY(-2px) scale(1.01);
}

#word-input:disabled {
    background-color: #f9fafb;
    cursor: not-allowed;
    opacity: 0.6;
}

button {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

button:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 
        var(--shadow-lg),
        0 0 20px rgba(37, 99, 235, 0.4);
    filter: brightness(1.05);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.uppercase {
    text-transform: uppercase;
}

.button-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-left: 10px;
    gap: 10px;
}

#form-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: row;
    margin-top: 20px;
}

#additional-buttons-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 20px;
    margin-right: 10px;
    gap: 10px;
}

.open-help-modal-button,
.open-community-notes-button,
.open-stats-modal-button {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    right: 10px;
    top: 10px;
    padding: 0;
    width: 45px;
    height: 45px;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: var(--shadow-md);
}

.open-help-modal-button i,
.open-community-notes-button i,
.open-stats-modal-button i {
    pointer-events: none;
}

.open-help-modal-button:hover,
.open-community-notes-button:hover,
.open-stats-modal-button:hover {
    transform: scale(1.15) rotate(10deg);
    box-shadow: 
        var(--shadow-lg),
        0 0 20px rgba(37, 99, 235, 0.5);
    animation: iconPulse 0.6s ease;
}

@keyframes iconPulse {
    0%, 100% { transform: scale(1.15) rotate(10deg); }
    50% { transform: scale(1.2) rotate(12deg); }
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: linear-gradient(135deg, #ffffff 0%, #fafbff 100%);
    margin: 2.5% auto;
    padding: 0;
    border: none;
    border-radius: 24px;
    width: 85%;
    max-width: 700px;
    max-height: 90vh;
    box-shadow: 
        var(--shadow-xl),
        0 0 60px rgba(37, 99, 235, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    overflow: hidden;
    animation: slideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
}

.modal-content > .modal-header {
    flex-shrink: 0;
}

.modal-content > .modal-nav {
    flex-shrink: 0;
    padding: 0 30px 15px 30px;
    background: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-content > div:not(.modal-header):not(.modal-nav) {
    padding: 15px 30px 30px 30px;
    overflow-y: auto;
    flex: 1;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22px 30px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 24px 24px 0 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    position: relative;
    z-index: 20;
    margin-bottom: 5px;
}

.modal-title {
    flex-grow: 1;
    text-align: center;
    color: white;
    font-size: 22px;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.5px;
}

.modal-content h3 {
    margin-top: 15px;
    margin-bottom: 10px;
    font-size: 19px;
    color: var(--text-dark);
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 6px;
}

.modal-content p {
    line-height: 1.6;
    color: var(--text-light);
    margin-bottom: 12px;
    font-size: 14px;
}

.modal-content p:first-of-type {
    margin-top: 0;
}

.modal-content p strong {
    color: var(--text-dark);
    font-weight: 900;
}

.note-element {
    display: flex;
    justify-content: space-between;
    flex-direction: column;
    background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
    padding: 15px;
    border-radius: 12px;
    margin: 12px 0;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.note-line {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

.notes-title {
    font-size: 15px;
    font-weight: 900;
    color: var(--primary-color);
    min-width: 120px;
}

.notes-content {
    font-size: 15px;
    color: var(--text-dark);
    text-align: right;
    flex: 1;
}

.modal-content hr {
    border: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-light), transparent);
    margin: 15px 0;
}

/* Submit Phrase Modal Styles */
#submit-phrase-form {
    display: flex;
    flex-direction: column;
    margin-top: 20px;
    gap: 10px;
    margin-bottom: 10px;
}

#submit-phrase-phrase-section {
    display: flex;
    flex-direction: row;
    gap: 10px;
}

#submit-phrase-phrase-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
}

#submit-phrase-start-word,
#submit-phrase-end-word {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
}

#submit-phrase-start-word label,
#submit-phrase-end-word label {
    font-size: 16px;
    color: #333;
    margin-bottom: 5px;
}

#start-word-input,
#end-word-input {
    padding: 10px 14px;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 16px;
}

#start-word-input:focus,
#end-word-input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

#explanation-input {
    padding: 10px 14px;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    margin: 0px 20px;
    transition: all 0.3s ease;
    font-size: 16px;
}

#explanation-input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

#submit-phrase-button-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

#submit-phrase-submit-button:hover {
    background-color: #003d82;
}

#submit-phrase-submit-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

#submit-phrase-submit-button-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
}

.blue-link {
    color: var(--primary-color);
    text-decoration: underline;
    transition: color 0.2s ease;
}

.blue-link:visited {
    color: var(--secondary-color);
}

.blue-link:hover {
    color: var(--primary-hover);
}

.blue-link:active {
    color: var(--primary-hover);
}

#example-see-more-table-container {
    display: flex;
    gap: 10px;
}

.example-see-more-table {
    width: 100%;
    border-collapse: collapse;
}

.example-see-more-table-wrapper {
    flex: 1;
    text-align: center;
}

.example-see-more-table-wrapper p {
    font-size: 16px;
    color: #333;
    margin-top: 0px;
    margin-bottom: 5px;
}

/* Chain Info Modal Styles */
.chain-info-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.chain-info-table th, .chain-info-table td {
    border: 1px solid var(--border-color);
    padding: 12px;
    text-align: center;
}

.chain-info-table th {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    font-weight: bold;
}

.chain-info-table tr:nth-child(even) {
    background-color: #f9fafb;
}

.chain-info-table tr:hover {
    background-color: var(--primary-light);
    transition: background-color 0.2s ease;
}

.chain-info-additional-messages {
    margin-top: 20px;
    background: var(--primary-light);
    padding: 15px;
    border-radius: 12px;
    border-left: 4px solid var(--primary-color);
}

.chain-info-additional-messages p {
    margin-top: 0px;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--text-dark);
    text-align: left;
    line-height: 1.5;
}

.chain-info-additional-messages p:last-child {
    margin-bottom: 0;
}

.close-button {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.2);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    transition: all 0.25s ease;
    border: 2px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
    padding: 0;
}

.close-button:hover,
.close-button:focus {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Modal Navigation Styles */
.modal-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 18px;
    padding-bottom: 5px;
}

.nav-button {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 10px 20px;
    box-shadow: var(--shadow-sm);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.nav-button.active,
.nav-button:disabled {
    background: var(--primary-color);
    cursor: not-allowed;
    transform: none;
    opacity: 0.7;
}

.modal-content-section {
    display: none;
}

.modal-content-section.active {
    display: block;
}

/* Stats Modal Styles */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    padding: 20px 0;
}

.stat-card {
    background: linear-gradient(135deg, #ffffff 0%, var(--primary-light) 100%);
    border: 2px solid var(--primary-color);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    box-shadow: 
        var(--shadow-md),
        0 0 20px rgba(37, 99, 235, 0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}

.stat-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 
        var(--shadow-lg),
        0 0 30px rgba(37, 99, 235, 0.2);
    border-color: var(--secondary-color);
}

.stat-icon {
    font-size: 36px;
    margin-bottom: 10px;
    animation: statIconFloat 3s ease-in-out infinite;
}

@keyframes statIconFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
}

.stat-value {
    font-size: 32px;
    font-weight: 900;
    color: var(--primary-color);
    margin-bottom: 6px;
    line-height: 1;
    text-shadow: 0 2px 4px rgba(37, 99, 235, 0.1);
}

.stat-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Responsive Styles */
@media (max-width: 768px) {
    #game-container {
        width: 90%;
        padding: 20px;
    }

    #chain-container {
        flex-direction: column;
        gap: 20px;
    }

    .form-component {
        flex-direction: column;
    }

    #word-input {
        width: 100%;
    }

    #message-container,
    #start-word,
    #end-word,
    .word-box {
        font-size: 18px;
    }
}

/* Tablet Screens */
@media (max-width: 768px) and (min-width: 481px) {
    body {
        padding: 10px;
    }

    #game-container {
        width: 95%;
        max-width: 100%;
        margin: 15px auto;
        padding: 25px;
    }

    h1 {
        font-size: 32px;
        margin-bottom: 10px;
    }

    #game-info {
        font-size: 16px;
        flex-direction: column;
        gap: 8px;
    }

    #start-word,
    #end-word {
        width: 100%;
        margin: 5px 0;
    }

    #chain-container {
        gap: 30px;
        padding: 12px;
        overflow-x: auto;
        justify-content: flex-start;
    }

    .word-box {
        font-size: 16px;
        padding: 14px 18px;
        min-width: 80px;
        flex-shrink: 0;
    }

    .word-box:not(:last-child)::after {
        right: -28px;
        font-size: 20px;
    }

    #word-input {
        padding: 12px 16px;
        font-size: 16px;
        width: 200px;
    }

    button {
        padding: 12px 20px;
        font-size: 14px;
    }

    .button-container {
        margin-left: 8px;
        gap: 8px;
    }

    .modal-content {
        width: 90%;
        max-height: 85vh;
    }

    .modal-header {
        padding: 18px 25px;
    }

    .modal-title {
        font-size: 20px;
    }

    .modal-content h3 {
        font-size: 17px;
    }

    .modal-content p {
        font-size: 13px;
    }

    .close-modal {
        font-size: 24px;
        padding: 8px 12px;
    }

    .open-help-modal-button,
    .open-community-notes-button,
    .open-stats-modal-button {
        width: 50px;
        height: 50px;
        font-size: 22px;
    }

    #additional-buttons-container {
        margin-right: 15px;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 12px;
    }

    .stat-card {
        padding: 18px;
    }

    .stat-value {
        font-size: 28px;
    }

    .stat-icon {
        font-size: 32px;
    }

    #message-container {
        font-size: 20px;
    }
}

/* Phone Screens */
@media (max-width: 480px) and (min-width: 320px) {
    body {
        padding: 0;
        margin: 0;
        overflow-x: hidden;
    }

    * {
        box-sizing: border-box;
    }

    #game-container {
        width: 100%;
        max-width: 100%;
        margin: 10px 0;
        padding: 16px;
        border-radius: 16px;
        box-shadow: var(--shadow-lg), 0 0 40px rgba(102, 126, 234, 0.1);
        box-sizing: border-box;
    }

    h1 {
        font-size: 28px;
        margin-bottom: 8px;
    }

    #game-date {
        font-size: 14px;
        margin-bottom: 10px;
    }

    #game-info {
        font-size: 14px;
        flex-direction: column;
        gap: 6px;
        display: flex;
    }

    #start-word,
    #end-word {
        width: 100%;
        margin: 4px 0;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    #start-word .uppercase,
    #end-word .uppercase {
        order: 2;
    }

    #instructions {
        font-size: 13px;
        line-height: 1.5;
    }

    .highlight {
        padding: 2px 6px;
        font-size: 12px;
    }

    #chain-container {
        flex-direction: column;
        gap: 12px;
        padding: 10px;
        margin: 10px 0;
    }

    .word-box {
        font-size: 14px;
        padding: 12px 16px;
        min-width: 70px;
        border: 2px solid var(--primary-color);
        box-shadow: var(--shadow-md), 0 0 15px rgba(37, 99, 235, 0.15);
        max-width: 85vw;
        word-break: break-word;
    }

    .word-box:not(:last-child)::after {
        display: none;
    }

    #chain-count {
        font-size: 14px;
        padding: 10px 16px;
        margin: 8px 0;
    }

    #form-container {
        flex-direction: column;
        gap: 12px;
        margin-top: 15px;
    }

    #word-input {
        width: 100%;
        padding: 14px 16px;
        font-size: 16px;
        border: 2px solid var(--primary-color);
        border-radius: 10px;
        box-sizing: border-box;
    }

    #word-input:focus {
        font-size: 16px;
    }

    .button-container {
        margin-left: 0;
        width: 100%;
        gap: 10px;
        box-sizing: border-box;
    }

    #submit-button,
    #undo-button {
        flex: 1;
        padding: 14px 16px;
        font-size: 14px;
        min-width: 90px;
    }

    button {
        -webkit-touch-callout: none;
        user-select: none;
    }

    #message-container {
        font-size: 16px;
        margin: 12px 0 8px;
        min-height: 28px;
    }

    #message-container:not(:empty) {
        padding: 10px 16px;
        border-radius: 10px;
    }

    .modal {
        background-color: rgba(0, 0, 0, 0.7);
    }

    .modal-content {
        width: 95%;
        max-width: 95vw;
        max-height: 90vh;
        margin: 5vh auto;
        border-radius: 20px;
        box-sizing: border-box;
        overflow-y: auto;
    }

    .modal-header {
        padding: 16px 20px;
        border-radius: 20px 20px 0 0;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .modal-title {
        font-size: 18px;
    }

    .close-modal {
        font-size: 20px;
        padding: 6px 10px;
        width: auto;
        height: auto;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 8px;
        transition: all 0.3s ease;
    }

    .close-modal:hover {
        background: rgba(255, 255, 255, 0.3);
    }

    .modal-nav {
        padding-top: 14px;
        padding-bottom: 4px;
    }

    .nav-button {
        padding: 9px 16px;
        font-size: 12px;
    }

    .modal-content > div:not(.modal-header):not(.modal-nav) {
        padding: 0 16px 20px 16px;
    }

    .modal-content h3 {
        margin-top: 12px;
        margin-bottom: 8px;
        font-size: 16px;
    }

    .modal-content p {
        font-size: 13px;
        line-height: 1.5;
        margin-bottom: 10px;
    }

    .modal-content p strong {
        display: block;
        margin-bottom: 4px;
    }

    .note-element {
        padding: 12px;
        margin: 10px 0;
        border-radius: 10px;
    }

    .notes-title {
        font-size: 13px;
        min-width: 100px;
    }

    .notes-content {
        font-size: 13px;
    }

    .open-help-modal-button,
    .open-community-notes-button,
    .open-stats-modal-button {
        width: 48px;
        height: 48px;
        font-size: 20px;
        box-shadow: var(--shadow-md);
    }

    #additional-buttons-container {
        margin-top: 15px;
        margin-right: 8px;
        gap: 8px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 15px 0;
    }

    .stat-card {
        padding: 16px;
        border-radius: 14px;
    }

    .stat-value {
        font-size: 26px;
        margin-bottom: 4px;
    }

    .stat-icon {
        font-size: 32px;
        margin-bottom: 6px;
    }

    .stat-label {
        font-size: 12px;
    }

    #example-chain-container {
        gap: 20px;
        padding: 12px;
        margin: 10px 0;
    }

    #example-see-more-table-container {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .example-see-more-table-wrapper {
        flex: 1;
    }

    .example-see-more-table-wrapper p {
        margin-bottom: 8px;
        font-size: 12px;
    }

    .chain-info-table {
        font-size: 12px;
        overflow-x: auto;
    }

    .chain-info-table th {
        padding: 8px 4px;
        font-size: 11px;
    }

    .chain-info-table td {
        padding: 6px 4px;
        font-size: 11px;
    }

    #submit-phrase-form {
        gap: 8px;
        margin-top: 15px;
    }

    #submit-phrase-phrase-section {
        flex-direction: column;
        gap: 10px;
    }

    #submit-phrase-start-word,
    #submit-phrase-end-word {
        margin-bottom: 8px;
    }

    #start-word-input,
    #end-word-input,
    #explanation-input {
        padding: 12px 14px;
        font-size: 16px;
        width: 100%;
    }

    #explanation-input {
        margin: 0;
    }

    #after-game {
        flex-direction: column;
        gap: 15px;
        margin-top: 20px;
    }
}

/* Landscape Mode (Small Screens) */
@media (max-height: 500px) and (orientation: landscape) {
    #game-container {
        padding: 12px;
        margin: 5px auto;
    }

    h1 {
        font-size: 22px;
        margin-bottom: 6px;
    }

    #game-info {
        font-size: 12px;
        gap: 4px;
    }

    #instructions {
        font-size: 12px;
        margin-top: 3px;
    }

    #chain-container {
        gap: 15px;
        padding: 8px;
        margin: 8px 0;
    }

    .word-box {
        font-size: 12px;
        padding: 8px 12px;
    }

    #form-container {
        gap: 8px;
        margin-top: 10px;
    }

    #word-input {
        padding: 10px 14px;
        font-size: 14px;
    }

    #submit-button,
    #undo-button {
        padding: 10px 14px;
        font-size: 12px;
    }

    .open-help-modal-button,
    .open-community-notes-button,
    .open-stats-modal-button {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
}
