* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Hiragino Mincho ProN', 'Yu Mincho', '游明朝', serif;
}

body {
    background-color: #f7f7f7;
    color: #333;
    padding: 20px;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #2c3e50;
}

.writing-area {
    margin-bottom: 10px;
    position: relative;
}

.manuscript-paper {
    display: flex;
    flex-wrap: wrap;
    flex-direction: row-reverse;
    width: 100%;
    margin: 0 auto;
    height: auto;
    justify-content: center;
    font-family: 'Hiragino Mincho ProN', 'Yu Mincho', '游明朝', serif;
}

.character-column {
    display: flex;
    flex-direction: column;
    height: 400px;
    margin-left: 10px;
}

.character-cell {
    width: 40px;
    height: 40px;
    border: 1px solid #ccc;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    cursor: text;
    position: relative;
}

.punctuation {
    position: absolute;
    right: 2px;
    top: 2px;
    font-size: 16px;
}

.punctuation-end {
    position: absolute;
    right: 0;
    bottom: 0;
    font-size: 16px;
}

.rotated-char {
    transform: rotate(90deg);
    display: inline-block;
}

.character-cell.current {
    background-color: #f0f7ff;
}

.character-cell.current::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 2px solid #3498db;
    box-sizing: border-box;
}

.character-counter {
    text-align: right;
    font-size: 14px;
    color: #666;
    margin-top: 10px;
}

.buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.settings-group, .action-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

button {
    padding: 8px 16px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #2980b9;
}

#clear-btn {
    background-color: #e74c3c;
}

#clear-btn:hover {
    background-color: #c0392b;
}

#export-image-btn {
    background-color: #9b59b6;
}

#export-image-btn:hover {
    background-color: #8e44ad;
}

.input-area {
    margin-bottom: 20px;
    text-align: center;
}

#japanese-input {
    width: 80%;
    padding: 8px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.color-selector {
    display: flex;
    align-items: center;
    margin-right: 5px;
}

.color-selector select {
    padding: 5px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 14px;
    margin-left: 5px;
}

.color-label {
    font-size: 14px;
}

.font-selector {
    display: none;
}

.saved-compositions {
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 4px;
}

h2 {
    font-size: 18px;
    margin-bottom: 10px;
    color: #2c3e50;
}

ul {
    list-style-type: none;
}

.author {
    font-size: 12px;
    color: #777;
    display: flex;
    align-items: center;
    margin-right: 10px;
    align-self: flex-end;
}

.author-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-right: 5px;
    object-fit: cover;
}

li {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    position: relative;
}

.text-column {
    display: flex;
    flex-direction: column;
    margin-left: 15px;
    height: 280px;
    font-family: 'Hiragino Mincho ProN', 'Yu Mincho', '游明朝', serif;
}

.char-span {
    height: 28px;
    width: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

li span.vertical-text {
    display: flex;
    flex-direction: row-reverse;
    height: auto;
    margin: 0 auto;
    font-size: 18px;
    line-height: 1.6;
    margin-bottom: 10px;
}

li span.vertical-text .punctuation {
    position: absolute;
    right: 2px;
    top: 2px;
    font-size: 16px;
}

li span.vertical-text .punctuation-end {
    position: absolute;
    right: 0;
    bottom: 0;
    font-size: 16px;
}

li span.vertical-text .rotated-char {
    transform: rotate(90deg);
    display: inline-block;
}

li span:first-child {
    flex-grow: 1;
}

li:last-child {
    border-bottom: none;
}

.delete-btn {
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 3px 8px;
    cursor: pointer;
    font-size: 12px;
    position: absolute;
    right: 10px;
    bottom: 10px;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fff;
    margin: 10% auto;
    padding: 20px;
    border-radius: 8px;
    max-width: 500px;
    position: relative;
}

.close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
}

.rules-content {
    margin-top: 15px;
}

.rules-btn {
    background-color: #2ecc71;
}

@media (max-width: 480px) {
    .container {
        padding: 15px;
    }
    
    .character-cell {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }
    
    .manuscript-paper {
        height: 360px;
    }
}